# How to add padding to a tkinter widget only on one side?

PythonTkinterGUI-Programming

Let us suppose that we want to add padding on one side (either top/bottom or left/right) of a particular widget. We can achieve this in Tkinter by using its pack() and grid() methods.

In pack() method, we have to define the value for “padx” and “pady”. On the other hand, the grid method requires only two tuples, i.e., x and y for adding padding around either of X-axis or Y-axis.

## Example

#import the required library
from tkinter import *

#Create an instance of window or frame
win= Tk()
win.geometry("700x400")

#Create two buttons

b1= Button(win, text= "Button1", font=('Poppins bold', 15))

b2= Button(win, text= "Button2", font=('Poppins bold', 15))
win.mainloop()