I want to display an image in a canvas through a button command, but it doesn't work !
this is the code:
from Tkinter import Tk,Button,Canvas,PhotoImage
from PIL import Image, ImageTk
def plot ():
image = Image.open("img1.png")
image = image.resize( (400,300), Image.ANTIALIAS)
img = ImageTk.PhotoImage(image)
canvas.create_image(200, 175, image = img)
return 0
tkk = Tk()
canvas = Canvas(tkk, \
width =400, height =650, \
bg="light yellow")
canvas.pack(side ="right")
button_plot = Button(tkk, text = "dessiner", command = dessiner, width = 50, fg = "red")
button_plot.pack()
mw.mainloop()
I tried to use : TopLevel() in my function ' plot()' but i got the same result which is a canvas without any image !