Tkinter question - Canvas widget

Tristan Juricek tjuricek at ucsd.edu
Tue Mar 21 01:57:52 EST 2000


Ok, I'm running into difficulties trying to use the Canvas widget in my
little GUI interface.  It's not working like I thought it would.  I
tried looking at the tk documentation, but, er, I think there might be a
nice soul out there who might help enlighten me a bit faster than it
would take me to figure it out on my own.

Here's the deal.  I've got this frame widget in which I'd like to
display overlapping sets of images (actually, a variable length hand of
cards for a blackjack game).  From what I can figure out, you make an
instance of a Canvas widget and then you add various PhotoImage
instances to the widget (each starting at a new x and y coordinate in
the canvas).  Well, here's what I'm doing:

This takes place within a derived frame class (which is the frame that I
want to add the canvas to).

pic_dlr1 = PhotoImage( file = "./pics/back1.gif" )
self.can_dlr1 = Canvas(self)
self.img_dlr1 = self.can_dlr1.create_image(0, 0,  anchor=W,
image=pic_dlr1)
self.can_dlr1.pack()

Right now, I see an empty space with nothing in it.  Are there more
options I need to specify?  Also, my overall plan is to add overlapping
images.  So, would I do that with successive calls to (canvas
object).create_image(x,y,...) where the x and y coordinates are the
start of the next image?

I'm a bit confused here, any enlightenment would be gratefully
appreciated.  And if nothing else, I guess I'll just have to figure out
the tk business.  Ergh.

-Tristan




More information about the Python-list mailing list