How to create a Tk bitmap?

Bob van der Poel bvdpoel at uniserve.com
Sat Jun 17 14:34:53 EDT 2000


Grant Edwards wrote:
> 
> On Sat, 17 Jun 2000 09:25:10 -0700, Bob van der Poel <bvdpoel at uniserve.com> wrote:
> 
> >> Yes, I know.  The call to BitmapImage() works fine, the error occurs when I
> >> try to use the bitmap in a button like:
> >>
> >>    Button(root, bitmap='queen')
> >>
> >> This is where the error occurs -- it doesn't matter if I use the name I
> >> specified in the call to BitmapImage or let Tk generate one and retrieve it
> >> with str().  What I can't figure out is how to use bobpic as the bitmap for
> >> a Button.
> >>
> >
> >More from my snippet:
> >
> >       l = Label(w, image=bobpic, borderwidth=4, relief='sunken')
> 
> Yes, using it as the widget's image works, but I'm trying to
> use it as the bitmap for the widget.

Oh, ummm did you try:

	 Button(root, bitmap=queen)

without the quotes around the name? Remember, 'queen' is a string, not
the name of the variable where the data is stored. Also, don't let this
bite you: if this is a function then the variable has to declared global
otherwise when the function exits the variable (and the display)
disappear.

-- 
   __
  /  )      /         Bob van der Poel
 /--<  ____/__        bvdpoel at uniserve.com
/___/_(_) /_)         http://users.uniserve.com/~bvdpoel



More information about the Python-list mailing list