I may not understand inheritance very well, or I might have missed some details about it. I was reading https://stackoverflow.com/a/40130619/5989438, and thought I need to do it this way, however it's not working.
I have a complete program in the Application() class, which is located in tab "Week_1". For OOP, and my limited knowledge, I was thinking creating a class for each tab (each week) so I wrote the program like this. If there is a better set up, I am happy to learn. Thanks for the assistance. Here is the shorten version of the program.
import tkinter as tk
from tkinter import ttk
#upper tabs
upper_tabs = ["Final", "Requests", "Control"]
lower_tabs = ["Week 1", "Week 2"]
tabs2 = {} #upper
tabs = {} #lower
class Application(tk.Frame): #inherent from frame.
def __init__(self, parent):
tk.Frame.__init__(self, parent, bg="tan")
self.parent = parent
self.pack(fill=tk.BOTH, expand=1)
self.Days= ["Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday", "Sunday"]
self.GUI()
def GUI(self): #the function that runs all the GUI functions.
self.create_lower_tabs()
####---------create grid_GUI---------------------####
def create_lower_tabs(self):
style1 = ttk.Style()
style1.configure("down.TNotebook", tabposition = "sw")
self.tabControl_lower = ttk.Notebook(self, width=1200,
height=550, padding = 0,
style = "down.TNotebook" )
for name in lower_tabs:
self.tab1=tk.Frame(self.tabControl_lower, bg='old lace')
self.tabControl_lower.add(self.tab1, text=name, )
tabs[name] = self.tab1 #add the widets to the dict.
self.tabControl_lower.pack(fill=tk.BOTH, expand=1)
class Week_1(Application):
def __init__(self, parent):
Application.__init__(self, parent)
week_1 = Week_1(Application)
self.pack(fill=tk.BOTH, expand=1)
self.GUI()
def GUI(self): #the function that runs all the GUI functions.
self.buttons("Week 1")
def buttons(self, name):
self.button = tk.Button(tabs[name], text="test button",
bg="salmon",)
self.button.pack()
def main():
root = tk.Tk()
root.title("class basic window")
root.config(background="LightBlue4")
app = Application(root)
root.mainloop()
if __name__ == '__main__':
main()