I want to add an image to a topframe in tkinter
. It works on the MainMenu
, but not on the SideMenu
. When run, it should show _test.gif on the first menu, and when the button is pressed, open the second menu and show _test2.gif. Currently, the second menu is blank - no image.
Code:
import tkinter as tk
class MainMenu(object):
def __init__(self):
self.launch_MainMenu()
def launch_MainMenu(self):
self._mainMenuWindow = tk.Tk()
self.imageGIF = tk.PhotoImage(file="_test.gif");
self.imageLabel = tk.Label(self._mainMenuWindow,image=self.imageGIF)
self.imageLabel.grid(row=0,column=1,padx=10,pady=10)
tk.Button(self._mainMenuWindow,text="Next Menu",
command=SideMenu).grid(row=0,column=2,padx=10)
tk.mainloop()
class SideMenu(object):
def __init__(self):
self.launch_sideMenu()
def launch_sideMenu(self):
self._sideWindow = tk.Toplevel()
self.imageGIF2 = tk.PhotoImage(file="_test2.gif")
self.imageLabel2 = tk.Label(self._sideWindow,image=self.imageGIF2)
self.imageLabel2.grid(row=0,column=1,padx=10,pady=10)