I'm trying to use tkinter filedialog and PIL to open an image, resize it and show it in a frame along with a button to clear the frame and return the original button. The frame is resizing as though the image is there but it's not visible. I have the same problem if I remove the 'change button', however, this is the weird part, if the change button returns an error - like if i use pack instead of grid or if i put a typo in the command - the image shows up just fine.
Any ideas would be much appreciated.
from tkinter import *
from tkinter import filedialog
from PIL import ImageTk, Image
root = Tk()
root.title("Gateway")
root.geometry("400x400")
def open_image():
global new_logo
for objects in logo_frame.winfo_children():
objects.grid_remove()
filename = filedialog.askopenfilename(initialdir="/c", title="Select an image", filetypes=(("jpg files", "*.jpg"), ("png files", "*.png")))
new_logo = Image.open(filename)
resized = new_logo.resize((200, 123), Image.ANTIALIAS)
new_pic = ImageTk.PhotoImage(resized)
def remove_logo():
logo_label.destroy()
change_button.destroy()
upload_logo_button.grid()
logo_label = Label(logo_frame, image=new_pic)
logo_label.grid(row=0, column=0)
change_button = Button(logo_frame, text="Remove Logo", command=remove_logoo)
change_button.grid(row=1, column=0)
logo_frame = Frame(root)
logo_frame.grid(row=9, column=0, sticky=NW, rowspan=8, columnspan=2)
upload_logo_button = Button(logo_frame, text="Browse", width=13, height=4, command=open_image)
upload_logo_button.grid(row=1, column=2, padx=10, pady=10)
root.mainloop()