[Python-de] RE: [Tutor] Images + Tkinter

Martin v. Loewis martin at v.loewis.de
Sun Nov 17 22:10:09 EST 2002


alan.gauld at bt.com writes:

> >     canvas.create_image(200, 250, image=photo)
> 
> Why doesn't this retain a reference to the image and stop it 
> being dropped?

Because the -image option is just a string, and Tcl doesn't do
refcounting of images (or, it does, but it will discard them anyway
even if they are still in use), see

https://sourceforge.net/tracker/?func=detail&aid=633300&group_id=12997&atid=362997

> In fact all of these objects should go out of scope at the end of 
> the function except for the fact they are parented on tk which is 
> global. So why does the image die but not the button?

Image.__del__ deletes the image, but there is no Button.__del__.

Regards,
Martin




More information about the Python-de mailing list