PIL+Tkinter query (I must be doing something _really_ stupid)

Fredrik Lundh fredrik at pythonware.com
Tue Jul 13 15:19:13 EDT 1999


Markus Stenberg <mstenber at cc.Helsinki.FI> wrote:
> Ok, even with the topic, this is a warning: total clueness incoming ;)
> From Markus's adventures in PIL+Tkinter-land..
> 
> from Tkinter import *
> tk = Tk()
> Label(tk, text='foo').pack()
> tk.mainloop()
> 
> This works. Ok. (me, a Tcl/Tk guru, snicker)
> 
> Then, we add:
> import ImageTK
> and change Label to have
> Label(tk, image=ImageTk.PhotoImage(image)).pack()
> 
> The image is fine; image.save() produces the required output; it's RGB
> image with some map data, to be precise. HOWEVER: The label has correct
> size (size of the image) but no image data whatsoever. The same problem
> applies to all approaches I've tried (using Canvas and putting it on one,
> etc). 

see:
http://www.python.org/doc/FAQ.html#4.69

suggested change:

photo = ImageTk.PhotoImage(image)
w = Label(tk, image=photo)
w.photo = photo
w.pack()

</F>





More information about the Python-list mailing list