]> git.zerfleddert.de Git - micropolis/blame_incremental - src/tk/library/demos/timer
XINCLUDE: use /usr/X11R6/include everywhere
[micropolis] / src / tk / library / demos / timer
... / ...
CommitLineData
1#!/usr/local/bin/wish -f
2#
3# This script generates a counter with start and stop buttons.
4
5label .counter -text 0.00 -relief raised -width 10
6button .start -text Start -command "set stop 0; tick"
7button .stop -text Stop -command {set stop 1}
8pack append . .counter {bot fill} .start {left expand fill} \
9 .stop {right expand fill}
10
11set seconds 0
12set hundredths 0
13set stop 0
14
15proc tick {} {
16 global seconds hundredths stop
17 if $stop return
18 after 20 tick
19 set hundredths [expr $hundredths+2]
20 if {$hundredths >= 100} {
21 set hundredths 0
22 set seconds [expr $seconds+1]
23 }
24 .counter config -text [format "%d.%2d" $seconds $hundredths]
25}
26
27bind . <Control-c> {destroy .}
28bind . <Control-q> {destroy .}
29focus .
Impressum, Datenschutz