1Button(3)             User Contributed Perl Documentation            Button(3)
2
3
4

NAME

6       Tk::Button - Create and manipulate Button widgets
7

SYNOPSIS

9       $button = $parent->Button(?options?);
10

STANDARD OPTIONS

12       -activebackground -activeforeground -anchor -background -bitmap -bor‐
13       derwidth -compound -cursor -disabledforeground -font -foreground -high‐
14       lightbackground -highlightcolor -highlightthickness -image -justify
15       -padx -pady -relief -repeatdelay -repeatinterval -takefocus -text
16       -textvariable -underline -wraplength
17
18       See Tk::options for details of the standard options.
19

WIDGET-SPECIFIC OPTIONS

21       Name:     command
22       Class:    Command
23       Switch:   -command
24           Specifies a Perl/Tk callback to associate with the button.  This
25           command is typically invoked when mouse button 1 is released over
26           the button window.
27
28       Command-Line Name: -compound
29       Database Name:  compound
30       Database Class: Compound
31           Specifies whether the button should display both an image and text,
32           and if so, where the image should be placed relative to the text.
33           Valid values for this option are bottom, center, left, none, right
34           and top.  The default value is none, meaning that the button will
35           display either an image or text, depending on the values of the
36           -image and -bitmap options.
37
38       Name:     default
39       Class:    Default
40       Switch:   -default
41           Specifies one of three states for the default ring: normal, active,
42           or disabled.  In active state, the button is drawn with the plat‐
43           form specific appearance for a default button.  In normal state,
44           the button is drawn with the platform specific appearance for a
45           non-default button, leaving enough space to draw the default button
46           appearance.  The normal and active states will result in buttons of
47           the same size.  In disabled state, the button is drawn with the
48           non-default button appearance without leaving space for the default
49           appearance.  The disabled state may result in a smaller button than
50           the active state.  ring.
51
52       Name:     height
53       Class:    Height
54       Switch:   -height
55           Specifies a desired height for the button.  If an image or bitmap
56           is being displayed in the button then the value is in screen units
57           (i.e. any of the forms acceptable to Tk_GetPixels); for text it is
58           in lines of text.  If this option isn't specified, the button's
59           desired height is computed from the size of the image or bitmap or
60           text being displayed in it.
61
62       Command-Line Name: -overrelief
63       Database Name:  overRelief
64       Database Class: OverRelief
65           Specifies  an alternative relief for the button, to be used when
66           the mouse cursor is over the widget.  This option can be used to
67           make  toolbar  buttons,  by configuring -relief flat -overrelief
68           raised.  If the value of this option is the empty  string,  then no
69           alternative relief is used when the mouse cursor is over the but‐
70           ton.  The empty string is the default value.
71
72       Name:     state
73       Class:    State
74       Switch:   -state
75           Specifies one of three states for the button:  normal, active, or
76           disabled.  In normal state the button is displayed using the fore‐
77           ground and background options.  The active state is typically used
78           when the pointer is over the button.  In active state the button is
79           displayed using the activeForeground and activeBackground options.
80           Disabled state means that the button should be insensitive:  the
81           default bindings will refuse to activate the widget and will ignore
82           mouse button presses.  In this state the disabledForeground and
83           background options determine how the button is displayed.
84
85       Name:     width
86       Class:    Width
87       Switch:   -width
88           Specifies a desired width for the button.  If an image or bitmap is
89           being displayed in the button then the value is in screen units
90           (i.e. any of the forms acceptable to Tk_GetPixels); for text it is
91           in characters.  If this option isn't specified, the button's
92           desired width is computed from the size of the image or bitmap or
93           text being displayed in it.
94

DESCRIPTION

96       The Button method creates a new window (given by the $widget argument)
97       and makes it into a button widget.  Additional options, described
98       above, may be specified on the command line or in the option database
99       to configure aspects of the button such as its colors, font, text, and
100       initial relief.  The button command returns its $widget argument.  At
101       the time this command is invoked, there must not exist a window named
102       $widget, but $widget's parent must exist.
103
104       A button is a widget that displays a textual string, bitmap or image.
105       If text is displayed, it must all be in a single font, but it can
106       occupy multiple lines on the screen (if it contains newlines or if
107       wrapping occurs because of the -wraplength option) and one of the char‐
108       acters may optionally be underlined using the -underline option.  It
109       can display itself in either of three different ways, according to the
110       -state option; it can be made to appear raised, sunken, or flat; and it
111       can be made to flash.  When a user invokes the button (by pressing
112       mouse button 1 with the cursor over the button), then the perl/Tk call‐
113       back specified in the -command option is invoked.
114

WIDGET METHODS

116       The Button method creates a widget object.  This object supports the
117       configure and cget methods described in Tk::options which can be used
118       to enquire and modify the options described above.  The widget also
119       inherits all the methods provided by the generic Tk::Widget class.
120
121       The following additional methods are available for button widgets:
122
123       $button->flash
124           Flash the button.  This is accomplished by redisplaying the button
125           several times, alternating between active and normal colors.  At
126           the end of the flash the button is left in the same normal/active
127           state as when the command was invoked.  This command is ignored if
128           the button's state is disabled.
129
130       $button->invoke
131           Invoke the callback associated with the buttons -command option, if
132           there is one.  The return value is the return value from the call‐
133           back, or the undefined value if there is no callback associated
134           with the button.  This command is ignored if the button's state is
135           disabled.
136

DEFAULT BINDINGS

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

KEYWORDS

165       button, widget
166
167
168
169perl v5.8.8                       2008-02-05                         Button(3)
Impressum