1button(n)                    Tk Built-In Commands                    button(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       button - Create and manipulate button widgets
9

SYNOPSIS

11       button pathName ?options?
12

STANDARD OPTIONS

14       -activebackground     -font                -relief
15       -activeforeground     -foreground          -repeatdelay
16       -anchor               -highlightbackground -repeatinterval
17       -background           -highlightcolor      -takefocus
18       -bitmap               -highlightthickness  -text
19       -borderwidth          -image               -textvariable
20       -compound             -justify             -underline
21       -cursor               -padx                -wraplength
22       -disabledforeground   -pady
23
24       See the options manual entry for details on the standard options.
25

WIDGET-SPECIFIC OPTIONS

27       [-command command]  Specifies  a Tcl command to associate with the but‐
28       ton.  This command is typically invoked when mouse button 1 is released
29       over  the  button  window.   [-default default]  Specifies one of three │
30       states for the default ring: normal, active, or  disabled.   In  active │
31       state,  the button is drawn with the platform specific appearance for a │
32       default button.  In normal state, the button is drawn with the platform │
33       specific  appearance  for a non-default button, leaving enough space to │
34       draw the default button appearance.  The normal and active states  will │
35       result  in  buttons of the same size.  In disabled state, the button is │
36       drawn with the non-default button appearance without leaving space  for │
37       the  default  appearance.   The  disabled state may result in a smaller │
38       button than the active state.   [-height height]  Specifies  a  desired
39       height for the button.  If an image or bitmap is being displayed in the
40       button then the value is in screen units (i.e. any of the forms accept‐
41       able to Tk_GetPixels); for text it is in lines of text.  If this option
42       isn't specified, the button's desired height is computed from the  size
43       of  the  image  or  bitmap  or  text  being displayed in it.  [-overre‐ 
44       lief overRelief] Specifies an alternative relief for the button, to  be │
45       used when the mouse cursor is over the widget.  This option can be used │
46       to make  toolbar  buttons,  by  configuring  -relief  flat  -overrelief 
47       raised.   If  the  value  of  this  option is the empty string, then no │
48       alternative relief is used when the mouse cursor is  over  the  button. │
49       The empty string is the default value.  [-state state] Specifies one of
50       three states for the button:  normal, active, or disabled.   In  normal
51       state  the  button  is  displayed  using  the foreground and background
52       options.  The active state is typically used when the pointer  is  over
53       the  button.  In active state the button is displayed using the active‐
54       Foreground and activeBackground options.  Disabled state means that the
55       button  should  be  insensitive:   the  default bindings will refuse to
56       activate the widget and will ignore  mouse  button  presses.   In  this
57       state  the  disabledForeground and background options determine how the
58       button is displayed.  [-width width] Specifies a desired width for  the
59       button.   If  an  image or bitmap is being displayed in the button then
60       the value is in screen units (i.e.  any  of  the  forms  acceptable  to
61       Tk_GetPixels);  for  text  it  is  in characters.  If this option isn't
62       specified, the button's desired width is computed from the size of  the
63       image or bitmap or text being displayed in it.
64_________________________________________________________________
65
66

DESCRIPTION

68       The  button  command  creates a new window (given by the pathName argu‐
69       ment) and makes it into a button widget.  Additional options, described
70       above,  may  be specified on the command line or in the option database
71       to configure aspects of the button such as its colors, font, text,  and
72       initial  relief.  The button command returns its pathName argument.  At
73       the time this command is invoked, there must not exist a  window  named
74       pathName, but pathName's parent must exist.
75
76       A  button  is a widget that displays a textual string, bitmap or image.
77       If text is displayed, it must all be in  a  single  font,  but  it  can
78       occupy  multiple  lines  on  the  screen (if it contains newlines or if
79       wrapping occurs because of the wrapLength option) and one of the  char‐
80       acters may optionally be underlined using the underline option.  It can
81       display itself in either of three  different  ways,  according  to  the
82       state  option; it can be made to appear raised, sunken, or flat; and it
83       can be made to flash.  When a user  invokes  the  button  (by  pressing
84       mouse  button  1 with the cursor over the button), then the Tcl command
85       specified in the -command option is invoked.
86
87

WIDGET COMMAND

89       The button command creates a new Tcl command whose  name  is  pathName.
90       This  command  may  be used to invoke various operations on the widget.
91       It has the following general form:
92              pathName option ?arg arg ...?
93       Option and the args determine the exact behavior of the  command.   The
94       following commands are possible for button widgets:
95
96       pathName cget option
97              Returns  the  current value of the configuration option given by
98              option.  Option may have any of the values accepted by the  but‐
99              ton command.
100
101       pathName configure ?option? ?value option value ...?
102              Query  or modify the configuration options of the widget.  If no
103              option is specified, returns a list describing all of the avail‐
104              able  options for pathName (see Tk_ConfigureInfo for information
105              on the format of this list).  If option  is  specified  with  no
106              value,  then the command returns a list describing the one named
107              option (this list will be identical to the corresponding sublist
108              of  the  value  returned  if no option is specified).  If one or
109              more option-value pairs are specified, then the command modifies
110              the  given widget option(s) to have the given value(s);  in this
111              case the command returns an empty string.  Option may  have  any
112              of the values accepted by the button command.
113
114       pathName flash
115              Flash the button.  This is accomplished by redisplaying the but‐
116              ton several times, alternating between active and normal colors.
117              At  the  end  of  the  flash the button is left in the same nor‐
118              mal/active state as when the command was invoked.  This  command
119              is ignored if the button's state is disabled.
120
121       pathName invoke
122              Invoke  the  Tcl command associated with the button, if there is
123              one.  The return value is the return value from the Tcl command,
124              or  an  empty  string if there is no command associated with the
125              button.  This command is ignored if the button's state  is  dis‐
126              abled.
127
128

DEFAULT BINDINGS

130       Tk  automatically  creates  class  bindings  for buttons that give them
131       default behavior:
132
133       [1]    A button activates whenever the mouse passes over it and deacti‐
134              vates whenever the mouse leaves the button.  Under Windows, this │
135              binding is only active when mouse button 1 has been pressed over │
136              the button.
137
138       [2]    A  button's  relief is changed to sunken whenever mouse button 1
139              is pressed over the button, and the relief is  restored  to  its
140              original value when button 1 is later released.
141
142       [3]    If  mouse  button  1 is pressed over a button and later released
143              over the button, the button is invoked.  However, if  the  mouse
144              is  not over the button when button 1 is released, then no invo‐
145              cation occurs.
146
147       [4]    When a button has the input focus, the space key causes the but‐
148              ton to be invoked.
149
150       If the button's state is disabled then none of the above actions occur:
151       the button is completely non-responsive.
152
153       The behavior of buttons can be changed by  defining  new  bindings  for
154       individual widgets or by redefining the class bindings.
155
156

KEYWORDS

158       button, widget
159
160
161
162Tk                                    4.4                            button(n)
Impressum