- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- 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 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.
#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()
Running the above code will add padding to all the buttons in the window.
- Related Articles
- How to create transparent widgets using Tkinter?
- How to delete Tkinter widgets from a window?
- How to show and hide widgets in Tkinter?
- How to capture events on Tkinter child widgets?
- How to set the border color of certain Tkinter widgets?
- Showing and Hiding widgets in Tkinter?
- How do you overlap widgets/frames in Python tkinter?
- Configure tkinter/ttk widgets with transparent backgrounds
- Adding a scrollbar to a group of widgets in Tkinter
- How to add space between two widgets placed in a grid in tkinter?
- How to set padding of all widgets inside a window or frame in Tkinter?
- Metals which are so soft that they can be cut with a knife are _________, ___________.
- Difference between .pack and .configure for widgets in Tkinter
- Changing the Default Font for all the widgets in Tkinter
- What must be added to the numbers 6,10,14 and 22 so that they are in proportion?