- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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 a margin to a tkinter window?
The margin of a tkinter window can be controlled by specifying the value of fill, expand and padding. Another way to set the margin of a tkinter window is to use grid(**options) Geometry Manager. Grid pack manager allows us to add the margin by specifying the value of row and column property.
# Import the required library from tkinter import * from tkinter import ttk # Create an instance of tkinter frame win= Tk() # Set the size of the Tkinter window win.geometry("700x350") # Add a frame to set the size of the window frame= Frame(win, relief= 'sunken', bg= "black") frame.pack(fill= BOTH, expand= True, padx= 10, pady=20) # Add a label widget label= Label(frame, text= "Welcome to Tutorialspoint", font=('Helvetica 15 bold'), bg= "white") label.pack(pady= 30) win.mainloop()
Executing the above code will display a Label Text lying inside a frame. The margin of the frame is expandable and resizable.
- How to dynamically add/remove/update labels in a Tkinter window?
- How to set a Tkinter window to a constant size?
- How to make a Tkinter window not resizable?
- How to delete Tkinter widgets from a window?
- How to Set a Tkinter Window with a Constant Size?
- How to close a Tkinter window by pressing a Button?
- How to make a Tkinter window jump to the front?
- How to bind the Enter key to a tkinter window?
- How to specify where a Tkinter window should open?
- Tkinter-How to get the current date to display in a tkinter window?
- How to add a column to a Tkinter TreeView widget?
- How do I close a tkinter window?
- How to center a window on the screen in Tkinter?
- How to put a Toplevel window in front of the main window in Tkinter?
- How to add text inside a Tkinter Canvas?