📄 scale.n
字号:
'\"'\" Copyright (c) 1990-1994 The Regents of the University of California.'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.'\"'\" See the file "license.terms" for information on usage and redistribution'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.'\" '\" SCCS: @(#) scale.n 1.32 97/10/31 12:58:51'\" .so man.macros.TH scale n 4.1 Tk "Tk Built-In Commands".BS'\" Note: do not modify the .SH NAME line immediately below!.SH NAMEscale \- Create and manipulate scale widgets.SH SYNOPSIS\fBscale\fR \fIpathName \fR?\fIoptions\fR?.SO\-activebackground \-font \-highlightthickness \-repeatinterval\-background \-foreground \-orient \-takefocus\-borderwidth \-highlightbackground \-relief \-troughcolor\-cursor \-highlightcolor \-repeatdelay.SE.SH "WIDGET-SPECIFIC OPTIONS".OP \-bigincrement bigIncrement BigIncrementSome interactions with the scale cause its value to change by``large'' increments; this option specifies the size of thelarge increments. If specified as 0, the large increments defaultto 1/10 the range of the scale..OP \-command command CommandSpecifies the prefix of a Tcl command to invoke whenever the scale'svalue is changed via a widget command.The actual command consistsof this option followed by a space and a real number indicating thenew value of the scale..OP \-digits digits DigitsAn integer specifying how many significant digits should be retainedwhen converting the value of the scale to a string.If the number is less than or equal to zero, then the scale picksthe smallest value that guarantees that every possible sliderposition prints as a different string..OP \-from from FromA real value corresponding to the left or top end of the scale..OP \-label label LabelA string to display as a label for the scale. Forvertical scales the label is displayed just to the right of thetop end of the scale. For horizontal scales the label is displayedjust above the left end of the scale. If the option is specifiedas an empty string, no label is displayed..OP \-length length LengthSpecifies 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 scalesit is the scale's width..OP \-resolution resolution ResolutionA real value specifying the resolution for the scale.If this value is greater than zero then the scale's value will always berounded to an even multiple of this value, as will tick marks andthe endpoints of the scale. If the value is less than zero then norounding occurs. Defaults to 1 (i.e., the value will be integral)..OP \-showvalue showValue ShowValueSpecifies a boolean value indicating whether or not the currentvalue of the scale is to be displayed..OP \-sliderlength sliderLength SliderLengthSpecfies the size of the slider, measured in screen units along the slider'slong dimension. The value may be specified in any of the forms acceptableto \fBTk_GetPixels\fR..OP \-sliderrelief sliderRelief SliderReliefSpecifies the relief to use when drawing the slider, such as \fBraised\fRor \fBsunken\fR..OP \-state state StateSpecifies 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 scalewon't activate.If the scale is active, the slider is displayed using the colorspecified by the \fBactiveBackground\fR option..OP \-tickinterval tickInterval TickIntervalMust be a real value.Determines the spacing between numericaltick marks displayed below or to the left of the slider.If 0, no tick marks will be displayed..OP \-to to ToSpecifies a real value correspondingto the right or bottom end of the scale.This value may be either less than or greater than the \fBfrom\fR option..OP \-variable variable VariableSpecifies the name of a global variable to link to the scale. Whenever thevalue of the variable changes, the scale will update to reflect thisvalue.Whenever the scale is manipulated interactively, the variablewill be modified to reflect the scale's new value..OP \-width width WidthSpecifies 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 scalesthis is the trough's height..BE.SH DESCRIPTION.PPThe \fBscale\fR command creates a new window (given by the\fIpathName\fR argument) and makes it into a scale widget.Additionaloptions, described above, may be specified on the command lineor in the option databaseto configure aspects of the scale such as its colors, orientation,and relief. The \fBscale\fR command returns its\fIpathName\fR argument. At the time this command is invoked,there must not exist a window named \fIpathName\fR, but\fIpathName\fR's parent must exist..PPA scale is a widget that displays a rectangular \fItrough\fR and asmall \fIslider\fR. The trough corresponds to a rangeof 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 adjustedwith the mouse or keyboard as described in the BINDINGSsection below. Whenever the scale's value is changed, a Tclcommand is invoked (using the \fBcommand\fR option) to notifyother interested widgets of the change.In addition, the valueof the scale can be linked to a Tcl variable (using the \fBvariable\fRoption), so that changes in either are reflected in the other..PPThree annotations may be displayed in a scale widget: a labelappearing at the top right of the widget (top left for horizontalscales), a number displayed just to the left of the slider(just above the slider for horizontal scales), and a collectionof numerical tick marks just to the left of the current value(just below the trough for horizontal scales). Each of these threeannotations may be enabled or disabled using theconfiguration options..SH "WIDGET COMMAND".PPThe \fBscale\fR command creates a new Tcl command whosename is \fIpathName\fR. Thiscommand may be used to invoke variousoperations on the widget. It has the following general form:.CS\fIpathName option \fR?\fIarg arg ...\fR?.CE\fIOption\fR and the \fIarg\fRsdetermine the exact behavior of the command. The followingcommands are possible for scale widgets:.TP\fIpathName \fBcget\fR \fIoption\fRReturns the current value of the configuration option givenby \fIoption\fR.\fIOption\fR may have any of the values accepted by the \fBscale\fRcommand..TP\fIpathName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR?Query or modify the configuration options of the widget.If no \fIoption\fR is specified, returns a list describing all ofthe available options for \fIpathName\fR (see \fBTk_ConfigureInfo\fR forinformation on the format of this list). If \fIoption\fR is specifiedwith no \fIvalue\fR, then the command returns a list describing theone named option (this list will be identical to the correspondingsublist of the value returned if no \fIoption\fR is specified). Ifone or more \fIoption\-value\fR pairs are specified, then the commandmodifies the given widget option(s) to have the given value(s); inthis case the command returns an empty string.\fIOption\fR may have any of the values accepted by the \fBscale\fRcommand..TP\fIpathName \fBcoords \fR?\fIvalue\fR?Returns a list whose elements are the x and y coordinates ofthe point along the centerline of the trough that correspondsto \fIvalue\fR.If \fIvalue\fR is omitted then the scale's current value is used..TP\fIpathName \fBget\fR ?\fIx y\fR?If \fIx\fR and \fIy\fR are omitted, returns the current valueof the scale. If \fIx\fR and \fIy\fR are specified, they givepixel coordinates within the widget; the command returnsthe 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..TP\fIpathName \fBidentify\fR \fIx y\fRReturns a string indicating what part of the scale lies underthe coordinates given by \fIx\fR and \fIy\fR.A return value of \fBslider\fR means that the point is overthe slider; \fBtrough1\fR means that the point is over theportion of the slider above or to the left of the slider;and \fBtrough2\fR means that the point is over the portionof the slider below or to the right of the slider.If the point isn't over one of these elements, an empty stringis returned..TP\fIpathName \fBset\fR \fIvalue\fRThis command is invoked to change the current value of the scale,and hence the position at which the slider is displayed. \fIValue\fRgives the new value for the scale.The command has no effect if the scale is disabled..SH BINDINGS.PPTk automatically creates class bindings for scales that give themthe following default behavior.Where the behavior is different for vertical and horizontal scales,the horizontal behavior is described in parentheses..IP [1]If button 1 is pressed in the trough, the scale's value willbe incremented or decremented by the value of the \fBresolution\fRoption so that the slider moves in the direction of the cursor. If the button is held down, the action auto-repeats..IP [2]If button 1 is pressed over the slider, the slider can be draggedwith the mouse..IP [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 thedirection towards the mouse cursor..IP [4]If button 2 is pressed, the scale's value is set to the mouseposition. If the mouse is dragged with button 2 down, the scale'svalue changes with the drag..IP [5]The Up and Left keys move the slider up (left) by the valueof the \fBresolution\fR option..IP [6]The Down and Right keys move the slider down (right) by the valueof the \fBresolution\fR option..IP [7]Control-Up and Control-Left move the slider up (left) by thevalue of the \fBbigIncrement\fR option..IP [8]Control-Down and Control-Right move the slider down (right) by thevalue of the \fBbigIncrement\fR option..IP [9]Home moves the slider to the top (left) end of its range..IP [10]End moves the slider to the bottom (right) end of its range..PPIf the scale is disabled using the \fBstate\fR option thennone of the above bindings have any effect..PPThe behavior of scales can be changed by defining new bindings forindividual widgets or by redefining the class bindings..SH KEYWORDSscale, slider, trough, widget
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -