Last change
on this file was
37,
checked in by (none), 14 years ago
|
Added original make3d
|
-
Property svn:executable set to
*
|
File size:
1.1 KB
|
Line | |
---|
1 | #!/bin/sh |
---|
2 | # the next line restarts using wish \ |
---|
3 | exec wish8.4 "$0" "$@" |
---|
4 | |
---|
5 | # timer -- |
---|
6 | # This script generates a counter with start and stop buttons. |
---|
7 | # |
---|
8 | # RCS: @(#) $Id: timer,v 1.3 2001/10/29 16:23:33 dkf Exp $ |
---|
9 | |
---|
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 |
---|
18 | } |
---|
19 | } |
---|
20 | button .stop -text Stop -state disabled -command { |
---|
21 | set stopped 1 |
---|
22 | .stop configure -state disabled |
---|
23 | .start configure -state normal |
---|
24 | } |
---|
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 |
---|
28 | |
---|
29 | set startMoment {} |
---|
30 | |
---|
31 | set stopped 1 |
---|
32 | |
---|
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}]] |
---|
39 | } |
---|
40 | |
---|
41 | bind . <Control-c> {destroy .} |
---|
42 | bind . <Control-q> {destroy .} |
---|
43 | focus . |
---|
44 | |
---|
45 | # Local Variables: |
---|
46 | # mode: tcl |
---|
47 | # End: |
---|
Note: See
TracBrowser
for help on using the repository browser.