How to create a Tk bitmap?

Grant Edwards nobody at nowhere.nohow
Fri Jun 16 23:14:12 EDT 2000


I can't figure out how to create a Tk bitmap and then use it in
a button.  According to the docs I can find, something like this
ought to work:


    myBitmap = BitmapImage(name='myBitmap', data='[...]')

    Button(root,bitmap='myBitmap')

But, Tk complains that there is no bitmap named 'myBitmap'.  If
I leave out the "name=" when I create the bitmap and then use
the name retrieved with str(myBitmap), I get the same error.

I have managed to get it to work with bitmap data from a file:

    Button(root,bitmap='@filename')

But I don't want to have to write the data to a file just so Tk
can read it back in.  Anybody have any examples of defining new
bitmaps?
    
-- 
Grant Edwards                   grante             Yow!  That's a decision
                                  at               that can only be made
                               visi.com            between you & SY SPERLING!!



More information about the Python-list mailing list