bitmap problem

R

Robin Becker

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


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


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\test.py", line 67, in <module>
main()
File "C:\Tmp\test.py", line 62, in main
top = PDFMU()
File "C:\Tmp\test.py", line 59, in __init__
self.createWidgets()
File "C:\Tmp\test.py", line 44, in createWidgets
self.canv.create_rectangle("10i", "10i", "13.5i", "13.5i",
fill="blue",activestipple='gray0')
File "C:\Python\lib\lib-tk\Tkinter.py", line 2166, in create_rectangle
return self._create('rectangle', args, kw)
File "C:\Python\lib\lib-tk\Tkinter.py", 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?
 
R

Robin Becker

Robin said:
I'm having trouble with defining a completely transparent bitmap
for use as a stipple in a canvas
........
after a bit of searching I find that stipples cannot be created with the
tk image command; for non-standard stipples you need to use a file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top