Version 0 of Scrolling Widgets With a Scale

Updated 2001-11-05 23:53:13

GPS Mon Nov 5, 2001 - at the Tcl 9.0 WishList MCL asked about adding the ability to scroll widgets with the scale widget. So, I wrote this code as an example.


#!/bin/wish8.3

set busy 0

proc moveScale {args} {

        if {$::busy == 1} {
                return
        }
        set yview [lindex $args 0]
        .s set [expr {int($yview * 100)}]

}

proc scrollWidget {y} {

        set ::busy 1
        set yview [expr {double($y) / 100.0}]
        .l yview moveto $yview
        update idletasks
        set ::busy 0

}

proc main {} {

        pack [listbox .l -yscrollcommand moveScale] -side right -fill both -expand 1
        pack [scale .s -tickinterval 0 -from 0 -to 100 -showvalue 0 \
                -command scrollWidget
        ] -side left -fill y

        for {set i 0} {$i < 400} {incr i} {
                .l insert end [expr {rand() * 40}]
        }

} main