Change Geometry of TTK Frame?

Viewed 20

So I have an App/TTK.Frame class, and I wish to change it once my program starts so that I can change the way it looks and turn it into a "Status: xxxx" kind of thing at the top of the screen.

However, I can't seem to be able to edit the geometry because this is a ttk.frame class and thus doing root.geometry('100x100') does nothing.

class App(ttk.Frame):
    def __init__(self, parent):
        ttk.Frame.__init__(self)

        # Make the app responsive
        for index in [0, 1, 2]:
            self.columnconfigure(index=index, weight=1)
            self.rowconfigure(index=index, weight=1)


        # Create control variables
        self.barbs = tk.BooleanVar(value=True)
        self.buildings = tk.BooleanVar(value=True)
        self.troops = tk.BooleanVar(value=True)
        self.exploration = tk.BooleanVar(value=True)
        self.gather = tk.StringVar()

        # Create widgets :)
        self.setup_widgets()

    def setup_widgets(self):
        #### Irrelevant code before this
        self.button = ttk.Button(self.widgets_frame, text="Button", command=self.startbtn2)
        self.button.grid(row=2, column=0, padx=0, pady=0, sticky="nsew")
    
    def startbtn2(self):
        self.changewindow()
        #### Irrelevant code after this

    def changewindow(self):
        self.widgets_frame.destroy()
        self.check_frame.destroy()
        root.geometry('100x100')

Also thought about doing it a different way, instead of destroying all the widgets and changing the geometry of the current window, I can just open a new one once the button is clicked / startbtn2 function starts, however, I need to call root.lift() on a loop so that the window always stays at the top of all other windows, and I think the only way to do so is if that's the main window, not a newly created one.

0 Answers
Related