Hello, I'm a newbie to Python (literally, within the last two weeks), and I am playing around with Tkinter to build some simple GUIs. I am attempting to build a simple class that displays a GIF. Here is the code:
#start of code from Tkinter import * class DisplayPict(Frame): def __init__(self,parent=None): Frame.__init__(self,parent) self.pack() self.img=PhotoImage(file="moon.gif") self.can=Canvas(self) self.can.create_image(2,2,image=self.img,anchor=NW) self.can.pack(fill=BOTH) #keep a reference to the img around self.can.photo=self.img if __name__ == '__main__': DisplayPict().mainloop() #end of code Anyway, I started with this code in Windoze using IDLE, and everytime I ran it I kept getting an empty frame (well, presumably with a Canvas that had nothing in it). I kept thinking that it had to be something to do with the whole images-get-garbage-collected-if-not-referenced issue that I read so much about. So I tried a bunch of different permutations and nothing made a difference. On a whim, I tried this code under Linux, and amazingly, it worked just fine: the image was displayed as expected. So...I am confused. I tried to do my homework (i.e., read through "Programming Python", "Learning Python", and scouring the internet), but I can't come up with an explanation as to why this doesn't work under Windoze. Can anyone out there show me the error in what I have? Thanks in advance, John O -- http://mail.python.org/mailman/listinfo/python-list