Create and manipulate a scale widget.


hwtk::scale - pathName ?option value? …


A hwtk::scale widget is typically used to control the numeric value of a linked variable that varies uniformly over some range. A scale displays a slider that can be moved along over a trough, with the relative position of the slider over the trough indicating

Standard Options

Database name: clientData
Database class: ClientData
Acts as a data storage for a widgets. User can store any data and this will not have any effect on widget property.
Database name: cursor
Database class: Cursor
Specifies the mouse cursor to be used for the widget. See Tk_GetCursor and cursors(n) in the Tk reference manual for the legal values. If set to the empty string (the default), the cursor is inherited from the parent widget.
Database name: help
Database class: Text
Specifies the text or help message that displays when the cursor moves over the widget.
Database name: helpcommand
Database class: Command
Dynamic help which calls an assigned -helpcommand when the user moves the mouse on the widget. The text which is returned by the -helpcommand will be in turn be displayed on the tooltip.
Database name: takeFocus
Database class: TakeFocus
Determines whether the window accepts the focus during keyboard traversal. Either 0, 1, a command prefix (to which the widget path is appended, and which should return 0 or 1), or the empty string. See options(n) in the Tk reference manual for the full description.

Widget-Specific Options

Database name: command
Database class: Command
Specifies the prefix of a Tcl command to invoke whenever the scale’s value is changed via a widget command. The actual command consists of this option followed by a space and a real number indicating the new value of the scale.
Database name: from
Database class: From
A real value corresponding to the left or top end of the scale.
Database name: length
Database class: Length
Specifies the desired long dimension of the scale in screen units (i.e. any of the forms acceptable to Tk_GetPixels). For vertical scales this is the scale’s height; for horizontal scales it is the scale’s width.
Database name: orient
Database class: Orient
Specifies the orientation whether the widget should be laid out horizontally or vertically. Must be either horizontal or vertical or an abbreviation of one of these. Default is horizontal.
Database name: to
Database class: To
Specifies a real value corresponding to the right or bottom end of the scale. This value may be either less than or greater than the from option.
Database name: value
Database class: Value
Specifies the current floating-point value of the variable.
Database name: variable
Database class: Variable
Specifies the name of a global variable to link to the scale. Whenever the value of the variable changes, the scale will update to reflect this value. Whenever the scale is manipulated interactively, the variable will be modified to reflect the scale’s new value.

Widget Command

pathName configure ?option? ?value option value …?
Query or modify the configuration options of the widget. If one or more option-value pairs are specified, then the command modifies the given widget option(s) to have the given value(s); in this case the command returns an empty string. If option is specified with no value, then the command returns a list describing the named option: the elements of the list are the option name, database name, database class, default value, and current value. If no option is specified, returns a list describing all of the available options for pathName.
pathName cget option
Returns the current value of the configuration option given by option.
pathName identify element x y
Returns the name of the element under the point given by x and y, or an empty string if the point does not lie within any element. x and y are pixel coordinates relative to the widget. Some widgets accept other identify subcommands.
pathName instate statespec ?script?
Test the widget’s state. If script is not specified, returns 1 if the widget state matches statespec and 0 otherwise. If script is specified, equivalent to
pathName state ?stateSpec?
Modify or inquire widget state. If stateSpec is present, sets the widget state: for each flag in stateSpec, sets the corresponding flag or clears it if prefixed by an exclamation point. Returns a new state spec indicating which flags were changed:
will restore pathName to the original state. If stateSpec is not specified, returns a list of the currently-enabled state flags.
pathName coords ?value?
Get the coordinates corresponding to value, or the coordinates corresponding to the current value of the -value option if value is omitted.
pathName get ?xy?
Get the current value of the -value option, or the value corresponding to the coordinates x,y if they are specified. X and y are pixel coordinates relative to the scale widget origin.
pathName set ?value?
Set the value of the widget (i.e. the -value option) to value. The value will be clipped to the range given by the -from and -to options. Note that setting the linked variable (i.e. the variable named in the -variable option) does not cause such clipping.


proc ScaleValues {w idx} {
    set c {lindex "Red Orange Yellow green_noitalic Blue Violet" [tcl::mathfunc::int $idx]]  
    $w configure -foreground $c -text "Color:: $c"

hwtk::dialog .dlg -title "::hwtk::scale"
set recess [.dlg recess]
label $recess.label
hwtk::scale $recess.scale -from 0 -to 5 -command [list ScaleValues $recess.label]
pack $recess.label $recess.scale

.dlg post