I've been trying to make a program which will import a png file and display it inside a frame. It actually works when I just run the code, but if I try to abstract the exact same code into a function, it fails. In the code below, if I just run it, it works. However, if I comment out the lines between "root=Tkinter.Tk()" and "moo(root)" and comment in "moo(root)", it no longer works. Instead of displaying the image, it just displays a gray frame of the correct size. Does anyone have any insights about what I'm doing wrong?
import Image, ImageTk, Tkinter def moo(master): img = Image.open('plotfig.png') f = Tkinter.Frame(master, width=800, height=600) pi = ImageTk.PhotoImage(img) t = Tkinter.Label(f, image=pi) f.pack() t.place(x=0, y=0, width=800, height=600) t.pack() root = Tkinter.Tk() img = Image.open('plotfig.png') f = Tkinter.Frame(root, width=800, height=600) pi = ImageTk.PhotoImage(img) t = Tkinter.Label(f, image=pi) f.pack() t.place(x=0, y=0, width=800, height=600) t.pack() #moo(root) root.mainloop() Thanks very much. Alan -- View this message in context: http://www.nabble.com/Possibly-n00bish-question-about-ImageTk-tf3990201.html#a11330353 Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org http://mail.python.org/mailman/listinfo/tkinter-discuss