from tkinter import * #Note that PhotoImage from tkinter is only guaranteed to #work with GIF images. You will have to use PIL to convert #JPEG's or other image types. #Also note that you MUST keep a reference to the PhotoImage #object. If you do not, the image it holds will be garbage #collected! win= Tk() class PhotoDemo: def __init__(self,mainWin): #The following line of code won't work! #Because the PhotoImage #does not have a reference pointing at it, #The python garbage collector may eat it! # l = Label(win, image=PhotoImage(file="cg.gif")) #Also, the following two lines wont work either! #because the "photo" variable disapears as soon #as the __init__ method stops! #photo = PhotoImage(file="cg.gif") #l = Label(win, image=photo) #If you make the photo variable an object #variable it will "stick around" and work. self.photo = PhotoImage(file="cg.gif") l = Label(win, image=self.photo) #You could also use a global variable, or #even add a new object variable to the label #with code like this: #photo = PhotoImage(file="cg.gif") #l = Label(win, image=photo) #l.photo = photo l.pack() app = PhotoDemo(win) win.mainloop()