File:  [Micropolis - Activity] / micropolis / src / tk / library / demos / timer
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed Mar 11 09:08:51 2020 UTC (6 years, 4 months ago) by root
Branches: donhopkins, MAIN
CVS tags: activity, HEAD
Micropolis Activity

#!/usr/local/bin/wish -f
#
# This script generates a counter with start and stop buttons.

label .counter -text 0.00 -relief raised -width 10
button .start -text Start -command "set stop 0; tick"
button .stop -text Stop -command {set stop 1}
pack append . .counter {bot fill} .start {left expand fill} \
	.stop {right expand fill}

set seconds 0
set hundredths 0
set stop 0

proc tick {} {
    global seconds hundredths stop
    if $stop return
    after 20 tick
    set hundredths [expr $hundredths+2]
    if {$hundredths >= 100} {
	set hundredths 0
	set seconds [expr $seconds+1]
    }
    .counter config -text [format "%d.%2d" $seconds $hundredths]
}

bind . <Control-c> {destroy .}
bind . <Control-q> {destroy .}
focus .

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.