place() geometry manager is the least used geometry manager in Tkinter, it allows you to position widgets using the
(x,y) coordinate system.
The most useful options for
- Absolute positioning (
x = Nand
y = N)
- Relative positioning (
Other options that are commonly used with
from tkinter import * root = Tk() # Absolute positioning Button(root, text = "Absolute").place(x = 60, y = 20) # x - horizontal placement; y - vertical placement # Relative positioning Button(root, text = "Relative").place(relx = 0.8, rely = 0.3, relwidth = 0.3, width = 40, anchor = NE) root.mainloop()
Run the code in the terminal and you will get something like shown below:
Try resizing the window and you will see that the button “Absolute” does not move during resizing while the “Relative” button changes its coordinates and size to accommodate the new size of the root window.
For a complete
place() reference use the help command in terminal:
>>> import tkinter >>> help(tkinter.Place)
place() manager can be used with any geometry manager within the same frame.
place() geometry manager is not usually used.
pack() geometry manager is usually used for side-wise / top-down widget placement.
grid() geometry manager is usually used for complex layouts.