Track /etc/gitconfig
[msysgit/mtrensch.git] / mingw / lib / tk8.4 / demos / timer
blob5255403d3a59f7fec0f57039849036a7b8ae335c
1 #!/bin/sh
2 # the next line restarts using wish \
3 exec wish "$0" "$@"
5 # timer --
6 # This script generates a counter with start and stop buttons.
8 # RCS: @(#) $Id: timer,v 1.3 2001/10/29 16:23:33 dkf Exp $
10 label .counter -text 0.00 -relief raised -width 10 -padx 2m -pady 1m
11 button .start -text Start -command {
12 if {$stopped} {
13 set stopped 0
14 set startMoment [clock clicks -milliseconds]
15 tick
16 .stop configure -state normal
17 .start configure -state disabled
20 button .stop -text Stop -state disabled -command {
21 set stopped 1
22 .stop configure -state disabled
23 .start configure -state normal
25 pack .counter -side bottom -fill both
26 pack .start -side left -fill both -expand yes
27 pack .stop -side right -fill both -expand yes
29 set startMoment {}
31 set stopped 1
33 proc tick {} {
34 global startMoment stopped
35 if {$stopped} {return}
36 after 50 tick
37 set elapsedMS [expr {[clock clicks -milliseconds] - $startMoment}]
38 .counter config -text [format "%.2f" [expr {double($elapsedMS)/1000}]]
41 bind . <Control-c> {destroy .}
42 bind . <Control-q> {destroy .}
43 focus .
45 # Local Variables:
46 # mode: tcl
47 # End: