Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

counter

Status
Not open for further replies.

sl1200mk2

Technical User
Jun 7, 2005
39
FR
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
}
}
 
Status
Not open for further replies.

Similar threads

Replies
1
Views
41

Part and Inventory Search

Sponsor

Back
Top