I've searched for an answer but it seems that no one has had this issue before. I don't know what I am missing. Here's a simplified version of the code, with the same problem:
app = tk.Tk()
location = 'C:\\Users\\User\\Desktop'
image = location + '\\ab.PNG'
image_final = tk.PhotoImage(file = image)
var = tk.StringVar(app)
list_file=['1','2']
def do(event):
if var.get() == 1:
image = location + '\\cd.PNG'
else:
image = location + '\\ab.PNG'
image_final = tk.PhotoImage(file = image)
a.config(image = image_final)
style_optionMenu = ttk.Style()
style_optionMenu.configure('style_option.TMenubutton', background = "green", foreground = "white")
option_athletes = ttk.OptionMenu(app,var,list_file[0],*list_file, style = 'style_option.TMenubutton', command = do )
option_athletes.config(width = 20)
option_athletes.pack()
a= tk.Label(master = app, image = image_final)
a.pack()
app.mainloop()
The problem is that, although displaying a first image, whenever I change the value in the OptioMenu, the image simply vanishes and doesn't reaper anymore. Everything else (not in this example code) is performing just fine. Does anyone have any clue or knows a better alternative to do this? Thank you very much!