Labelframe#

Labelframe is the native ttk frame with a caption drawn into its border (ttk.Labelframe), themed by ttkbootstrap. This page is the complete reference for its options, methods, and styling. ttk.LabelFrame is an accepted alias for the same class, matching tkinter.ttk.

Options#

Each option can be set in the constructor and changed later with configure().

Option

Type

Description

bootstyle

str

Constructor keyword. An accent color, optionally with a variant. See Styling options for the available styles.

text

str

The caption drawn into the border.

labelwidget

Widget

A widget to use as the label in place of text.

labelanchor

str

Where the caption sits on the border: "nw", "n", "ne", "en", "e", and so on.

underline

int

The character index in text to underline (for a mnemonic), or -1.

padding

int | tuple

Extra space inside the frame’s border, in pixels (a single value, or per-side).

borderwidth

int

The width of the frame’s border, in pixels.

relief

str

The border decoration: "flat", "raised", "sunken", "solid", "ridge", or "groove".

width

int

The requested width in pixels. Ignored unless geometry propagation is turned off.

height

int

The requested height in pixels. Ignored unless geometry propagation is turned off.

cursor

str

The mouse cursor over the frame (see Cursors).

takefocus

bool

Whether the frame accepts keyboard focus during traversal.

Styling options#

This section is for changing how the labelframe looks. Define a style with style.configure(...) (and style.map(...) for per-state colors), then apply it with Labelframe(style=...).

Bootstyle mapping#

Any of the accent colors – primary, secondary, success, info, warning, danger, light, dark – substitutes for primary below. neutral does not apply to this family.

bootstyle

ttk style name

primary

primary.TLabelframe

Layout (elements)#

The widget is drawn from these nested parts. Each is an element you can target by name in a custom layout:

Labelframe.border

Configurable style options#

Options you can set with style.configure(...) / style.map(...):

bordercolor, borderwidth, darkcolor, lightcolor, relief

Supported states#

This style declares no style.map(...) overrides; any state-dependent appearance is drawn from its image elements.

Hand-styling example#

import ttkbootstrap as ttk

app = ttk.App()
style = app.style

style.configure("my.TLabelframe", background="#3498db", foreground="white")
ttk.Labelframe(app, text="Custom", style="my.TLabelframe").pack(padx=8, pady=8)

app.mainloop()

Shared capabilities#

Labelframe also has the methods every widget inherits — configuration, placement, event binding, lifecycle, focus, and introspection — plus the ttk state methods state / instate / identify. These are documented under Capabilities.

See also#