I'm building a small program where different parts of the code will call on one object different times. I'd like to try and make it call the previous frame back instead of duplicating the actual code multiple times. Here is part of my code if you need an example:
#Console Menu
class consoleMenu(tk.Frame):
#Initialize
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
#Setups
consoleGuideLabel = ttk.Label(self, text = "Console Guide", font = LARGE_FONT)
consoleItemInfoButton = ttk.Button(self, text = "Console Item Info", command = lambda: controller.show_frame(consoleItemInfo))
consoleVersionButton = ttk.Button(self, text = "Console Version History", command = lambda: popupmsg ("Not supported just yet!"))
consoleMainMenuButton = ttk.Button(self, text = "Main Menu", command = lambda: controller.show_frame(StartPage))
#Placement
consoleGuideLabel.pack(pady = 10, padx = 10)
consoleItemInfoButton.pack()
consoleVersionButton.pack()
consoleMainMenuButton.pack()
Now this is the part that gets called on multiple times by different frames.
#Air - MCPE, PC, Xbox
class mc_air(tk.Frame):
#Initialize
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
#Item Info
text_file = open("minecraft_air.txt", "r")
file = text_file.read()
text_file.close()
#Setups
airLabel = ttk.Label(self, text = "Minecraft - Air - 1", font = LARGE_FONT)
airInfo = ttk.Label(self, text = file, font = NORMAL_FONT)
exitButton = ttk.Button(self, text = "Return to Menu", command = lambda: controller.show_frame(StartPage))
#Placement
airLabel.pack(pady = 10, padx = 10)
airInfo.pack()
exitButton.pack()
Where it says:
exitButton = ttk.Button(self, text = "Return to Menu", command = lambda: controller.show_frame(StartPage))
I'd like to be able to replace StartPage with a command to go to the previous window.