Tkinter question: image on canvas
Hans Nowak
ivnowa at hvision.nl
Sat Dec 4 16:52:47 EST 1999
OK, replying to my own message... I think I found the problem. A
typical case of "duh"...
>
> -----------begin code---------
>
> from Tkinter import *
>
> class MemoryFrame (Frame):
> .
> .
> def createImage(self):
> img = PhotoImage(file="c:/001.gif")
> print img
> id = self.canvas.create_image(40, 40, image=img, anchor=NW)
> print id
This creates an image, and stores the only reference to the
PhotoImage instance as a local variable. In other words, it will be
destroyed as soon as the end of this method is reached. No wonder it
doesn't display the image... =/
My other program didn't have this problem since it stored all images
nicely in a dictionary.
Duh-ly yours,
--Hans Nowak (zephyrfalcon at hvision.nl)
Homepage: http://fly.to/zephyrfalcon
You call me a masterless man. You are wrong. I am my own master.
More information about the Python-list
mailing list