How to create a Tk bitmap?

Grant Edwards ge at nowhere.none
Sat Jun 17 15:54:54 EDT 2000


In article <394BC4CD.6432CBBF at uniserve.com>, Bob van der Poel wrote:

>> >>    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)

Yes, I did.  Does that work for you?

>without the quotes around the name? Remember, 'queen' is a string,

Yes, I know.  According to the documentation, the argument
value for the bitmap option is supposed to be a string
specifying a bitmap in a manner acceptible to Tk_Getbitmap.
Tk_Betbitmap accepts two types of strings:

    "@filename"   will read the data from a file.
    
    "bitmapname"  will use the previously defined bitmaped of
                  that name

>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.

Yes, I tried making it global and making it an instance
variable.  Neither one made a difference.

I am wondering if BitmapImage is somehow not adding the name of
the created bitmap to the global list of "known" bitmaps, or if
the name is somehow getting mangled so the name that Tk knows
about is different than the one Python presents to the user.

Does anybody know how to see the list of "known" bitmaps?

-- 
Grant Edwards                   grante             Yow!  .. Now KEN and BARBIE
                                  at               are PERMANENTLY ADDICTED to
                               visi.com            MIND-ALTERING DRUGS...



More information about the Python-list mailing list