Modern Tkinter
Widget Pictures

Button Widgets

The widget roundup provides you with a quick and easy reference to the most important features and options for each Tk widget.

Button

Widget Essentials

When to use: When you want your user to invoke some operation (submit a dialog, calculate a result, save a file, etc.)
Python:b = ttk.Button(parent, text="Okay", command=submitForm)
Tcl:ttk::button .b -text "Okay" -command "submitForm"
Ruby:b = Tk::Tile::Button.new(parent) {text "Okay"; command "submitForm"}
Perl:my $b = parent->new_ttk__button(-text => "Okay", -command => sub {submitForm();});
Reference:(at www.tcl.tk)

Common Options

text The label to be shown in the button.
command The script to invoke when the button is pressed.
default If "active", this is a "default" button for the window, i.e. the one that will be invoked if the user presses Return. Regular state is "normal" (You need to set up the event binding separately.)
image,
compound
Specify a Tk Image object (not the path to an image file) instead of the text label. If compound is center, top, bottom, left, or right, display the text and the image.

How do I...

Press the button from my program? Use the "invoke" method. Useful so you don't need to repeat the button's command script in multiple places in your program.
Disable the button? Use the "state disabled" method.
You can reenable this with "state !disabled".
Check with "instate disabled" (returns 1 if disabled, else 0).