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

bootstyle

str

Constructor keyword. The style — an accent color (primary, …, dark, neutral) optionally with a variant (outline, link, ghost). See Styling options.

icon

str

Constructor keyword. A Bootstrap Icons glyph name (e.g. "gear-fill") shown on the button; theme-aware — it follows the foreground color and states. See the Icons guide.

icon_size

int

Constructor keyword. The glyph size in pixels (scaled for high-DPI).

icon_only

bool

Constructor keyword. Show only the glyph (hide the text) and pad the button into a square. Default False.

text

str

The label shown on the button.

textvariable

Variable

A StringVar whose value is shown as the label and tracked live.

command

callable

The function called when the button is pressed.

image

PhotoImage

An image to display in place of, or beside, the text.

compound

str

How text and image are combined: "none", "left", "right", "top", "bottom", or "center".

underline

int

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

width

int

The requested width in characters (negative sets a minimum).

padding

int | tuple

Extra space around the label, in pixels (a single value, or per-side).

default

str

The default-button ring: "normal", "active", or "disabled".

state

str

"normal" or "disabled". For finer control use the state method (see Capabilities).

cursor

str

The mouse cursor over the button (see Cursors).

takefocus

bool

Whether the button accepts keyboard focus during traversal.

Methods#

invoke()

Invoke the button — run its command and 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.

bootstyle

ttk style name

primary

primary.TButton

primary ghost

primary.Ghost.TButton

primary link

primary.Link.TButton

primary outline

primary.Outline.TButton

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.

bootstyle

ttk style name

primary toolbutton

primary.Toolbutton

primary outline toolbutton

primary.Outline.Toolbutton

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#