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

# 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) 260, y= 50)

# Add a Button widget in second frame
ttk.Button(frame1, text= "Button").place(x= 260, y=50)


Executing the above code will display a window with a Label and a button widget inside the frame.

Updated on 08-Jun-2021 09:39:47