[Tutor] ImageTk problem

Rick Pasotto rick@niof.net
Fri, 23 Feb 2001 14:53:54 -0500


The following code produces no error and no visible picture. The size of
the picture is known since using a different image will change the size
of the label. It doesn't matter whether it's a gif or a jpg.

What am I overlooking?

from Tkinter import *
import Image, ImageTk

class Main:
	def __init__(self,win):
		self.win = win
		im1 = Image.open("picture.gif")
		im2 = ImageTk.PhotoImage(im1)
		Label(self.win, image = im2).pack()
		b = Button(self.win,text='Quit',height=2)
		b.pack()
		b.config(command = lambda w = self.win: w.destroy())

def main():
	root = Tk()
	Main(root)
	root.mainloop()

if __name__ == '__main__':
	main()

-- 
"The financial policy of the welfare state requires that there be no
way for the owners of wealth to protect themselves.  This is the
shabby secret of the welfare statists' tirades against gold.   Deficit
spending is simply a scheme for the 'hidden' confiscation of wealth.
Gold stands in the way of this insidious process.   It stands as a
protector of property rights."
		-- Alan Greenspan
		   Rick Pasotto email: rickp@telocity.com