Main/Parent Class
class tkinterApp(tk.Tk): #Root Window
def __init__(self):
#main set up
super().__init__()
self.geometry("700x700")
self.title('Wuiz')
#widgets
#Trying to switch between "frames", have to comment out so they all arent on one window
#self.Homepage = Homepage(self)
self.Weatherpage = Weatherpage(self)
self.mainloop()
This Being the main class followed by Frame classes:
WeatherPage Frame/Class -> Holding widget elements, labels, buttons, etc.. then packing it to the main root window
class Weatherpage(tk.Frame):
def __init__(self, parent):
super().__init__(parent)
# Back Button at corner => to homepage
backbutton = Button(self, text="Back", fg="black", font=("Helvetica", 10), width=30)
....etc ...
self.pack(expand=True, fill="both") # Problem probably here
Then the info class/frame -> Again Holding widget elements, labels, buttons, etc.. then packing it to the main root window
class Infopage(tk.Frame):
def __init__(self, parent):
super().__init__(parent)
backbutton = Button(self, text="Back", fg="black", font=("Helvetica", 10),
width=30) # Back button does nothing
backbutton.pack(side=TOP, anchor=NW)
..... etc...
self.pack(expand=True, fill="both") # Problem probably here
if __name__ == '__main__':
tkinterApp()
Do you guys know any methods or soultions/ways to switch frames based of this? I think it might be how I am packing the classes to the root window, I probably need to switch it off and on somehow.