Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 position Tkinter widgets so that they are not stuck together?
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.
Example
#Import the required library
from tkinter import*
from tkinter import ttk
#Create an instance of tkinter frame
win= Tk()
#Set the geometry
win.geometry("750x250")
#Create an Label Widget
Label(win, text= "New Line Text", font= ('Helvetica 15
underline')).pack(pady=20)
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)
win.mainloop()
Output
Running the above code will add padding to all the buttons in the window.

Advertisements