TKinter PhotoImage Class?? - 2nd round

Fredrik Lundh fredrik at pythonware.com
Tue Oct 16 08:33:40 CEST 2001


Robert C. Ramsdell wrote:
> When I try the method above in the method, the Canvas remains empty.
> No errror message is given, the image just is not displayed.  Does anyone
> know why this is happening?

you must keep a reference to the PhotoImage object.  see
FAQ question 4.69 for a bit more information:

    http://www.python.org/doc/FAQ.html#4.69

>         def draw_image(self, iname):
>                 self.drawspace.pack()
>                 i=PIL.ImageTk.PhotoImage(file=iname)

                 self.photo = i

>                 self.drawspace.create_image(0,0,image=i)

</F>

<!-- (the eff-bot guide to) the python standard library:
http://www.pythonware.com/people/fredrik/librarybook.htm
-->





More information about the Python-list mailing list