Tkinter
Fredrik Lundh
fredrik at pythonware.com
Sun Apr 9 02:35:05 EDT 2006
"Jay" <first180 at gmail.com> wrote:
> Cold somebody please enlighten me at why code 1 works perfectly and yet
> code to will not display the gif file.
> code 2
> -----------START---------
>
> from Tkinter import *
>
> class App:
> def __init__(self, root):
> self.MainFrame = Canvas(root)
> self.MainFrame.pack(fill=BOTH, expand=1)
>
> BackgroundFile = PhotoImage(file="Background.GIF")
> Tank1 = self.MainFrame.create_image(0, 0, image=BackgroundFile)
>
> root = Tk()
> app = App(root)
> root.mainloop()
>
> -----------END---------
> Thanks
you need to keep a reference to the photo object on the Python side
of things, to keep it from being garbage collected.
see the note at the bottom of this page:
http://www.effbot.org/tkinterbook/photoimage.htm
</F>
More information about the Python-list
mailing list