from tkinter import *
from PIL import ImageTk,Image
master =Tk()
canvas= Canvas(master, height=600, width=750)
canvas.pack()
frame_image=Frame(master,bg="wheat")
frame_image.place(relx=0.05 ,rely=0.05,relwidth=0.75,relheight=0.75 )
def function():
img = ImageTk.PhotoImage(Image.open("image.jpg").resize((170, 170)))
org_img = Label(frame_image, image=img)
org_img.place(relx=0.07, rely=0.07,anchor ='nw')
function()
master.mainloop()
I'm trying to show an image in the gui. If I don't define the image in the function, it works, but if I define it in the function, only the white frame appears. What is the reason ?
from tkinter import *
from PIL import ImageTk,Image
master =Tk()
canvas= Canvas(master, height=600, width=750)
canvas.pack()
frame_image=Frame(master,bg="wheat")
frame_image.place(relx=0.05 ,rely=0.05,relwidth=0.75,relheight=0.75 )
img = ImageTk.PhotoImage(Image.open("image.jpg").resize((170, 170)))
org_img = Label(frame_image, image=img)
org_img.place(relx=0.07, rely=0.07,anchor ='nw')
master.mainloop()