How can I update the canvas from a function called by a button? Here's my code:
from Tkinter import * import ImageTk tk = Tk() canvas = Canvas(tk, bg="white", width=300, height=200) canvas.grid() def displayLabel(): photoimage = ImageTk.PhotoImage(file="Logo.png") canvas.create_image(0,0, image=photoimage, anchor = NW) b3 = Button(tk, text="Display Label", width=30, command= displayLabel()) b3.grid(row=1) tk.mainloop() Pressing the "Display Label" button does nothing. I've tried designating the canvas global in the method, or passing the canvas in as an argument (using command = lambda (displayLabel(canvas)), both to no effect. What am I doing wrong?
UPDATE: I now realize my question is a duplicate of this one, but @shalitmaan's answer helped me in ways the other one didn't.