Chapter 11. The Button Widget

Table of Contents
When to use the Button Widget
Patterns
Methods
Helpers
Options

The Button widget is a standard Tkinter widget used to implement various kinds of buttons. Buttons can contain text or images, and you can associate a Python function or method with each button. When the button is pressed, Tkinter automatically calls that function or method.

The button can only display text in a single font, but the text may span more than one line. In addition, one of the characters can be underlined, for example to mark a keyboard shortcut. By default, the Tab key can be used to move to a button widget.

When to use the Button Widget

Simply put, button widgets are used to let the user say "do this now!," where this is either given by the text on the button, or implied by the icon displayed in the button. Buttons are typically used in toolbars, in application windows, and to accept or dismiss data entered into a dialog box.

For buttons suitable for data entry, see the Checkbutton and Radiobutton widgets.