button \- Create and manipulate button widgets
button pathName ?options?
activeBackground bitmap font relief activeForeground borderWidth foreground text anchor cursor padX textVariable background disabledForeground padY
See section options, for more information.
:command
Name="command" Class="
Command"
Specifies a Tcl command to associate with the button. This command is typically invoked when mouse button 1 is released over the button window.
:height
Name="height" Class="
Height"
Specifies a desired height for the button. If a bitmap is being displayed in the button then the value is in screen units (i.e. any of the forms acceptable to Tk_GetPixels); for text it is in lines of text. If this option isn't specified, the button's desired height is computed from the size of the bitmap or text being displayed in it.
:state
Name="state" Class="
State"
Specifies one of three states for the button: normal, active, or disabled. In normal state the button is displayed using the foreground and background options. The active state is typically used when the pointer is over the button. In active state the button is displayed using the activeForeground and activeBackground options. Disabled state means that the button is insensitive: it doesn't activate and doesn't respond to mouse button presses. In this state the disabledForeground and background options determine how the button is displayed.
:width
Name="width" Class="
Width"
Specifies a desired width for the button. If a bitmap is being displayed in the button then the value is in screen units (i.e. any of the forms acceptable to Tk_GetPixels); for text it is in characters. If this option isn't specified, the button's desired width is computed from the size of the bitmap or text being displayed in it.
The button command creates a new window (given by the pathName argument) and makes it into a button widget. Additional options, described above, may be specified on the command line or in the option database to configure aspects of the button such as its colors, font, text, and initial relief. The button command returns its pathName argument. At the time this command is invoked, there must not exist a window named pathName, but pathName's parent must exist.
A button is a widget that displays a textual string or bitmap. It can display itself in either of three different ways, according to the state option; it can be made to appear raised, sunken, or flat; and it can be made to flash. When a user invokes the button (by pressing mouse button 1 with the cursor over the button), then the Tcl command specified in the :command option is invoked.
The button command creates a new Tcl command whose name is pathName. This command may be used to invoke various operations on the widget. It has the following general form:
pathName option ?arg arg ...?
Option and the args determine the exact behavior of the command. The following commands are possible for button widgets:
Tk automatically creates class bindings for buttons that give them the following default behavior:
If the button's state is disabled then none of the above actions occur: the button is completely non-responsive.
The behavior of buttons can be changed by defining new bindings for individual widgets or by redefining the class bindings.
button, widget
Go to the first, previous, next, last section, table of contents.