1Scale(3) User Contributed Perl Documentation Scale(3)
2
3
4
6 Tk::Scale - Create and manipulate Scale widgets
7
9 $scale = $parent->Scale(?options?);
10
12 -activebackground -font -highlightthickness -repeatinterval
13 -background -foreground -orient -takefocus
14 -borderwidth -highlightbackground -relief -troughcolor
15 -cursor -highlightcolor -repeatdelay
16
17 See Tk::options for details of the standard options.
18
20 Name: bigIncrement
21 Class: BigIncrement
22 Switch: -bigincrement
23 Some interactions with the scale cause its value to change by
24 ``large'' increments; this option specifies the size of the large
25 increments. If specified as 0, the large increments default to
26 1/10 the range of the scale.
27
28 Name: command
29 Class: Command
30 Switch: -command
31 Specifies the prefix of a perl/Tk callback to invoke whenever the
32 scale's value is changed via a method. The actual command consists
33 of this option followed by a space and a real number indicating the
34 new value of the scale.
35
36 Name: digits
37 Class: Digits
38 Switch: -digits
39 An integer specifying how many significant digits should be
40 retained when converting the value of the scale to a string. If
41 the number is less than or equal to zero, then the scale picks the
42 smallest value that guarantees that every possible slider position
43 prints as a different string.
44
45 Name: from
46 Class: From
47 Switch: -from
48 A real value corresponding to the left or top end of the scale.
49
50 Name: label
51 Class: Label
52 Switch: -label
53 A string to display as a label for the scale. For vertical scales
54 the label is displayed just to the right of the top end of the
55 scale. For horizontal scales the label is displayed just above the
56 left end of the scale. If the option is specified as an empty
57 string, no label is displayed.
58
59 Name: length
60 Class: Length
61 Switch: -length
62 Specifies the desired long dimension of the scale in screen units
63 (i.e. any of the forms acceptable to Tk_GetPixels). For vertical
64 scales this is the scale's height; for horizontal scales it is the
65 scale's width.
66
67 Name: resolution
68 Class: Resolution
69 Switch: -resolution
70 A real value specifying the resolution for the scale. If this
71 value is greater than zero then the scale's value will always be
72 rounded to an even multiple of this value, as will tick marks and
73 the endpoints of the scale. If the value is less than zero then no
74 rounding occurs. Defaults to 1 (i.e., the value will be integral).
75
76 Name: showValue
77 Class: ShowValue
78 Switch: -showvalue
79 Specifies a boolean value indicating whether or not the current
80 value of the scale is to be displayed.
81
82 Name: sliderLength
83 Class: SliderLength
84 Switch: -sliderlength
85 Specfies the size of the slider, measured in screen units along the
86 slider's long dimension. The value may be specified in any of the
87 forms acceptable to Tk_GetPixels.
88
89 Name: sliderRelief
90 Class: SliderRelief
91 Switch: -sliderrelief
92 Specifies the relief to use when drawing the slider, such as raised
93 or sunken.
94
95 Name: state
96 Class: State
97 Switch: -state
98 Specifies one of three states for the scale: normal, active, or
99 disabled. If the scale is disabled then the value may not be
100 changed and the scale won't activate. If the scale is active, the
101 slider is displayed using the color specified by the
102 activeBackground option.
103
104 Name: tickInterval
105 Class: TickInterval
106 Switch: -tickinterval
107 Must be a real value. Determines the spacing between numerical
108 tick marks displayed below or to the left of the slider. If 0, no
109 tick marks will be displayed.
110
111 Name: to
112 Class: To
113 Switch: -to
114 Specifies a real value corresponding to the right or bottom end of
115 the scale. This value may be either less than or greater than the
116 from option.
117
118 Name: variable
119 Class: Variable
120 Switch: -variable
121 Specifies the name of a global variable to link to the scale.
122 Whenever the value of the variable changes, the scale will update
123 to reflect this value. Whenever the scale is manipulated
124 interactively, the variable will be modified to reflect the scale's
125 new value.
126
127 Name: width
128 Class: Width
129 Switch: -width
130 Specifies the desired narrow dimension of the trough in screen
131 units (i.e. any of the forms acceptable to Tk_GetPixels). For
132 vertical scales this is the trough's width; for horizontal scales
133 this is the trough's height.
134
136 The Scale method creates a new window (given by the $widget argument)
137 and makes it into a scale widget. Additional options, described above,
138 may be specified on the command line or in the option database to
139 configure aspects of the scale such as its colors, orientation, and
140 relief. The scale command returns its $widget argument. At the time
141 this command is invoked, there must not exist a window named $widget,
142 but $widget's parent must exist.
143
144 A scale is a widget that displays a rectangular trough and a small
145 slider. The trough corresponds to a range of real values (determined
146 by the from, to, and resolution options), and the position of the
147 slider selects a particular real value. The slider's position (and
148 hence the scale's value) may be adjusted with the mouse or keyboard as
149 described in the "BINDINGS" section below. Whenever the scale's value
150 is changed, a Tcl command is invoked (using the command option) to
151 notify other interested widgets of the change. In addition, the value
152 of the scale can be linked to a Tcl variable (using the variable
153 option), so that changes in either are reflected in the other.
154
155 Three annotations may be displayed in a scale widget: a label
156 appearing at the top right of the widget (top left for horizontal
157 scales), a number displayed just to the left of the slider (just above
158 the slider for horizontal scales), and a collection of numerical tick
159 marks just to the left of the current value (just below the trough for
160 horizontal scales). Each of these three annotations may be enabled or
161 disabled using the configuration options.
162
164 The Scale method creates a widget object. This object supports the
165 configure and cget methods described in Tk::options which can be used
166 to enquire and modify the options described above. The widget also
167 inherits all the methods provided by the generic Tk::Widget class.
168
169 The following additional methods are available for scale widgets:
170
171 $scale->coords(?value?)
172 Returns a list whose elements are the x and y coordinates of the
173 point along the centerline of the trough that corresponds to value.
174 If value is omitted then the scale's current value is used.
175
176 $scale->get(?x, y?)
177 If x and y are omitted, returns the current value of the scale. If
178 x and y are specified, they give pixel coordinates within the
179 widget; the command returns the scale value corresponding to the
180 given pixel. Only one of x or y is used: for horizontal scales y
181 is ignored, and for vertical scales x is ignored.
182
183 $scale->identify(x, y)
184 Returns a string indicating what part of the scale lies under the
185 coordinates given by x and y. A return value of slider means that
186 the point is over the slider; trough1 means that the point is over
187 the portion of the slider above or to the left of the slider; and
188 trough2 means that the point is over the portion of the slider
189 below or to the right of the slider. If the point isn't over one
190 of these elements, an empty string is returned.
191
192 $scale->set(value)
193 This command is invoked to change the current value of the scale,
194 and hence the position at which the slider is displayed. Value
195 gives the new value for the scale. The command has no effect if
196 the scale is disabled.
197
199 Tk automatically creates class bindings for scales that give them the
200 following default behavior. Where the behavior is different for
201 vertical and horizontal scales, the horizontal behavior is described in
202 parentheses.
203
204 [1] If button 1 is pressed in the trough, the scale's value will be
205 incremented or decremented by the value of the resolution option so
206 that the slider moves in the direction of the cursor. If the
207 button is held down, the action auto-repeats.
208
209 [2] If button 1 is pressed over the slider, the slider can be dragged
210 with the mouse.
211
212 [3] If button 1 is pressed in the trough with the Control key down, the
213 slider moves all the way to the end of its range, in the direction
214 towards the mouse cursor.
215
216 [4] If button 2 is pressed, the scale's value is set to the mouse
217 position. If the mouse is dragged with button 2 down, the scale's
218 value changes with the drag.
219
220 [5] The Up and Left keys move the slider up (left) by the value of the
221 resolution option.
222
223 [6] The Down and Right keys move the slider down (right) by the value
224 of the resolution option.
225
226 [7] Control-Up and Control-Left move the slider up (left) by the value
227 of the bigIncrement option.
228
229 [8] Control-Down and Control-Right move the slider down (right) by the
230 value of the bigIncrement option.
231
232 [9] Home moves the slider to the top (left) end of its range.
233
234 [10]
235 End moves the slider to the bottom (right) end of its range.
236
237 If the scale is disabled using the state option then none of the
238 above bindings have any effect.
239
240 The behavior of scales can be changed by defining new bindings for
241 individual widgets or by redefining the class bindings.
242
244 scale, slider, trough, widget
245
246
247
248perl v5.30.1 2020-01-30 Scale(3)