Apr-03-2020, 05:43 PM
I am stumped. I can't figure out how to add multiple frames to the main window in a GUI....
I have a system that uses multiple winches to raise/lower things. I want to create a GUI that shows each winch & allows for control of them.
Since the winch frame is the same for each winch (except for the winch name, "Top Right", etc.) I created a class for the winch frame. Then I created a main app class. I can't seem to get the winches added to the main app, though....
I have a system that uses multiple winches to raise/lower things. I want to create a GUI that shows each winch & allows for control of them.
Since the winch frame is the same for each winch (except for the winch name, "Top Right", etc.) I created a class for the winch frame. Then I created a main app class. I can't seem to get the winches added to the main app, though....
from tkinter import * class WinchFrame(Frame): def __init__(self): super().__init__() # CREATE WIDGETS: self.winch_lbl = Label(text="Top Right", width=15) self.lbl_btn_up = Label(text="UP") self.btn_up = Button(text="OFF", width=12, fg='green') self.txt = Text(height=1, width=50, bg="light blue") self.lbl_btn_down = Label(text="DOWN") self.btn_down = Button(text="OFF", width=12, fg='green') # LAYOUT: self.winch_lbl.grid(row = 1, column = 0, padx=5, pady=5) self.lbl_btn_up.grid(row=1, column=1, padx=5, pady=5) self.btn_up.grid(row=1, column=2, padx=5, pady=5) self.lbl_btn_down.grid(row=3, column=1, padx=5, pady=5) self.btn_down.grid(row=3, column=2, padx=5, pady=5) self.txt.grid(row = 5, column=1, columnspan=2, padx=5, pady=5) class WinchApp(Tk): def __init__(self): self.frames = {} self.frames["Top Right"] = WinchFrame(parent=container, controller=self) self.frames["Top Right"].grid(row=0, column=0, sticky="nsew") self.Top_Right = WinchFrame() self.Bot_Right = WinchFrame() self.Top_Right.grid(row=0, column=0, sticky='nsew') self.Bot_Right.grid(row=5, column=0, sticky='nsew') if __name__ == "__main__": app = WinchApp() app.mainloopAny help you can offer will be greatly appreciated!