Previous: Text widgets
Up: Widgets
Next: Frame and Toplevel widgets
Previous Page: Text widgets
Next Page: Frame and Toplevel widgets
Scale widgets allow direct data entry of numerical data, by means of a slider. The following example creates a scale widget, and a label, and the value set by the scale widget is displayed in the label. The scale is set to show an initial value.
#Make a scale, oriented vertically, going down from 50 to 0. #Tick marks are places alongside the scale every 10 units. scale .scale1 -width 10 -orient vertical -length 280 -from 50 -to 0 -command "set var1" -tickinterval 10 -relief raisedlabel .lab1 -width 10 -textvariable var1 -relief sunken pack .scale1 .lab1 -padx 1m -pady 2m -fill x
#Now set the value of scale to 25 using a widget command .scale1 set 25