Set size for a frame

Question:

What is the point of setting a size for a frame on Tkinter, if it will resize every time I add a new widget.

`

frame1 = Frame(self.MainWindow,width=600,height=100,bg='Blue')
        frame1.grid(row=0,column=0)
        #frame1.pack()

        #Title

        self.mainTitle = Label(frame1,text='Welcome')
        self.mainTitle.grid(row=0,column=1,padx=60,pady=5)

        #Back button

        backButton = Button(frame1,text='Home',command=None)
        backButton.grid(row=0,column=0,padx=60,pady=5)

        nexButton = Button(frame1,text='Next',command=None)
        nexButton.grid(row=0,column=2,padx=60,pady=5)

`

I do not know if there is any way to work with frames like divs in html.

Asked By: Eduardo A

||

Answers:

What is the point of setting a size for a frame on Tkinter, if it will resize every time I add a new widget.

The vast majority of the time there is no advantage for setting a size on a frame. It can be useful in those cases when you have very strict requirements, but more often than not it’s better to let tkinter size frames for you. It’s very good at making responsive GUIs when you let it do all of the work of calculating sizes.

Answered By: Bryan Oakley
Categories: questions Tags: , , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.