bitmap problem

Robin Becker robin at
Sun Jan 20 14:58:12 CET 2008

I'm having trouble with defining a completely transparent bitmap
for use as a stipple in a canvas

import Tkinter'image','create', 'bitmap', 'gray0',
                 '-background', '',
		'-data', '#define gray0_width 1\n#define gray0_height 1\nstatic char 
gray0_bits[] = {\n0x0\n};')
print 'image names','image','names')
print 'image type','image','type','gray0')
self.canv.create_rectangle("10i", "10i", "13.5i", "13.5i",

the prints seem to indicate that the bitmap is defined, but the canvas 
create_rectangle fails

image names gray0
image type bitmap
Traceback (most recent call last):
   File "C:\Tmp\", line 67, in <module>
   File "C:\Tmp\", line 62, in main
     top = PDFMU()
   File "C:\Tmp\", line 59, in __init__
   File "C:\Tmp\", line 44, in createWidgets
     self.canv.create_rectangle("10i", "10i", "13.5i", "13.5i", 
   File "C:\Python\lib\lib-tk\", line 2166, in create_rectangle
     return self._create('rectangle', args, kw)
   File "C:\Python\lib\lib-tk\", line 2145, in _create
     *(args + self._options(cnf, kw))))
_tkinter.TclError: bitmap "gray0" not defined

if I change gray0 to one of the predefined names eg gray12 then the 
create_rectangle succeeds. The tk manual seems to suggest I should be 
able to do this, but it doesn't seem to work even in tk. Is there a way 
to define a stipple without a file?
Robin Becker

More information about the Python-list mailing list