How to create a Tk bitmap?
Grant Edwards
nobody at nowhere.nohow
Sat Jun 17 12:02:09 EDT 2000
In article <394AEFE7.6F3B718C at uniserve.com>, Bob van der Poel wrote:
>> 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.
>The data is an exact copy of the file. For example:
>
> bobpic = BitmapImage (data = """
> #define bob_width 107
> #define bob_height 154
> static char bob_bits[] = {
>
>0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
> 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
>< blessedly snipped >
> 0xff,0xff,0xff}; """ )
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.
--
Grant Edwards grante Yow! An air of FRENCH
at FRIES permeates my
visi.com nostrils!!
More information about the Python-list
mailing list