Home > OS >  Set size for a frame
Set size for a frame

Time:01-03

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.

CodePudding user response:

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.

  • Related