I'm currently working on a Python Tkinter code which is getting longer and longer. I wanted to implement using multiple classes for some of the frames in my GUI.
Below code is a sample of what I am trying to do. Basically making a class which has a frame, and the frame is using another class as a parent.
But when I run the code, I get this error "'MainProgram' object has no attribute 'FirstFrame'"
Any solutions? I tried searching but I wasn't successful on finding something like this.
import tkinter as tk
from tkinter import ttk
class MainProgram():
def __init__(self):
self.mainwin = tk.Tk()
self.FirstFrame()
class FirstFrame():
def __init__(self):
self.firstframe = ttk.LabelFrame(self.MainProgram.mainwin, text="hi")
self.firstframe.grid(column=0, row=0)
if __name__ == "__main__":
main = MainProgram()
main.mainwin.mainloop