.canvas create bitmap $x $y -bitmap \
@my_icon.xbm -anchor nw -foreground green
Later, I decided I would like to take out the dependence on "my_icon.xbm"
so I could move the program without having to shlepp around the icon file.
Looking at the "image" command, I decided to inline the icon like:
set bmdata {
#define my_icon_width 64
#define my_icon_height 64
static char my_icon_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
many lines omitted..
....
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00};
}
set my_icon [ image create bitmap \
-background black -foreground white -data $bmdata]
This seems to work, or at least it doesn't complain, and sets $my_icon
to "image1".
But, when I try to follow through to the canvas, and do
.canvas create bitmap $x $y -bitmap \
$my_icon -anchor nw -foreground green
it barfs:
Error in startup script: bitmap "image1" not defined
(processing "-bitmap" option)
invoked from within
Am I missing something, or is there some odd reason that "image create"
bitmaps are disjoint from canvas bitmaps?
Thanks,
Ted
When you create something with the 'image' command, bitmap or photo
type, it is an image to the rest of Tk. The -bitmap option to
widgets is only for the older style bitmap (-image came much later
and is a better generic mechanism). Just use -image.
--
Jeff Hobbs The Tcl Guy
Senior Developer http://www.ActiveState.com/
Tcl Support and Productivity Solutions