Version 0 of Scale widget

Updated 2005-08-26 06:38:42 by WJP

#This provides an addition to the default methods of the scale #widget. The default method, bound to <B1>, #increments or decrements #the value by the resolution, by default 1. If you want a larger #increment, you can use a larger resolution, but sometimes it is

 By default the value of a scale widget is changed either

by dragging the slider or by left-clicking in the trough. The increment by which the left-click changes is the same as the resolution, by default one unit. You can increase the increment by which a click moves by increasing the resolution value (which decreases the resolution in the normal sense). However, sometimes it is convenient to have a finer resolution available while also being able to move in larger increments. A solution is to bind to <B3>, or some other event if you wish, a larger movement. This procedure moves by the specified multiplier k times the resolution of the scale.

 proc ScaleMoveBigIncrement {w k x y} {
    set part [$w identify $x $y]
    switch -exact -- $part {
        trough1 {
            set dir -1;
        }
        trough2 {
            set dir  1;
        }
    }
    set Resolution [$w cget -resolution]
    set CurrentValue [$w get]
    set Delta [expr $dir * $k * $Resolution]
    $w set [expr $CurrentValue + $Delta]
 }

The coordinates x and y are supplied by Tk when the binding is triggered. w and k are, from the point of view of the individual binding, constants. They represent the scale widget and the desired resolution multiplier. You supply them when you create the bindng. A typical binding might look like this:

 bind .play.vol <<B3>> {ScaleMoveBigIncrement .play.vol 5 %x %y}

WJP