Changing image in label

Fredrik Lundh fredrik at effbot.org
Fri Dec 8 11:25:10 CET 2000


2rkil at my-deja.com wrote:
> What happens is that the first picture disappears,
> and just the frame (the sizes) of the new one appears.

you have to keep a reference to the image in your Python
program.  the easiest way is to make it a global variable, or
to add it as an attribute to the widget objekt:

    global gif # keep a reference
    gif = PhotoImage(file=photo)
    photo_widget["image"] = gif

or

    gif = PhotoImage(file=photo)
    photo_widget.image = gif # keep a reference
    photo_widget["image"] = gif

for more info, see:

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

</F>





More information about the Python-list mailing list