Change Geometry of TTK Frame?


This Content is from Stack Overflow. Question asked by Steelhard2

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(‘100×100’) does nothing.

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

        # 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 :)

    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):
        #### Irrelevant code after this

    def changewindow(self):

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.


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?