Tkinter question - Canvas widget
Christian Tanzer
tanzer at swing.co.at
Tue Mar 21 02:29:30 EST 2000
Tristan Juricek <tjuricek at ucsd.edu> wrote :
> 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.
You need to keep a reference to the PhotoImage:
self.pic_dlr1 = pic_dlr1 = PhotoImage( file = "./pics/back1.gif" )
Otherwise the image is lost, when `pic_dlr1' goes out of scope.
--
Christian Tanzer tanzer at swing.co.at
Glasauergasse 32 Tel: +43 1 876 62 36
A-1130 Vienna, Austria Fax: +43 1 877 66 92
More information about the Python-list
mailing list