How to position Tkinter widgets so that they are not stuck together?

TkinterServer Side ProgrammingProgramming

In a tkinter GUI skeleton, we can add any number of widgets to make it more functional and operational. However, sometimes, it seems difficult to resize and position the widgets so that they don’t stick together and are non-variable in size. We can add padding using the widget pack manager to make every widget stand as one separate entity.


#Import the required library
from tkinter import*
from tkinter import ttk

#Create an instance of tkinter frame
win= Tk()

#Set the geometry

#Create an Label Widget
Label(win, text= "New Line Text", font= ('Helvetica 15
left=Button(win, text="Button1", font= ('Helvetica 15 bold'))
left.pack(padx= 10,pady=10)
right= Button(win, text= "Button2",font=('Helvetica 15 bold'))
right.pack(padx= 10, pady= 10)
center= Button(win, text= "Button3", font= ('Helvetica 15 bold'))
center.pack(padx=10, pady=10)


Running the above code will add padding to all the buttons in the window.

Updated on 16-Apr-2021 06:54:51