Changing image in label

Fredrik Lundh fredrik at
Fri Dec 8 05:25:10 EST 2000

2rkil at 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


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

for more info, see:


More information about the Python-list mailing list