hi everyone. i'm try to load an image by clicking on a botton insert imag but the problem thata i having with this is that
the image is not being insert it just appear and disappear immediately.
can anyone tell me what is wrong with my codes and tel me how to do it.
thanks...
here is my code
import Tkinter as tk
from PIL import Image, ImageTk
import Tkinter
from Tkconstants import *
frame=tk.Frame()
frame.pack()
canvas =tk.Canvas(frame,bg = 'white',width=500, height=500)
canvas.pack()
def image():
imageFile = "map.png"
image1 = ImageTk.PhotoImage(Image.open(imageFile))
canvas.create_image(200, 250, image=image1)
canvas.update()
button=tk.Button(frame,fg="blue", text="Insert Image", activebackground='red',font=('verdana', 10, 'bold'),command=image)
button.pack(padx =50,side = "left")
frame.mainloop()
i want when i click on the insert image button the image appear on the canvas.