Place() lets you position a widget either with absolute x,y coordinates, or relative to another widget. Positioning Widgets With Place Layout Manager In this example, three labels are positioned side by side in relation to each other, and are padded to separate them: import tkinter as tk root = tk.Tk() test = tk.Label(root, text="red", bg="red", fg="white") test.pack(padx=5, pady=15, side=tk.LEFT) test = tk.Label(root, text="green", bg="green", fg="white") test.pack(padx=5, pady=20, side=tk.LEFT) test = tk.Label(root, text="purple", bg="purple", fg="white") test.pack(padx=5, pady=20, side=tk.LEFT) root.mainloop() import tkinter as tk root = tk.Tk() test = tk.Label(root, text="Red", bg="red", fg="white") test.pack(side=tk.BOTTOM) test = tk.Label(root, text="Green", bg="green", fg="white") test.pack(side=tk.BOTTOM) test = tk.Label(root, text="Purple", bg="purple", fg="white") test.pack(side=tk.BOTTOM) tk.mainloop() In this example, three labels (widgets that contain text or images) are positioned vertically in relation to each other, and are not padded.
Pads viewer grid off how to#
For simple positioning of widgets vertically or horizontally in relation to each other, pack() is the layout manager of choice.įor more information about pack() and its options, refer to: How To Position Buttons in Tkinter With Pack Vertical Positioning with Pack However, pack() is limited in precision compared to place() and grid() which feature absolute positioning. Instead of declaring the precise location of a widget, pack() declares the positioning of widgets in relation to each other. Pack is the easiest layout manager to use with Tkinter. Positioning Widgets With the Pack Layout Manager
Pads viewer grid off code#
Watch the video, which introduces the pack, place and grid code snippets below Important : pack(), place(), and grid() should not be combined in the same master window.