- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to add space between two widgets placed in a grid in tkinter?
Let us assume that we are creating a tkinter application where two or more widgets are placed using a grid property. We have to add some space between the widgets in order to style their appearance. To provide space in the widgets, we can use padding property, as padding adds space to the outermost part of the widget. In order to add padding, assign the values to padx and pady.
Example
#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, padx= 25, pady= 25) Button(win, text= "Button 1").grid(row=0, column=1, padx= 50, pady= 80) Button(win, text= "Button 2").grid(row=0, column=2, padx= 25, pady =36) win.mainloop()
Output
- Related Articles
- How to show and hide widgets in Tkinter?
- How to delete Tkinter widgets from a window?
- Difference between .pack and .configure for widgets in Tkinter
- How to create transparent widgets using Tkinter?
- Adding a scrollbar to a group of widgets in Tkinter
- Showing and Hiding widgets in Tkinter?
- How to add space between elements?
- How to capture events on Tkinter child widgets?
- How do you overlap widgets/frames in Python tkinter?
- How to add two strings with a space in first string in JavaScript?
- How to add space between characters in IText using FabricJS?
- How to add space between characters in Text using FabricJS?
- How to update information in the grid in Tkinter?
- How to set padding of all widgets inside a window or frame in Tkinter?
- How to horizontally center a widget using a grid() in Tkinter?

Advertisements