How do I group widgets with a LabelFrame in tkinter?
A LabelFrame is a container with a border and a caption. The part that trips people is not the widget itself but the parenting: anything that should sit inside it must be created with the LabelFrame as its parent, not the window.
import tkinter as tk
from tkinter import ttk
root = tk.Tk()
box = ttk.LabelFrame(root, text="Delivery")
box.pack(fill="x", padx=10, pady=10)
# the parent is the box, not root — this is the whole trick
ttk.Radiobutton(box, text="Standard", value="std").pack(anchor="w")
ttk.Radiobutton(box, text="Express", value="exp").pack(anchor="w")
root.mainloop() Why widgets land outside the box
Passing root as the parent puts the widget in the window and leaves the LabelFrame empty, which draws as a thin caption with nothing under it. The parent argument is what decides containment — position on screen has nothing to do with it, so a widget can look like it is inside while belonging to the window.
A LabelFrame with no children collapses to almost nothing, so an unexpectedly small box is usually this mistake rather than a sizing problem.
The caption and where it sits
text sets the caption, and it can be changed later like any option. On the themed widget, labelanchor moves it around the border — it defaults to the top left, and values like n or ne shift it along the top edge.
box = ttk.LabelFrame(root, text="Delivery", labelanchor="n")
box.configure(text="Shipping")Classic or themed
tk.LabelFrame takes the classic options, so it can have a background colour and a relief of its own. ttk.LabelFrame follows the active theme instead, which is what you want under ttkbootstrap, but it will ignore a bg= you try to set on it directly.
When a plain Frame is better
Use a Frame when the grouping is for layout only and the user does not need to see it — most windows are full of invisible frames holding rows together. Use a LabelFrame when the group is a real category worth naming on screen.
Doing it without the lookup
Drop a Labelframe on the canvas and drag widgets into it; the outline highlights when the widget will be captured, and the export writes each child with the frame as its parent. The caption is a field in the inspector.
Lay the window out visually and read the generated Python as you go.
Open the tkinter designer →