[Python] tkinter layout problem, pack does not place the elements as expected

Discussão em 'Python' iniciado por Stack, Abril 27, 2025.

  1. Stack

    Stack Membro Participativo

    I want to have three elements. The first two aligned left and the third below spanning the remaining space in x and y.

    This code however does not realized that import ttkbootstrap as tb

    class App(tb.Window):
    def __init__(self):
    # Initialize window with superhero theme
    super().__init__(themename="superhero")

    # Configure the root window
    self.title('test layout')
    self.geometry('800x600')

    tb.Button(self, text='first').pack(padx=10, pady=10, side = tb.LEFT)
    tb.Button(self, text='second').pack(padx=10, pady=10, side = tb.LEFT)
    tb.Label(self, text="filled", borderwidth=2, relief="groove").pack(expand=True, side=tb.BOTTOM)


    if __name__ == "__main__":
    app = App()
    app.mainloop()


    This looks like [​IMG]

    What is the typical solution?

    Continue reading...

Compartilhe esta Página