1 #!/usr/local/bin/wish -f
 
   3 # This script generates a counter with start and stop buttons.
 
   5 label .counter -text 0.00 -relief raised -width 10
 
   6 button .start -text Start -command "set stop 0; tick"
 
   7 button .stop -text Stop -command {set stop 1}
 
   8 pack append . .counter {bot fill} .start {left expand fill} \
 
   9         .stop {right expand fill}
 
  16     global seconds hundredths stop
 
  19     set hundredths [expr $hundredths+2]
 
  20     if {$hundredths >= 100} {
 
  22         set seconds [expr $seconds+1]
 
  24     .counter config -text [format "%d.%2d" $seconds $hundredths]
 
  27 bind . <Control-c> {destroy .}
 
  28 bind . <Control-q> {destroy .}