tkinter canvas bitmaps w/ xbm formated string data?

Brett brett_gengler at
Sat Aug 14 21:00:15 CEST 2004

I'm trying to load a xbm formatted string as a bitmap and draw it to a
canvas....I don't have any trouble with loading/displaying xbm files,
it's when I've pre-created the xbm as a string I get a 'can't find
your bitmap error'

<created my canvas and I draw other objects that are displayed

xbm_string = "#define arrow_width 1 #define arrow_height 16 static
char arrow_bits[] = {
a_bitmap = Tkinter.BitmapImage(data=xbm_string) 

print a_bitmap.width() #prints out 1
print a_bitmap.height() #print out 16

canvas.create_bitmap(100,100, bitmap=a_bitmap)  #if I used
bitmap="@line.xbm" with the exact same string as defined above, the
xbm is displayed correctly.

When the create_bitmap executes I get:
  File "C:\June 5th datamaster\", line 360, in
    self.canvas.create_bitmap(100,100, bitmap=a_bitmap)
  File "<string>", line 1, in create_bitmap
  File "C:\Python23\lib\lib-tk\", line 2057, in
    return self._create('bitmap', args, kw)
  File "C:\Python23\lib\lib-tk\", line 2049, in _create
    return getint(
TclError: bitmap "pyimage1" not defined

...I have a feeling that I somehow lost a reference to my bitmap
object...I'm not sure what's happening.

any ideas what could be wrong?


More information about the Python-list mailing list