- 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 do you overlap widgets/frames in Python tkinter?
There are three general ways through which we can align and position a particular widget in a Tkinter application. Let us suppose that we want to overlap two or more widgets or frames one on another, then we can use place() geometry manager. What place() geometry manager does is that it lines up the widget in rows and columns of a grid. We can certainly overlap the widget by providing the same coordinate in each.
# Import the required libraries 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 frame1= Frame(win, bg= "LightPink1") # Add an optional Label widget Label(frame1, text= "Welcome Folks!", font= ('Aerial 18 bold italic'), background= "white").pack(pady= 50) frame1.place(x= 260, y= 50) # Add a Button widget in second frame ttk.Button(frame1, text= "Button").place(x= 260, y=50) win.mainloop()
Executing the above code will display a window with a Label and a button widget inside the frame.
- Related Articles
- How to show and hide widgets in Tkinter?
- How to create transparent widgets using Tkinter?
- Showing and Hiding widgets in Tkinter?
- How to delete Tkinter widgets from a window?
- How to capture events on Tkinter child widgets?
- How to explicitly resize frames in tkinter?
- How to switch between two frames in Tkinter?
- What is the difference between the widgets of tkinter and tkinter.ttk in Python?
- Configure tkinter/ttk widgets with transparent backgrounds
- How to set the border color of certain Tkinter widgets?
- Difference between .pack and .configure for widgets in Tkinter
- How do you create a clickable Tkinter Label?
- How to add space between two widgets placed in a grid in tkinter?
- Rectangle Overlap in Python
- Changing the Default Font for all the widgets in Tkinter