hi there
i would like to use the following counter proc for many scales.
it works for one but how can i do for several ones....
the spinbox value is the time of counting in ms
any idea?
many thanks
nicolas
#!/bin/sh
wm title . "go"
namespace eval var {
variable valp ""
variable vals ""
variable tps ""
variable result ""
}
pack [scale .s -variable count -from 100 -to 0 -bg red -relief flat -command {lset var::vals} ] -side left
pack [scale .p -variable valp -from 100 -to 0 -bg green -relief flat -command {lset var::valp} ] -side left
pack [spinbox .sp -textvariable tps -from 0 -to 100000 -command { lset var::tps $tps }] -side left
bind .sp <Return> { lset var::tps $tps ; focus -force . }
pack [button .b -text "go" -command play ] -side left
proc play {} {
lset var::vals [.s get]
lset var::result $var::vals
countdown $var::valp $var::tps
}
proc countdown {cnt temp} {
set ::count $var::result
if {$cnt < $var::result} {
incr var::result -1
after [expr ($temp / abs($cnt-$var::vals))] [list countdown $cnt $temp]
} elseif {$cnt > $var::result} {
incr var::result +1
after [expr ($temp / abs($cnt-$var::vals))] [list countdown $cnt $temp]
}
if {$var::result == $cnt } {
lset var::vals $var::result
return
}
}
i would like to use the following counter proc for many scales.
it works for one but how can i do for several ones....
the spinbox value is the time of counting in ms
any idea?
many thanks
nicolas
#!/bin/sh
wm title . "go"
namespace eval var {
variable valp ""
variable vals ""
variable tps ""
variable result ""
}
pack [scale .s -variable count -from 100 -to 0 -bg red -relief flat -command {lset var::vals} ] -side left
pack [scale .p -variable valp -from 100 -to 0 -bg green -relief flat -command {lset var::valp} ] -side left
pack [spinbox .sp -textvariable tps -from 0 -to 100000 -command { lset var::tps $tps }] -side left
bind .sp <Return> { lset var::tps $tps ; focus -force . }
pack [button .b -text "go" -command play ] -side left
proc play {} {
lset var::vals [.s get]
lset var::result $var::vals
countdown $var::valp $var::tps
}
proc countdown {cnt temp} {
set ::count $var::result
if {$cnt < $var::result} {
incr var::result -1
after [expr ($temp / abs($cnt-$var::vals))] [list countdown $cnt $temp]
} elseif {$cnt > $var::result} {
incr var::result +1
after [expr ($temp / abs($cnt-$var::vals))] [list countdown $cnt $temp]
}
if {$var::result == $cnt } {
lset var::vals $var::result
return
}
}