.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Scale 3" .TH Scale 3 2023-07-25 "perl v5.38.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Tk::Scale \- Create and manipulate Scale widgets .SH SYNOPSIS .IX Header "SYNOPSIS" \&\fR\f(CI$scale\fR\fI\fR = \fI\fR\f(CI$parent\fR\fI\fR\->\fBScale\fR(?\fIoptions\fR?); .SH "STANDARD OPTIONS" .IX Header "STANDARD OPTIONS" \&\fB\-activebackground\fR \fB\-font\fR \fB\-highlightthickness\fR \fB\-repeatinterval\fR \&\fB\-background\fR \fB\-foreground\fR \fB\-orient\fR \fB\-takefocus\fR \&\fB\-borderwidth\fR \fB\-highlightbackground\fR \fB\-relief\fR \fB\-troughcolor\fR \&\fB\-cursor\fR \fB\-highlightcolor\fR \fB\-repeatdelay\fR .PP See Tk::options for details of the standard options. .SH "WIDGET-SPECIFIC OPTIONS" .IX Header "WIDGET-SPECIFIC OPTIONS" .IP "Name: \fBbigIncrement\fR" 4 .IX Item "Name: bigIncrement" .PD 0 .IP "Class: \fBBigIncrement\fR" 4 .IX Item "Class: BigIncrement" .IP "Switch: \fB\-bigincrement\fR" 4 .IX Item "Switch: -bigincrement" .PD Some interactions with the scale cause its value to change by ``large'' increments; this option specifies the size of the large increments. If specified as 0, the large increments default to 1/10 the range of the scale. .IP "Name: \fBcommand\fR" 4 .IX Item "Name: command" .PD 0 .IP "Class: \fBCommand\fR" 4 .IX Item "Class: Command" .IP "Switch: \fB\-command\fR" 4 .IX Item "Switch: -command" .PD Specifies the prefix of a perl/Tk callback to invoke whenever the scale's value is changed via a method. The actual command consists of this option followed by a space and a real number indicating the new value of the scale. .IP "Name: \fBdigits\fR" 4 .IX Item "Name: digits" .PD 0 .IP "Class: \fBDigits\fR" 4 .IX Item "Class: Digits" .IP "Switch: \fB\-digits\fR" 4 .IX Item "Switch: -digits" .PD An integer specifying how many significant digits should be retained when converting the value of the scale to a string. If the number is less than or equal to zero, then the scale picks the smallest value that guarantees that every possible slider position prints as a different string. .IP "Name: \fBfrom\fR" 4 .IX Item "Name: from" .PD 0 .IP "Class: \fBFrom\fR" 4 .IX Item "Class: From" .IP "Switch: \fB\-from\fR" 4 .IX Item "Switch: -from" .PD A real value corresponding to the left or top end of the scale. .IP "Name: \fBlabel\fR" 4 .IX Item "Name: label" .PD 0 .IP "Class: \fBLabel\fR" 4 .IX Item "Class: Label" .IP "Switch: \fB\-label\fR" 4 .IX Item "Switch: -label" .PD A string to display as a label for the scale. For vertical scales the label is displayed just to the right of the top end of the scale. For horizontal scales the label is displayed just above the left end of the scale. If the option is specified as an empty string, no label is displayed. .IP "Name: \fBlength\fR" 4 .IX Item "Name: length" .PD 0 .IP "Class: \fBLength\fR" 4 .IX Item "Class: Length" .IP "Switch: \fB\-length\fR" 4 .IX Item "Switch: -length" .PD Specifies the desired long dimension of the scale in screen units (i.e. any of the forms acceptable to \fBTk_GetPixels\fR). For vertical scales this is the scale's height; for horizontal scales it is the scale's width. .IP "Name: \fBresolution\fR" 4 .IX Item "Name: resolution" .PD 0 .IP "Class: \fBResolution\fR" 4 .IX Item "Class: Resolution" .IP "Switch: \fB\-resolution\fR" 4 .IX Item "Switch: -resolution" .PD A real value specifying the resolution for the scale. If this value is greater than zero then the scale's value will always be rounded to an even multiple of this value, as will tick marks and the endpoints of the scale. If the value is less than zero then no rounding occurs. Defaults to 1 (i.e., the value will be integral). .IP "Name: \fBshowValue\fR" 4 .IX Item "Name: showValue" .PD 0 .IP "Class: \fBShowValue\fR" 4 .IX Item "Class: ShowValue" .IP "Switch: \fB\-showvalue\fR" 4 .IX Item "Switch: -showvalue" .PD Specifies a boolean value indicating whether or not the current value of the scale is to be displayed. .IP "Name: \fBsliderLength\fR" 4 .IX Item "Name: sliderLength" .PD 0 .IP "Class: \fBSliderLength\fR" 4 .IX Item "Class: SliderLength" .IP "Switch: \fB\-sliderlength\fR" 4 .IX Item "Switch: -sliderlength" .PD Specfies the size of the slider, measured in screen units along the slider's long dimension. The value may be specified in any of the forms acceptable to \fBTk_GetPixels\fR. .IP "Name: \fBsliderRelief\fR" 4 .IX Item "Name: sliderRelief" .PD 0 .IP "Class: \fBSliderRelief\fR" 4 .IX Item "Class: SliderRelief" .IP "Switch: \fB\-sliderrelief\fR" 4 .IX Item "Switch: -sliderrelief" .PD Specifies the relief to use when drawing the slider, such as \fBraised\fR or \fBsunken\fR. .IP "Name: \fBstate\fR" 4 .IX Item "Name: state" .PD 0 .IP "Class: \fBState\fR" 4 .IX Item "Class: State" .IP "Switch: \fB\-state\fR" 4 .IX Item "Switch: -state" .PD Specifies one of three states for the scale: \fBnormal\fR, \&\fBactive\fR, or \fBdisabled\fR. If the scale is disabled then the value may not be changed and the scale won't activate. If the scale is active, the slider is displayed using the color specified by the \fBactiveBackground\fR option. .IP "Name: \fBtickInterval\fR" 4 .IX Item "Name: tickInterval" .PD 0 .IP "Class: \fBTickInterval\fR" 4 .IX Item "Class: TickInterval" .IP "Switch: \fB\-tickinterval\fR" 4 .IX Item "Switch: -tickinterval" .PD Must be a real value. Determines the spacing between numerical tick marks displayed below or to the left of the slider. If 0, no tick marks will be displayed. .IP "Name: \fBto\fR" 4 .IX Item "Name: to" .PD 0 .IP "Class: \fBTo\fR" 4 .IX Item "Class: To" .IP "Switch: \fB\-to\fR" 4 .IX Item "Switch: -to" .PD 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 \fBfrom\fR option. .IP "Name: \fBvariable\fR" 4 .IX Item "Name: variable" .PD 0 .IP "Class: \fBVariable\fR" 4 .IX Item "Class: Variable" .IP "Switch: \fB\-variable\fR" 4 .IX Item "Switch: -variable" .PD 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. .IP "Name: \fBwidth\fR" 4 .IX Item "Name: width" .PD 0 .IP "Class: \fBWidth\fR" 4 .IX Item "Class: Width" .IP "Switch: \fB\-width\fR" 4 .IX Item "Switch: -width" .PD Specifies the desired narrow dimension of the trough in screen units (i.e. any of the forms acceptable to \fBTk_GetPixels\fR). For vertical scales this is the trough's width; for horizontal scales this is the trough's height. .SH DESCRIPTION .IX Header "DESCRIPTION" The \fBScale\fR method creates a new window (given by the \&\f(CW$widget\fR argument) and makes it into a scale widget. Additional options, described above, may be specified on the command line or in the option database to configure aspects of the scale such as its colors, orientation, and relief. The \fBscale\fR command returns its \&\f(CW$widget\fR argument. At the time this command is invoked, there must not exist a window named \f(CW$widget\fR, but \&\f(CW$widget\fR's parent must exist. .PP A scale is a widget that displays a rectangular \fItrough\fR and a small \fIslider\fR. The trough corresponds to a range of real values (determined by the \fBfrom\fR, \fBto\fR, and \&\fBresolution\fR options), and the position of the slider selects a particular real value. The slider's position (and hence the scale's value) may be adjusted with the mouse or keyboard as described in the "BINDINGS" section below. Whenever the scale's value is changed, a Tcl command is invoked (using the \fBcommand\fR option) to notify other interested widgets of the change. In addition, the value of the scale can be linked to a Tcl variable (using the \fBvariable\fR option), so that changes in either are reflected in the other. .PP Three annotations may be displayed in a scale widget: a label appearing at the top right of the widget (top left for horizontal scales), a number displayed just to the left of the slider (just above the slider for horizontal scales), and a collection of numerical tick marks just to the left of the current value (just below the trough for horizontal scales). Each of these three annotations may be enabled or disabled using the configuration options. .SH "WIDGET METHODS" .IX Header "WIDGET METHODS" The \fBScale\fR method creates a widget object. This object supports the \fBconfigure\fR and \fBcget\fR methods described in Tk::options which can be used to enquire and modify the options described above. The widget also inherits all the methods provided by the generic Tk::Widget class. .PP The following additional methods are available for scale widgets: .ie n .IP \fR\fI$scale\fR\fI\fR\->\fBcoords\fR(?\fIvalue\fR?) 4 .el .IP \fR\f(CI$scale\fR\fI\fR\->\fBcoords\fR(?\fIvalue\fR?) 4 .IX Item "$scale->coords(?value?)" Returns a list whose elements are the x and y coordinates of the point along the centerline of the trough that corresponds to \fIvalue\fR. If \fIvalue\fR is omitted then the scale's current value is used. .ie n .IP "\fR\fI$scale\fR\fI\fR\->\fBget\fR(?\fIx, y\fR?)" 4 .el .IP "\fR\f(CI$scale\fR\fI\fR\->\fBget\fR(?\fIx, y\fR?)" 4 .IX Item "$scale->get(?x, y?)" If \fIx\fR and \fIy\fR are omitted, returns the current value of the scale. If \fIx\fR and \fIy\fR are specified, they give pixel coordinates within the widget; the command returns the scale value corresponding to the given pixel. Only one of \fIx\fR or \fIy\fR is used: for horizontal scales \&\fIy\fR is ignored, and for vertical scales \fIx\fR is ignored. .ie n .IP "\fR\fI$scale\fR\fI\fR\->\fBidentify\fR(\fIx, y\fR)" 4 .el .IP "\fR\f(CI$scale\fR\fI\fR\->\fBidentify\fR(\fIx, y\fR)" 4 .IX Item "$scale->identify(x, y)" Returns a string indicating what part of the scale lies under the coordinates given by \fIx\fR and \fIy\fR. A return value of \fBslider\fR means that the point is over the slider; \fBtrough1\fR means that the point is over the portion of the slider above or to the left of the slider; and \fBtrough2\fR means that the point is over the portion of the slider below or to the right of the slider. If the point isn't over one of these elements, an empty string is returned. .ie n .IP \fR\fI$scale\fR\fI\fR\->\fBset\fR(\fIvalue\fR) 4 .el .IP \fR\f(CI$scale\fR\fI\fR\->\fBset\fR(\fIvalue\fR) 4 .IX Item "$scale->set(value)" This command is invoked to change the current value of the scale, and hence the position at which the slider is displayed. \fIValue\fR gives the new value for the scale. The command has no effect if the scale is disabled. .SH BINDINGS .IX Header "BINDINGS" Tk automatically creates class bindings for scales that give them the following default behavior. Where the behavior is different for vertical and horizontal scales, the horizontal behavior is described in parentheses. .IP [1] 4 .IX Item "[1]" If button 1 is pressed in the trough, the scale's value will be incremented or decremented by the value of the \fBresolution\fR option so that the slider moves in the direction of the cursor. If the button is held down, the action auto-repeats. .IP [2] 4 .IX Item "[2]" If button 1 is pressed over the slider, the slider can be dragged with the mouse. .IP [3] 4 .IX Item "[3]" If button 1 is pressed in the trough with the Control key down, the slider moves all the way to the end of its range, in the direction towards the mouse cursor. .IP [4] 4 .IX Item "[4]" If button 2 is pressed, the scale's value is set to the mouse position. If the mouse is dragged with button 2 down, the scale's value changes with the drag. .IP [5] 4 .IX Item "[5]" The Up and Left keys move the slider up (left) by the value of the \fBresolution\fR option. .IP [6] 4 .IX Item "[6]" The Down and Right keys move the slider down (right) by the value of the \fBresolution\fR option. .IP [7] 4 .IX Item "[7]" Control-Up and Control-Left move the slider up (left) by the value of the \fBbigIncrement\fR option. .IP [8] 4 .IX Item "[8]" Control-Down and Control-Right move the slider down (right) by the value of the \fBbigIncrement\fR option. .IP [9] 4 .IX Item "[9]" Home moves the slider to the top (left) end of its range. .IP [10] 4 .IX Item "[10]" End moves the slider to the bottom (right) end of its range. .Sp If the scale is disabled using the \fBstate\fR option then none of the above bindings have any effect. .Sp The behavior of scales can be changed by defining new bindings for individual widgets or by redefining the class bindings. .SH KEYWORDS .IX Header "KEYWORDS" scale, slider, trough, widget