Label#
Label is the native ttk widget that displays a line or block of
read-only text, an image, or both (ttk.Label), themed by ttkbootstrap.
This page is the complete reference for its options, methods, and styling.
Options#
Each option can be set in the constructor and changed later with configure().
Option |
Type |
Description |
|---|---|---|
|
|
Constructor keyword. An accent color, optionally with a variant. See Styling options for the available styles. |
|
|
Constructor keyword. A Bootstrap Icons glyph name (e.g.
|
|
|
Constructor keyword. The glyph size in pixels (scaled for high-DPI). |
|
|
Constructor keyword. Show only the glyph (hide the text) and pad the
widget into a square. Default |
|
|
The text shown on the label. |
|
|
A |
|
|
An image to display in place of, or beside, the text. |
|
|
How text and image are combined: |
|
|
The font for the text. |
|
|
The text color. |
|
|
The label’s background color. |
|
|
How content is positioned in extra space, e.g. |
|
|
Alignment for multi-line text: |
|
|
The width, in pixels, at which text wraps to a new line. |
|
|
The character index to underline (for a keyboard mnemonic), or |
|
|
The requested width in characters (negative sets a minimum). |
|
|
Extra space around the content, in pixels (a single value, or per-side). |
|
|
The border style, e.g. |
|
|
The width of the border, in pixels. |
|
|
|
|
|
The mouse cursor over the label (see Cursors). |
|
|
Whether the label accepts keyboard focus during traversal. |
Styling options#
This section is for changing how the label looks. Define a style with
style.configure(...) (and style.map(...) for per-state colors), then
apply it with Label(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.
|
ttk style name |
|---|---|
|
|
|
|
Layout (elements)#
The widget is drawn from these nested parts. Each is an element you can target by name in a custom layout:
Label.border
Label.padding
Label.label
Configurable style options#
Options you can set with style.configure(...) / style.map(...):
anchor, background, bordercolor, borderwidth, compound, darkcolor, embossed, font, foreground, image, justify, lightcolor, padding, relief, shiftrelief, space, stipple, text, underline, width, wraplength
Supported states#
The states you can target with style.map(...) to vary appearance by interaction:
disabled
Hand-styling example#
import ttkbootstrap as ttk
app = ttk.App()
style = app.style
style.configure("my.TLabel", background="#3498db", foreground="white")
ttk.Label(app, text="Custom", style="my.TLabel").pack(padx=8, pady=8)
app.mainloop()
See also#
Label catalog page — usage, screenshots, and examples.
Tk ttk::label manual page — the canonical upstream reference (Tcl 8.6).