I am trying to make an employee registration form in Tkinter and I have a problem inserting employee image to the canvas after browsing it from my pc
all I want to click the button under the canvas and browse for my image to automatically insert it to the canvas
from tkinter import *
import os
from tkinter import filedialog
from PIL import Image,ImageTk
def imageselect():
global filepath
filepath = filedialog.askopenfilename()
entry.insert(END, filepath)
return filepath
window = Tk()
btn = Button(window ,text = "select image",command = imageselect)
btn.pack()
x = StringVar()
entry= Entry(window,textvariable = x)
entry.pack(fill=X)
canvas = Canvas(window,width = 200,height = 200,bg="black")
img = PhotoImage(file=entry.get())
canvas.create_image(0,0,anchor=NW,image=img)
canvas.pack()
window.mainloop()