Button#
Button is the native ttk push button (ttk.Button), themed by
ttkbootstrap — a clickable trigger that runs its command when pressed. 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. The style — an accent color ( |
|
|
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
button into a square. Default |
|
|
The label shown on the button. |
|
|
A |
|
|
The function called when the button is pressed. |
|
|
An image to display in place of, or beside, the text. |
|
|
How text and image are combined: |
|
|
The character index to underline (for a keyboard mnemonic), or |
|
|
The requested width in characters (negative sets a minimum). |
|
|
Extra space around the label, in pixels (a single value, or per-side). |
|
|
The default-button ring: |
|
|
|
|
|
The mouse cursor over the button (see Cursors). |
|
|
Whether the button accepts keyboard focus during traversal. |
Methods#
- invoke()
Invoke the button — run its
commandand return whatever that returns.- Returns:
the command’s return value.
Styling options#
This section is for changing how the button looks. Define a style with
style.configure(...) (and style.map(...) for per-state colors), then
apply it with Button(style=...). The tables below list the style names you
can start from, the parts of the button you can target, the options each part
accepts, and the states they respond to.
Bootstyle mapping#
Any of the accent colors – primary, secondary, success, info, warning, danger, light, dark – substitutes for primary below. neutral also applies here.
|
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:
Button.border
Button.focus
Button.padding
Button.label
Configurable style options#
Options you can set with style.configure(...) / style.map(...):
anchor, background, bordercolor, borderwidth, compound, darkcolor, embossed, focuscolor, focussolid, focusthickness, 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, disabled, hover, pressed
Hand-styling example#
import ttkbootstrap as ttk
app = ttk.App()
style = app.style
style.configure("my.TButton", background="#3498db", foreground="white")
ttk.Button(app, text="Custom", style="my.TButton").pack(padx=8, pady=8)
app.mainloop()
Toolbutton variant#
Styled for a toolbar — and used for segmented
Checkbutton and Radiobutton groups — a button uses these Toolbutton style
names instead:
Bootstyle mapping#
Any of the accent colors – primary, secondary, success, info, warning, danger, light, dark – substitutes for primary below. neutral also applies here.
|
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:
Toolbutton.border
Toolbutton.focus
Toolbutton.padding
Toolbutton.label
Configurable style options#
Options you can set with style.configure(...) / style.map(...):
anchor, background, bordercolor, borderwidth, compound, darkcolor, embossed, focuscolor, focussolid, focusthickness, 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, disabled, selected
Hand-styling example#
import ttkbootstrap as ttk
app = ttk.App()
style = app.style
style.configure("my.Toolbutton", background="#3498db", foreground="white")
ttk.Button(app, text="Custom", style="my.Toolbutton").pack(padx=8, pady=8)
app.mainloop()
Shared capabilities#
Button 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#
Button catalog page — usage, screenshots, and examples.
Tk ttk::button manual page — the canonical upstream reference (Tcl 8.6).