[IMAGE-SIG] Changing a displayed image

Andrew Kuchling amk@magnet.com
Thu, 10 Jul 1997 11:23:05 -0400 (EDT)


How does one change an image being displayed under Tkinter using
ImageTk.PhotoImage?  Here's the code that creates the widget
displaying the image:

	im=Image.open('/scratch/rob.ppm')
	image = ImageTk.PhotoImage(im)
	self.viewer=Tk.Label(self, image=image, bd=0)
	self.viewer.pack(side=RIGHT, fill=Y)

I'm trying to update the image on hitting a button, using the
following code, which destroys the Label widget and recreates it:

	im=Image.open('/scratch/rob.ppm')
	im=im.transpose(Image.ROTATE_90)
	image = ImageTk.PhotoImage(im)
	self.viewer.destroy()
	self.viewer=Tk.Label(self, image=image, bd=0)
	self.viewer.pack(side=RIGHT, fill=Y)

When this code gets run, the window resizes as appropriate (since the
image isn't square) but the image isn't displayed; the area remains
blank.  What am I missing?  (Presumably this is due to my poor
understanding of Tkinter.)


	Andrew Kuchling
	amk@magnet.com
	http://people.magnet.com/%7Eamk/

_______________
IMAGE-SIG - SIG on Image Processing with Python

send messages to: image-sig@python.org
administrivia to: image-sig-request@python.org
_______________