The padding options padx and pady of the grid and pack methods can take a 2-tuple that represent the left/right and top/bottom padding.
Here's an example:
import tkinter as tk
class MyApp():
def __init__(self):
self.root = tk.Tk()
l1 = tk.Label(self.root, text="Hello")
l2 = tk.Label(self.root, text="World")
l1.grid(row=0, column=0, padx=(100, 10))
l2.grid(row=1, column=0, padx=(10, 100))
app = MyApp()
app.root.mainloop()
Answer from Bryan Oakley on Stack OverflowTkDocs
tkdocs.com โบ tutorial โบ grid.html
TkDocs Tutorial - The Grid Geometry Manager
The columnconfigure and rowconfigure methods accept a pad option. This increases the requested size for each widget to account for padding, but does not put extra padding around the widget, which must still be done via padx and/or pady. Let's add the extra sticky, resizing, and padding behavior ...
Videos
05:32
Tkinter window grid layout using padx pady and internal padding ...
06:51
One Sided Widget Padding - Python Tkinter GUI Tutorial #140 - YouTube
BeyondExams
11:06
Mp3 Player in Tkinter - Part 11 - Using grid manager, frames and ...
15:19
Tkinter(Python GUI) : Padding & LabelFrame - YouTube
05:59
How to pad space around the text of Python tkinter label - YouTube
Tutorialspoint
tutorialspoint.com โบ python โบ tk_grid.htm
Tkinter grid() Method
Python TechnologiesDatabasesComputer ProgrammingWeb DevelopmentJava TechnologiesComputer ScienceMobile DevelopmentBig Data & AnalyticsMicrosoft TechnologiesDevOpsLatest TechnologiesMachine LearningDigital MarketingSoftware QualityManagement Tutorials View All Categories ... This geometry manager organizes widgets in a table-like structure in the parent widget. ... ipadx, ipady โ How many pixels to pad widget, horizontally and vertically, inside widget's borders.
Python Guides
pythonguides.com โบ python-tkinter-grid
How To Create Responsive Layouts With Python Tkinter's Grid Geometry Manager?
March 19, 2025 - In this tutorial, I have explained create responsive layouts with Python Tkinterโs grid geometry manager. I discussed creating a simple label widget and added configurations like rows , columns, span widgets across multiple cells, and handling complex layouts with frames. I also discussed grid padding and some best practices and tips.
Top answer 1 of 3
312
The padding options padx and pady of the grid and pack methods can take a 2-tuple that represent the left/right and top/bottom padding.
Here's an example:
import tkinter as tk
class MyApp():
def __init__(self):
self.root = tk.Tk()
l1 = tk.Label(self.root, text="Hello")
l2 = tk.Label(self.root, text="World")
l1.grid(row=0, column=0, padx=(100, 10))
l2.grid(row=1, column=0, padx=(10, 100))
app = MyApp()
app.root.mainloop()
2 of 3
10
There are multiple ways of doing that you can use either place or grid or even the packmethod.
Sample code:
from tkinter import *
root = Tk()
l = Label(root, text="hello" )
l.pack(padx=6, pady=4) # where padx and pady represent the x and y axis respectively
# well you can also use side=LEFT inside the pack method of the label widget.
To place a widget to on basis of columns and rows , use the grid method:
but = Button(root, text="hello" )
but.grid(row=0, column=1)
Rip Tutorial
riptutorial.com โบ grid()
tkinter Tutorial => grid()
from tkinter import * root = Tk() btn_column = Button(root, text="I'm in column 3") btn_column.grid(column=3) btn_columnspan = Button(root, text="I have a columnspan of 3") btn_columnspan.grid(columnspan=3) btn_ipadx = Button(root, text="ipadx of 4") btn_ipadx.grid(ipadx=4) btn_ipady = Button(root, text="ipady of 4") btn_ipady.grid(ipady=4) btn_padx = Button(root, text="padx of 4") btn_padx.grid(padx=4) btn_pady = Button(root, text="pady of 4") btn_pady.grid(pady=4) btn_row = Button(root, text="I'm in row 2") btn_row.grid(row=2) btn_rowspan = Button(root, text="Rowspan of 2") btn_rowspan.grid(rowspan=2) btn_sticky = Button(root, text="I'm stuck to north-east") btn_sticky.grid(sticky=NE) root.mainloop() Result ยท
Profjahier
profjahier.github.io โบ html โบ NSI โบ tkinter โบ doc_tk_allegee โบ tutorial โบ grid.html
TkDocs Tutorial - The Grid Geometry Manager
Note that this extra padding is within the grid cell containing the widget. If you want to add padding around an entire row or column, the columnconfigure and rowconfigure methods accept a pad option, which will do this for you. Let's add the extra sticky, resizing, and padding behavior to ...
AskPython
askpython.com โบ home โบ tkinter tutorial โ add padding to your windows
Tkinter Tutorial - Add Padding to Your Windows - AskPython
March 28, 2022 - Now we can see that when we set padx = (100, 0) it gets somewhat aside from the center. This option will place or move our label somewhat far from the top margin of the window. We will just change the parameter and the rest of the code remains the same. ... from tkinter import * window = Tk() window.title("Padding in Tkinter") window.geometry("400x400") window.config(background = "Light Blue") label_1 = Label(window, text = "Label_1", bg = "white", fg = "black", font = ("Arial", 30)) label_1.pack(pady = 100) window.mainloop()
Narkive
comp.lang.python.narkive.com โบ LdMp1L6u โบ default-padding-for-tkinter-grid
Default padding for Tkinter grid
You have to call grid() once on every widget, so adding **padding at the end doesn't appear too bad to me: label = Label(master, text="Hello world!") widget.grid(row=3, col=1, **padding) What about a function: def grid_with_padding(widget, padx='1m', pady='1m', **kw): widget.grid(padx=padx, ...
TutorialsPoint
tutorialspoint.com โบ how-to-add-space-between-two-widgets-placed-in-a-grid-in-tkinter
How to add space between two widgets placed in a grid in tkinter?
In order to add padding, assign the values to padx and pady. #Import the required library from tkinter import * #create an instance of tkinter frame win= Tk() win.geometry("750x250") #Create some Button widgets Label(win, text= "New Line Text", font= ('Helvetica 20 bold')).grid(row=0, column=5, ...
EDUCBA
educba.com โบ home โบ software development โบ software development tutorials โบ tkinter tutorial โบ tkinter grid
Tkinter Grid | Lists of Options in Tkinter Grid with Various Examples
March 27, 2023 - Tkinter grid provides some manager classes to manage widgets such as pack(), grid() and place(). As Tkinter is a Python module for GUI, it has a grid method that needs to be imported from Tkinter. ... Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more. ... column: This option is used to put the widget in a column that is leftmost column. The default column is 0. columnspan: This option keeps track of how many columns it will take to occupy widgets, and by default, this is 1. ipadx and ipady: These two options are used for how many pixels on the interface to pad the widgets in horizontal and vertical, respectively, but it will be used in padding inside the widgets border.
Call ย +917738666252
Address ย Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
TutorialsPoint
tutorialspoint.com โบ article โบ how-to-add-padding-to-a-tkinter-widget-only-on-one-side
How to add padding to a tkinter widget only on one side?
March 25, 2026 - The grid() method provides more precise control with padx, pady, and sticky options ? from tkinter import * win = Tk() win.geometry("700x400") # Using grid with specific padding b1 = Button(win, text="Left Padding", font=('Arial', 12)) b1.grid(row=0, column=0, padx=(20, 0), pady=10) # Only left padding b2 = Button(win, text="Right Padding", font=('Arial', 12)) b2.grid(row=0, column=1, padx=(0, 20), pady=10) # Only right padding b3 = Button(win, text="Top Padding", font=('Arial', 12)) b3.grid(row=1, column=0, padx=10, pady=(20, 0)) # Only top padding b4 = Button(win, text="Bottom Padding", font=('Arial', 12)) b4.grid(row=1, column=1, padx=10, pady=(0, 20)) # Only bottom padding win.mainloop()
CodeSpeedy
codespeedy.com โบ home โบ add padding to a tkinter widget only on one side in python
Add padding to a Tkinter widget only on one side in Python - CodeSpeedy
January 22, 2022 - #import the required librearies like tkinter from tkinter import * #Now create a object of tkinter tkobj = Tk() tkobj.title("Codespeedy") #adding geometry to the window tkobj.geometry("400x400") #creating a label sa = Label(tkobj,text="Welcome to Codespeedy") sa.grid(padx=(120,0),pady=(0,0)) sa.mainloop()