I have an image in a label and I want that image to be changed when I press the button but instead of changing the image the window becomes blank:
from tkinter import *
from PIL import Image,ImageTk
import os
root = Tk()
root.state("zoomed")
def chng():
photo2 = ImageTk.PhotoImage(Image.open("upload.jpg"))
img.config(image = photo2)
img.grid()
photo = ImageTk.PhotoImage(Image.open("cat.jpg"))
img = Label(root,image = photo)
upload = Button(root, text= "Upload" ,height = 3, width = 12, command =
chng)
upload.grid( )
for col_num in range(root.grid_size()[1]):
root.columnconfigure(col_num, minsize=600)
for row_num in range(root.grid_size()[1]):
root.rowconfigure(row_num, minsize=60)
img.grid()
root.mainloop()