stopwatch-3.4/HISTORY010066400236350007756000000055121013753055300146460ustar00libesmsid00003600000025This is the HISTORY file for stopwatch. Date Version Description ------- ------- ------------------------------------------------------ 10/26/04 3.5 Made keyboard shortcuts orthogonal and added shortcuts to the help. 6/23/04 3.4 At request of Michel Bellemare , added keyboard bindings for all buttons. 9/6/03 3.3 Made zero button work even when clock is running. Made shift-zero or shift-record do "record and log" to support functionality of a real stopwatch. 6/30/03 3.2 Added support for "Select All". 6/17/03 3.1 Added support to enable/disable milliseconds from menu. 5/6/03 3.0 Added code to countdown and stop at zero. Added menus to support this configuration. Added help. Just about doubled size of overall script. Was 211, is 416! 7/11/02 2.6 Bernhard Kuemel noted stopwatch no longer worked in non-msec mode. 5/14/02 2.5 Vertical expansion of widgets wasn't working properly. Fixed. 1/28/02 2.4.1 Make code more readable. 1/25/02 2.4 Noted that hours overflowed at 596. Fixed it so that if millisecond timing is turned off, the additional bits are given back so that additional hours can be tracked. Added binding for Return to start/stop the clock. 1/24/02 2.3 Further cleaned up the code and display. 1/23/02 2.2 Mark Saye pointed out a bug and suggested the whole implementation was unnecessarily complex. He was right. There's no need to sync the msec and second clocks because the msec clock has enough bits. 1/22/02 2.1 Ben Blackhawk noted that new version broke in the browser. Added a test for tclversion so that it disables millisecond code if running in an older version. 1/17/02 2.0 Rich Biolnick asked for millisecond timing and I started fiddling and a couple hours later had it done. It was mildly unpleasant because Tcl doesn't provide access to absolute msec time. There is a msec timer but it's relative so you have to establish synchrony between the two timers yourself. Also worked on display - to make it expand the log when the user expands the window. It's almost right. But there's still a bug in the grid propagation code which I haven't tracked down. 6/12/00 1.2 Angel De Vicente added a simple log. Rewrote log to be more generic (log either time at any time) and made it able to do splits like a real stopwatch. Added autoselection. Adjusted fonts after realizing that courier really wasn't necessary for formatting (and is horribly ugly). Added some color highlights. 3/31/98 1.1 Dave Marquardt found typo which caused mishandling of hours. 4/8/01 1.2 Liebrecht reported failure in the plugin because tk_setPalette tries to create a toplevel. stopwatch-3.4/README010066400236350007756000000014400742204314200144320ustar00libesmsid00003600000025This is the README file for stopwatch, a program that implements a stopwatch. I wrote it to help me time talks or individual slides within a talk. For that purpose, it works well. -------------------- To Install -------------------- See the install instructions at http://expect.nist.gov/stopwatch/#install -------------------- To Use -------------------- See the directions at http://expect.nist.gov/stopwatch/#directions -------------------- Systems Supported -------------------- Stopwatch should work on any system that supports Tk 8.3 or later. For earlier versions, see: http://expect.nist.gov/stopwatch -------------------- Author -------------------- Don Libes National Institute of Standards and Technology Bldg 220, Rm A-127 Gaithersburg, MD 20899 (301) 975-3535 libes@nist.gov stopwatch-3.4/Makefile010066400236350007756000000016151006632747600152330ustar00libesmsid00003600000025VERSION = 3.4 FTPDIR = /proj/itl/www/div826/subject/expect/stopwatch install: # There's nothing to install! Simply run stopwatch! stopwatch-$(VERSION).tar: rm -f ../stopwatch-$(VERSION) ln -s `pwd` ../stopwatch-$(VERSION) cd ..;tar cvfh $@ `pubfile stopwatch-$(VERSION)` mv ../$@ . stopwatch-$(VERSION).tar.gz: stopwatch-$(VERSION).tar gzip -fc stopwatch-$(VERSION).tar > $@ stopwatch.tcl.html: stopwatch echo '' > stopwatch.tcl.html cat stopwatch >> stopwatch.tcl.html echo '' >> stopwatch.tcl.html # make a release and install it on ftp server ftp: stopwatch-$(VERSION).tar.gz stopwatch.tcl.html cp index.html tclet.html README HISTORY stopwatch.tcl.html $(FTPDIR) cp stopwatch-$(VERSION).tar.gz $(FTPDIR)/stopwatch.tar.gz cp stopwatch $(FTPDIR)/stopwatch.tcl cp stopwatch1.2 $(FTPDIR)/ cp stopwatch.gif $(FTPDIR) rm stopwatch-$(VERSION).tar* ls -l $(FTPDIR)/stopwatch.tar* stopwatch-3.4/index.html010066400236350007756000000067641013753226300155710ustar00libesmsid00003600000025Stopwatch Home Page

