Python Tkinter Basics: An Introduction to Tkinter UI with the Place Layout

Tkinter is a popular library for creating user interfaces with Python. In this tutorial you will learn the usage of the Place-Layout

The Place layout allows you to specify the exact position and size of each widget using absolute coordinates. It's useful for creating complex layouts, but it requires a lot of manual positioning.

To use the place layout we have to call the place method. This method accepts following parameters:

The example below shows the usage of the place-layout with the same layout which we already implemented in the previous tutorial for the grid-layout:

import tkinter as tk

root = tk.Tk()

# Create the text input and submit button using the Place layout
text_input = tk.Entry(root)
submit_button = tk.Button(root, text="Submit")
text_input.place(x=10, y=10, width=200, height=25)
submit_button.place(x=220, y=10, width=75, height=25)

# Create the multiline label using the Place layout
label_text = tk.StringVar()
label_text.set("This is a multiline label.\nIt takes up all available width.\nDemo for place layout with Tk in Python\n(c) DEVLABS.ninja")
multiline_label = tk.Label(root, textvariable=label_text, justify="left", anchor="w", wraplength=root.winfo_screenwidth())
multiline_label.place(x=10, y=50, relwidth=1.0, relheight=1.0, width=-20, height=-60)

root.mainloop()

Place Layout with Python