1scale(n) Tk Built-In Commands scale(n)
2
3
4
5______________________________________________________________________________
6
8 scale - Create and manipulate 'scale' value-controlled slider widgets
9
11 scale pathName ?options?
12
14 -activebackground -foreground -relief
15 -background -highlightbackground -repeatdelay
16 -borderwidth -highlightcolor -repeatinterval
17 -cursor -highlightthickness -takefocus
18 -font -orient -troughcolor
19
20 See the options manual entry for details on the standard options.
21
23 Command-Line Name:-bigincrement
24 Database Name: bigIncrement
25 Database Class: BigIncrement
26
27 Some interactions with the scale cause its value to change by
28 “large” increments; this option specifies the size of the large
29 increments. If specified as 0, the large increments default to
30 1/10 the range of the scale.
31
32 Command-Line Name:-command
33 Database Name: command
34 Database Class: Command
35
36 Specifies the prefix of a Tcl command to invoke whenever the
37 scale's value is changed via a widget command. The actual com‐
38 mand consists of this option followed by a space and a real num‐
39 ber indicating the new value of the scale.
40
41 Command-Line Name:-digits
42 Database Name: digits
43 Database Class: Digits
44
45 An integer specifying how many significant digits should be re‐
46 tained when converting the value of the scale to a string. If
47 the number is less than or equal to zero, then the scale picks
48 the smallest value that guarantees that every possible slider
49 position prints as a different string.
50
51 Command-Line Name:-from
52 Database Name: from
53 Database Class: From
54
55 A real value corresponding to the left or top end of the scale.
56
57 Command-Line Name:-label
58 Database Name: label
59 Database Class: Label
60
61 A string to display as a label for the scale. For vertical
62 scales the label is displayed just to the right of the top end
63 of the scale. For horizontal scales the label is displayed just
64 above the left end of the scale. If the option is specified as
65 an empty string, no label is displayed.
66
67 Command-Line Name:-length
68 Database Name: length
69 Database Class: Length
70
71 Specifies the desired long dimension of the scale in screen
72 units (i.e. any of the forms acceptable to Tk_GetPixels). For
73 vertical scales this is the scale's height; for horizontal
74 scales it is the scale's width.
75
76 Command-Line Name:-resolution
77 Database Name: resolution
78 Database Class: Resolution
79
80 A real value specifying the resolution for the scale. If this
81 value is greater than zero then the scale's value will always be
82 rounded to an even multiple of this value, as will the endpoints
83 of the scale. If the value is less than zero then no rounding
84 occurs. Defaults to 1 (i.e., the value will be integral).
85
86 Command-Line Name:-showvalue
87 Database Name: showValue
88 Database Class: ShowValue
89
90 Specifies a boolean value indicating whether or not the current
91 value of the scale is to be displayed.
92
93 Command-Line Name:-sliderlength
94 Database Name: sliderLength
95 Database Class: SliderLength
96
97 Specifies the size of the slider, measured in screen units along
98 the slider's long dimension. The value may be specified in any
99 of the forms acceptable to Tk_GetPixels.
100
101 Command-Line Name:-sliderrelief
102 Database Name: sliderRelief
103 Database Class: SliderRelief
104
105 Specifies the relief to use when drawing the slider, such as
106 raised or sunken.
107
108 Command-Line Name:-state
109 Database Name: state
110 Database Class: State
111
112 Specifies one of three states for the scale: normal, active, or
113 disabled. If the scale is disabled then the value may not be
114 changed and the scale will not activate. If the scale is ac‐
115 tive, the slider is displayed using the color specified by the
116 -activebackground option.
117
118 Command-Line Name:-tickinterval
119 Database Name: tickInterval
120 Database Class: TickInterval
121
122 Must be a real value. Determines the spacing between numerical
123 tick marks displayed below or to the left of the slider. The
124 values will all be displayed with the same number of decimal
125 places, which will be enough to ensure they are all accurate to
126 within 20% of a tick interval. If 0, no tick marks will be dis‐
127 played.
128
129 Command-Line Name:-to
130 Database Name: to
131 Database Class: To
132
133 Specifies a real value corresponding to the right or bottom end
134 of the scale. This value may be either less than or greater
135 than the -from option.
136
137 Command-Line Name:-variable
138 Database Name: variable
139 Database Class: Variable
140
141 Specifies the name of a global variable to link to the scale.
142 Whenever the value of the variable changes, the scale will up‐
143 date to reflect this value. Whenever the scale is manipulated
144 interactively, the variable will be modified to reflect the
145 scale's new value.
146
147 Command-Line Name:-width
148 Database Name: width
149 Database Class: Width
150
151 Specifies the desired narrow dimension of the scale in screen
152 units (i.e. any of the forms acceptable to Tk_GetPixels). For
153 vertical scales this is the scale's width; for horizontal
154 scales this is the scale's height.
155______________________________________________________________________________
156
158 The scale command creates a new window (given by the pathName argument)
159 and makes it into a scale widget. Additional options, described above,
160 may be specified on the command line or in the option database to con‐
161 figure aspects of the scale such as its colors, orientation, and re‐
162 lief. The scale command returns its pathName argument. At the time
163 this command is invoked, there must not exist a window named pathName,
164 but pathName's parent must exist.
165
166 A scale is a widget that displays a rectangular trough and a small
167 slider. The trough corresponds to a range of real values (determined
168 by the -from, -to, and -resolution options), and the position of the
169 slider selects a particular real value. The slider's position (and
170 hence the scale's value) may be adjusted with the mouse or keyboard as
171 described in the BINDINGS section below. Whenever the scale's value is
172 changed, a Tcl command is invoked (using the -command option) to notify
173 other interested widgets of the change. In addition, the value of the
174 scale can be linked to a Tcl variable (using the -variable option), so
175 that changes in either are reflected in the other.
176
177 Three annotations may be displayed in a scale widget: a label appear‐
178 ing at the top right of the widget (top left for horizontal scales), a
179 number displayed just to the left of the slider (just above the slider
180 for horizontal scales), and a collection of numerical tick marks just
181 to the left of the current value (just below the trough for horizontal
182 scales). Each of these three annotations may be enabled or disabled
183 using the configuration options.
184
186 The scale command creates a new Tcl command whose name is pathName.
187 This command may be used to invoke various operations on the widget.
188 It has the following general form:
189 pathName option ?arg arg ...?
190 Option and the args determine the exact behavior of the command. The
191 following commands are possible for scale widgets:
192
193 pathName cget option
194 Returns the current value of the configuration option given by
195 option. Option may have any of the values accepted by the scale
196 command.
197
198 pathName configure ?option? ?value option value ...?
199 Query or modify the configuration options of the widget. If no
200 option is specified, returns a list describing all of the avail‐
201 able options for pathName (see Tk_ConfigureInfo for information
202 on the format of this list). If option is specified with no
203 value, then the command returns a list describing the one named
204 option (this list will be identical to the corresponding sublist
205 of the value returned if no option is specified). If one or
206 more option-value pairs are specified, then the command modifies
207 the given widget option(s) to have the given value(s); in this
208 case the command returns an empty string. Option may have any
209 of the values accepted by the scale command.
210
211 pathName coords ?value?
212 Returns a list whose elements are the x and y coordinates of the
213 point along the centerline of the trough that corresponds to
214 value. If value is omitted then the scale's current value is
215 used.
216
217 pathName get ?x y?
218 If x and y are omitted, returns the current value of the scale.
219 If x and y are specified, they give pixel coordinates within the
220 widget; the command returns the scale value corresponding to
221 the given pixel. Only one of x or y is used: for horizontal
222 scales y is ignored, and for vertical scales x is ignored.
223
224 pathName identify x y
225 Returns a string indicating what part of the scale lies under
226 the coordinates given by x and y. A return value of slider
227 means that the point is over the slider; trough1 means that the
228 point is over the portion of the slider above or to the left of
229 the slider; and trough2 means that the point is over the portion
230 of the slider below or to the right of the slider. If the point
231 is not over one of these elements, an empty string is returned.
232
233 pathName set value
234 This command is invoked to change the current value of the
235 scale, and hence the position at which the slider is displayed.
236 Value gives the new value for the scale. The command has no ef‐
237 fect if the scale is disabled.
238
240 Tk automatically creates class bindings for scales that give them the
241 following default behavior. Where the behavior is different for verti‐
242 cal and horizontal scales, the horizontal behavior is described in
243 parentheses.
244
245 [1] If button 1 is pressed in the trough, the scale's value will be
246 incremented or decremented by the value of the -resolution op‐
247 tion so that the slider moves in the direction of the cursor.
248 If the button is held down, the action auto-repeats.
249
250 [2] If button 1 is pressed over the slider, the slider can be
251 dragged with the mouse.
252
253 [3] If button 1 is pressed in the trough with the Control key down,
254 the slider moves all the way to the end of its range, in the di‐
255 rection towards the mouse cursor.
256
257 [4] If button 2 is pressed, the scale's value is set to the mouse
258 position. If the mouse is dragged with button 2 down, the
259 scale's value changes with the drag.
260
261 [5] The Up and Left keys move the slider up (left) by the value of
262 the -resolution option.
263
264 [6] The Down and Right keys move the slider down (right) by the
265 value of the -resolution option.
266
267 [7] Control-Up and Control-Left move the slider up (left) by the
268 value of the -bigincrement option.
269
270 [8] Control-Down and Control-Right move the slider down (right) by
271 the value of the -bigincrement option.
272
273 [9] Home moves the slider to the top (left) end of its range.
274
275 [10] End moves the slider to the bottom (right) end of its range.
276
277 If the scale is disabled using the -state option then none of the above
278 bindings have any effect.
279
280 The behavior of scales can be changed by defining new bindings for in‐
281 dividual widgets or by redefining the class bindings.
282
284 ttk::scale(n)
285
287 scale, slider, trough, widget
288
289
290
291Tk 4.1 scale(n)