The Stopwatch Home Page

Description

Stopwatch does what its name implies - enables hand timing much like a physical stopwatch. It can also be used as a countdown timer.

Stopwatch has millisecond accuracy and no artificial limit on hours. Stopwatch runs on UNIX, Windows, and MacOS.

Stopwatch normally runs as a standalone program. To run it this way, download and install it. You can also run stopwatch inside the browser, if you have the Tcl plugin.

Directions

Press "start" to start the stopwatch and "stop" to stop it. "record" records the current time and selects it so that it can readily be pasted into other programs. Recorded times are marked with an L for "lap" or T for "total". When stopped, you can cut/paste/edit the time by hand and set it to any valid time. "zero" resets the time to zero. Holding down the shift key while pressing record or zero, records and then zeros the time.

Time moves forward or backward according to the Run menu. By default, time is stopped automatically when either the lap or total time reaches zero. To disable the automatic stop, unselect Run -> Stop At Zero.

Download

source This single file is all you really need.
complete distribution A full distribution for people who want the README, HISTORY, and other unnecessary stuff.

Installation

There is no installation step (such as "configure" or "Make"). Once downloaded, simply run stopwatch with wish or any Tk-enabled interpreter. If you're unfamiliar with wish or Tk, download the Tcl/Tk distribution from the Tcl Developer Xchange.

Version

This page describes stopwatch version 3.5.

Price

Stopwatch is free.

Copy and Reuse Information

Stopwatch is in the public domain.

Caveats

Stopwatch requires Tcl/Tk 7.5 or later. Millisecond timing is available when using Tcl 8.3 or later.

By default, the maximum time is just over 596 hours (about 25 days). The range may be increased (to about 68 years) by disabling the millisecond timer. To disable the millisecond timer, unselect Run -> Milliseconds.

Contact Info

Don Libes, libes@nist.gov
National Institute of Standards and Technology
100 Bureau Drive, Stop 8264
Gaithersburg, MD 20899-8264
USA


