close

How to add space between two widgets placed in grid in tkinter ~ python?

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How to add space between two widgets placed in grid in tkinter ~ python in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

How to add space between two widgets placed in grid in tkinter ~ python?

  1. How to add space between two widgets placed in grid in tkinter ~ python?

    I think that you already got the answer, but I will share my solution to have space between two lines which works for me well.

  2. add space between two widgets placed in grid in tkinter ~ python

    I think that you already got the answer, but I will share my solution to have space between two lines which works for me well.

Method 1

When you pack the widget you can use

self.a_button = Button(root, text="A Button") 
self.a_button.grid(row=0, column=1, padx=10, pady=10)

Using padx and pady you can add padding to the outer side of the button and alternatively if you want to increase the size of the button you can add inner padding using ipadx and ipady.

Method 2

I think that you already got the answer, but I will share my solution to have space between two lines which works for me well.

spacer1 = tk.Label(win, text="")
spacer1.grid(row=4, column=0)

you can have this between to labels or entries as empty space at location row= 4, column= 0. You may want to modify the size of the space by adding pad sizes to spacer1.grid(row=4, column=0, padx= 10, pady= 10) or modify the label like spacer1 = tk.Label(win, text="", font=('Times New Roman, 40)) which ever works for you. The out put will be the space between two rows(3 & 5). I hope the solution helps you.

Summery

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read