Skip to content Skip to sidebar Skip to footer

Python Tkinter Update Image

I have problem with updating picture in canvas in tkinter. I'm using Python 3.3. from tkinter import * class Testi(): def __init__(self): self.canvas = Canvas(root, wi

Solution 1:

Like the original image, you need to keep a reference to the new image, or it will get garbage collected prematurely. Just overwrite the old image sitting at self.img.

def changeImg(self):

    self.img = PhotoImage(file="cell.pgm")

    self.canvas.itemconfig(self.imgArea, image = self.img)

Post a Comment for "Python Tkinter Update Image"