Names of companies and products, and links to commercial pages are provided in order to adequately specify procedures and equipment used. In no case does such identification imply recommendation or endorsement by the National Institute of Standards and Technology, nor does it imply that the products are necessarily the best available for the purpose.
Last modified: Thu Mar 18 12:25:44 EST 2004
href="#downlstopwatch-3.4/stopwatch010075500236350007756000000354721013753031400155250ustar00libesmsid00003600000025#!/depot/path/wish -f ###################################################################### # Name: Stopwatch # Author: Don Libes # Date first released: 9/26/96 # Description: Stopwatch is a tool for hand timing, such as timing how # long a talk or part of a talk takes. See the home page for more # details. # set version 3.5 set versionDate 2004/6/23 # For the latest version: http://expect.nist.gov/stopwatch ###################################################################### ###################################################################### # User-settable features ###################################################################### catch { ;# allow it to run in a browser tk_setPalette #dfd5e7 ;# touch of lavender } set time(startColor) #009900 ;# medium green set time(stopColor) #ff0000 ;# red set time(msecShow) 1 ;# To disable millisecond timing, set to 0. ;# Not much reason to do this unless you ;# find the millisecond display distracting ;# or you're timing for more than 24 days. ;# If the version of Tcl that you're using ;# doesn't support millisecond timing, then ;# this option will be disabled automatically. set time(forward) 1 ;# runs backward when 0 set time(stopAtZero) 1 ;# to use in countdown mode option add *Entry.font {Times 18} ###################################################################### # End of user-settable features ###################################################################### proc stop {} { global time .startstop config -text start -command start .startstop config -foreground $time(startColor) \ -activeforeground $time(startColor) .m.r entryconfigure $::menuStartStopIndex \ -foreground $time(startColor) \ -activeforeground $time(startColor) \ -label Start \ -command start .m.r entryconfigure $::menuMsecIndex -state normal .m.r entryconfigure $::menuForwardIndex -state normal .m.r entryconfigure $::menuBackwardIndex -state normal if {![info exists time(tickId)]} return after cancel $time(tickId) unset time(tickId) } proc start {} { global time if {[catch {timescan time(total)} time(tstart,relative)]} return if {[catch {timescan time(lap)} time(lstart,relative)]} return .startstop config -text stop -command stop .startstop config -foreground $time(stopColor) \ -activeforeground $time(stopColor) .m.r entryconfigure $::menuStartStopIndex \ -foreground $time(stopColor) \ -activeforeground $time(stopColor) \ -label Stop \ -command stop .m.r entryconfigure $::menuMsecIndex -state disabled .m.r entryconfigure $::menuForwardIndex -state disabled .m.r entryconfigure $::menuBackwardIndex -state disabled set now [now] if {$time(forward)} { set time(tstart) [expr {$now - $time(tstart,relative)}] set time(lstart) [expr {$now - $time(lstart,relative)}] } else { set time(tstart) [expr {$now + $time(tstart,relative)}] set time(lstart) [expr {$now + $time(lstart,relative)}] } # start the clock ticking tick } # configure millisecond support according to the setting of time(msecShow) proc msecConfig {} { global time # If millisecond time requested, try it out first and if it doesn't # work, fall back to single-second timing. if {$time(msecShow) && (0 == [catch {clock clicks -milliseconds}])} { proc now {} {clock clicks -milliseconds} } else { proc now {} {clock seconds} set time(msecShow) 0 } # By using either msecs or secs as the underlying quantum, we can get # accuracy where we want it. if {$time(msecShow)} { set time(msecsPerTick) 1 set time(ticksPerSec) 1000 set time(ticksPerMin) 60000 set time(ticksPerHr) 3600000 } else { set time(msecsPerTick) 1000 set time(ticksPerSec) 1 set time(ticksPerMin) 60 set time(ticksPerHr) 3600 } } msecConfig # tick is called every so often to update the clock. proc tick {} { global time set now [now] set stop 0 if {$::time(forward)} { set ttime [expr {$now - $time(tstart)}] set ltime [expr {$now - $time(lstart)}] if {$time(stopAtZero)} { # time has passed zero crossing, so adjust both counters # so at least one of them shows perfect zero and the other # is adjusted by the difference. if {(($time(tstart,relative) < 0) && ($ttime >= 0))} { incr ltime [expr {-$ttime}] set ttime 0 set stop 1 } elseif {(($time(lstart,relative) < 0) && ($ltime >= 0))} { incr ttime [expr {-$ltime}] set ltime 0 set stop 1 } } } else { set ttime [expr {$time(tstart) - $now}] set ltime [expr {$time(lstart) - $now}] if {$time(stopAtZero)} { # time has passed zero crossing, so adjust both counters # so at least one of them shows perfect zero and the other # is adjusted by the difference. if {(($time(tstart,relative) > 0) && ($ttime <= 0))} { incr ltime [expr {-$ttime}] set ttime 0 set stop 1 } elseif {(($time(lstart,relative) > 0) && ($ltime <= 0))} { incr ttime [expr {-$ltime}] set ltime 0 set stop 1 } } } set time(total) [timeformat $ttime] set time(lap) [timeformat $ltime] if {$stop} { stop bell } else { set time(tickId) [after $time(msecsPerTick) tick] } } # parse displayed time proc timescan {timevar} { upvar $timevar timetext global time # possible sign regexp ^(-)?(.*) $timetext x sign timetext # accept user-supplied time with or without msec if {4 != [scan $timetext %d:%d:%d.%d hr min sec msec]} { set msec 0 if {3 != [scan $timetext %d:%d:%d hr min sec]} { set timetext "what?" error "conversion error" } } if {!$time(msecShow)} { set msec 0 } set ticks [expr {(($hr*60 + $min)*60 + $sec)*$time(ticksPerSec) + $msec}] if {$sign == "-"} { set ticks [expr {0 - $ticks}] } return $ticks } # format time for display proc timeformat {ticks} { global time if {$ticks < 0} { set sign "-" set ticks [expr {abs($ticks)}] } else { set sign "" } set r $sign[format %03d:%02d:%02d \ [expr { $ticks /$time(ticksPerHr) }] \ [expr {($ticks % $time(ticksPerHr) )/$time(ticksPerMin)}] \ [expr {($ticks % $time(ticksPerMin))/$time(ticksPerSec)}]] if {$time(msecShow)} { append r [format ".%03d" [expr {$ticks % 1000}]] } return $r } proc record {type time} { .record.t tag remove sel 1.0 end .record.t insert 1.0 "$type $time$::recordeol" .record.t tag add sel 1.2 1.end .record.t see 1.0 # add newlines after every record but the first set ::recordeol "\n" } set recordeol "" ######################################################################## # Mostly widget layout stuff after this point. ######################################################################## # Allow enough display space for "hhh:mm:ss.mmm" These don't literally # add up because less space is taken by punctuation. option add *Entry.width 12 label .totallabel -text "total:" -anchor e entry .totaltime -textvar time(total) button .totalzero -text "zero" -command { set time(total) [timeformat 0] .lapzero invoke set time(tstart) [now] ;# if clock running, this needs to be updated } button .totalrecord -text "record" -command { record T $time(total) } proc totalzr {} { .totalrecord invoke .totalzero invoke } bind .totalzero {totalzr; break} bind .totalrecord {totalzr; break} label .laplabel -text "lap:" -anchor e entry .laptime -textvar time(lap) button .lapzero -text "zero" -command { set time(lap) [timeformat 0] set time(lstart) [now] ;# if clock running, this needs to be updated } button .laprecord -text "record" -command { record L $time(lap) } proc lapzr {} { .laprecord invoke .lapzero invoke } bind .lapzero {lapzr; break} bind .laprecord {lapzr; break} button .startstop -text start -command start \ -foreground $time(startColor) \ -activeforeground $time(startColor) frame .record scrollbar .record.sb -command {.record.t yview} text .record.t -height 5 -width 10 -yscroll {.record.sb set} button .record.clear -text clear -command {.record.t delete 1.0 end} grid .totallabel .totaltime .totalrecord .totalzero grid configure .totallabel -sticky e grid configure .totaltime -sticky ns grid .laplabel .laptime .laprecord .lapzero grid configure .laplabel -sticky e grid configure .laptime -sticky ns grid .startstop -columnspan 4 -sticky ew grid .record -columnspan 4 -sticky nsew grid .record.sb -column 0 -row 0 -sticky ns grid .record.t -column 1 -row 0 -sticky nsew grid .record.clear -column 2 -row 0 -sticky ns grid columnconfigure . 0 -weight 1 grid rowconfigure . 3 -weight 1 grid columnconfigure .record 1 -weight 1 grid rowconfigure .record 0 -weight 1 ######################################## # miscellaneous other things of interest to the UI ######################################## proc about {} { # tk_messageBox -message "Stopwatch $::version by Don Libes " set w .about if {[winfo exists $w]} { wm deiconify $w raise $w return } toplevel $w wm title $w "about stopwatch" wm iconname $w "about stopwatch" wm resizable $w 0 0 button $w.b -text Dismiss -command [list wm withdraw $w] label $w.title -text "Stopwatch" -font "Times 16" -borderwidth 10 -fg red label $w.version -text "Version $::version, Released $::versionDate" label $w.author -text "Written by Don Libes " label $w.using -text "Using Tcl $::tcl_patchLevel,\ Tk $::tk_patchLevel" grid $w.title grid $w.version grid $w.author grid $w.using grid $w.b -sticky ew } proc help {} { if {[winfo exists .help]} { destroy .help return } toplevel .help wm title .help "Stopwatch help" wm iconname .help "Stopwatch help" scrollbar .help.sb -command {.help.text yview} text .help.text -width 80 -height 30 -yscroll {.help.sb set} -wrap word button .help.ok -text "OK" -command {destroy .help} -relief raised bind .help {destroy .help;break} grid .help.sb -row 0 -column 0 -sticky ns grid .help.text -row 0 -column 1 -sticky nsew grid .help.ok -row 1 -columnspan 2 -sticky ew -padx 2 -pady 2 # let text box only expand grid rowconfigure .help 0 -weight 1 grid columnconfigure .help 1 -weight 1 .help.text tag configure h1 -foreground #008000 .help.text insert end "Stopwatch $::version - by Don Libes " h1 .help.text insert end { Stopwatch does what its name implies - enables hand timing much like a physical stopwatch. Stopwatch can also countdown like a timer. Stopwatch runs on UNIX, Windows, and MacOS. Stopwatch may run as a traditional program or in a browser. } .help.text insert end "Directions" h1 .help.text insert end { Press "start" to start timing and "stop" to stop it. "record" records the current time and selects it so that it can readily be pasted into other programs. Recorded times are marked with an L for "lap" or T for "total". When stopped, you can cut/paste/edit the time by hand and set it to any valid time. "zero" resets the time to zero. Time moves forward or backward according to the Run menu. By default, time stops automatically when either the lap or total time reaches zero. To disable the automatic stop, unselect Run -> Stop At Zero. } .help.text insert end "Shortcuts" h1 .help.text insert end " zeros the lap time. zeros the total time. resets the lap time. resets the total time. starts/stops the time. clears the recorded times. Holding down the control key while pressing the record or zero buttons/keys, records and then zeros the time. " .help.text insert end "Caveats" h1 .help.text insert end { Stopwatch requires Tcl/Tk. Millisecond timing is only available when using Tcl 8.3 or later. By default, the maximum time is just over 596 hours (about 25 days). The range may be increased (to about 68 years) by disabling the millisecond timer. To disable the millisecond timer, select Run => Milliseconds (or edit the source to change it permanently.) By default, the "Stop At Zero" action is a bell. To change this, edit the source and redefine the "bell" procedure as desired.} } ###################################################################### # set up menu bar ###################################################################### menu .m -tearoff 0 .m add cascade -menu .m.f -label "File" -underline 0 .m add cascade -menu .m.e -label "Edit" -underline 0 .m add cascade -menu .m.r -label "Run" -underline 0 .m add cascade -menu .m.help -label "Help" -underline 0 menu .m.f menu .m.e menu .m.r menu .m.help .m.f add command -label "Exit" -command exit .m.e add command -label "Cut" -command {event generate [selection own] <>} .m.e add command -label "Copy" -command {event generate [selection own] <>} .m.e add command -label "Paste" -command {event generate [selection own] <>} .m.e add command -label "Clear" -command {selection clear} .m.e add command -label "Select All" -command {selectAll} proc selectAll {} { set w [focus] if {$w == "."} { # if no focus, use recording area set w .record.t } switch [winfo class $w] { "Text" { $w tag remove sel 0.0 end $w tag add sel 1.0 end } "Entry" { $w selection range 0 end } } } # Note that changes to this menu may impact the indexes below which # are manually calculated. .m.r add command -label "Start" -command start .m.r add checkbutton -label "Stop At Zero" -variable time(stopAtZero) .m.r add checkbutton -label "Milliseconds" -variable time(msecShow) -command msecConfig .m.r add radio -label "Forward" -variable time(forward) -value 1 .m.r add radio -label "Backward" -variable time(forward) -value 0 set menuStartStopIndex 1 set menuMsecIndex 3 set menuForwardIndex 4 set menuBackwardIndex 5 .m.r entryconfigure $::menuStartStopIndex \ -foreground $time(startColor) \ -activeforeground $time(startColor) .m.help add command -label "About" -command about .m.help add command -label "Help" -command help . config -m .m .totalzero invoke bind all {.startstop invoke} bind all {.record.clear invoke} bind all {.laprecord invoke} ; bind all {lapzr} bind all {.totalrecord invoke} ; bind all {totalzr} bind all {.lapzero invoke} ; bind all {lapzr} bind all {.totalzero invoke} ; bind all {totalzr} nversion error" } } if {!$time(msecShow)} { set msec 0 } set ticks [expr {(($hr*60 + $min)*60 + $sec)*$time(ticksPerSec) + $msec}] if {$sign == "-"} { set ticks [expr {0 - $