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
13       -borderwidth -compound -cursor -disabledforeground -font -foreground
14       -highlightbackground -highlightcolor -highlightthickness -image
15       -justify -padx -pady -relief -repeatdelay -repeatinterval -takefocus
16       -text -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
43           platform specific appearance for a default button.  In normal
44           state, the button is drawn with the platform specific appearance
45           for a non-default button, leaving enough space to draw the default
46           button appearance.  The normal and active states will result in
47           buttons of the same size.  In disabled state, the button is drawn
48           with the non-default button appearance without leaving space for
49           the default appearance.  The disabled state may result in a smaller
50           button than 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
70           button.  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
77           foreground and background options.  The active state is typically
78           used when the pointer is over the button.  In active state the
79           button is displayed using the activeForeground and activeBackground
80           options.  Disabled state means that the button should be
81           insensitive:  the default bindings will refuse to activate the
82           widget and will ignore mouse button presses.  In this state the
83           disabledForeground and background options determine how the button
84           is displayed.
85
86       Name:     width
87       Class:    Width
88       Switch:   -width
89           Specifies a desired width for the button.  If an image or bitmap is
90           being displayed in the button then the value is in screen units
91           (i.e. any of the forms acceptable to Tk_GetPixels); for text it is
92           in characters.  If this option isn't specified, the button's
93           desired width is computed from the size of the image or bitmap or
94           text being displayed in it.
95

DESCRIPTION

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

WIDGET METHODS

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

DEFAULT BINDINGS

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

KEYWORDS

166       button, widget
167
168
169
170perl v5.30.1                      2020-01-30                         Button(3)
Impressum