[Tutor] Images + Tkinter

Magnus Lycka magnus@thinkware.se
Sat Dec 21 10:21:02 2002


I just remembered this old thread as I looked at the
PIL docs at New Mexico Tech...

At 17:50 2002-11-17 +0000, alan.gauld@bt.com wrote:
> > def window(tk):
> >     global photo       #### SIC!
> >     frame=Tkinter.Frame(tk)
> >     frame.pack()
> >     canvas=Tkinter.Canvas(frame,width=400,height=500)
> >     canvas.pack()
> >     photo=Tkinter.PhotoImage(file="picture.gif")
> >     canvas.create_rectangle(10,20,30,40, fill="red")
> >     canvas.create_image(200, 250, image=photo)
>
>Why doesn't this retain a reference to the image and stop it
>being dropped?

I just stumbled over this:

http://www.nmt.edu/tcc/help/pubs/pil.pdf

On page 6 it says there is a bug in PIL's PhotoImage, so
that reference count isn't bumped up as it should. I can't
personally verify that this is a bug and not a design choice,
but it's at least a known problem...



-- 
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/  mailto:magnus@thinkware.se