Tkinter.PhotoImage question
Fredrik Lundh
effbot at telia.com
Sun Oct 8 10:15:14 EDT 2000
Kent wrote:
> I would like to display image files onto labels and canvasses. I noticed
> however, that if I call PhotoImage from within a function, no image will
> appear. When I run the following code, a photo appears on the label but
> not the canvas, even though the lines and bitmap do appear. Is this a
> Tkinter bug? Is there a workaround?
You must keep a reference to the photoimage object.
For example:
c = Tkinter.Canvas(f)
c.pack()
c.photo2 = Tkinter.PhotoImage(file="lena.gif")
...
c.create_image(10,10,anchor=Tkinter.NW, image=c.photo2)
...
for more info, see:
http://www.python.org/doc/FAQ.html#4.69
</F>
<!-- (the eff-bot guide to) the standard python library:
http://www.pythonware.com/people/fredrik/librarybook.htm
-->
More information about the Python-list
mailing list