Version 3 of iLogWatch

Updated 2003-10-27 19:56:35

http://mywebpages.comcast.net/jakeforce/iLogWatch.jpg if {0} {

by Michael Jacobson

iLogWatch is my updated to RS's A little stopwatch application. With the addition of a message window and a comment box that allows you to log events while using the stopwatch. I plan on using this programs at swim meets where I usually have paper and a stopwatch handy.

This application was developed for my PocketPC but the current port of the TclTk does not work well enough to run this application (hopefully some day it will).}

 entry .e1
 eval [concat font create Time "[font actual [.e1 cget -font]] -size 12 -weight bold"]
 destroy .e1
 #----- button and Time
 frame .b
 button .b.start -text Start -command {eval \[.b.start cget -text\]} -bg green -width 5 -font Time
 label  .b.time -textvar time -width 12 -bg black -fg green -font Time
 set time 00:00:00.00
 button .b.split -text Split -command Split -state disable -bg SystemButtonFace -width 5 -font Time
 pack .b.start .b.time .b.split -side left -fill y
 pack .b -side top -fill y -expand 1
 #----- Comment label and entry
 frame .c
 label .c.comm -text Comments -width 9 
 entry .c.mess -width 30 -textvariable Mess
 pack .c.comm .c.mess -side left -fill y -expand 1
 pack .c -side top -fill y -expand 1
 bind .c.mess  <KeyPress-Return> Comment 
 focus .c.mess
 #----- Log window
 frame .a
 scrollbar .a.y -command ".a.t yview"
 text .a.t -yscrollc ".a.y set" -wrap word -font {Tahoma 8} -padx 2 -pady 3 -borderwidth 0 -takefocus 0
 pack .a.y -side right -fill y
 pack .a.t -side right -fill both -expand 1
 pack .a -side bottom
 #----- procedures
 proc every {ms body} {eval $body; after $ms [info level 0]}
 proc Time {} {
         set m [expr {[clock clicks -milliseconds] - $::time0}]
    return [format %2.2d:%2.2d:%2.2d.%2.2d \
            [expr {$m/360000}] [expr {$m/60000}] [expr {($m/1000)%60}] [expr {$m%1000/10}]]
 }
 proc Start {} {
    if {$::time=="00:00:00.00"} {
        set ::time0 [clock clicks -milliseconds]
               .a.t insert 1.0  "Start : [clock format [clock seconds] -format %T_%D]\n"
        .b.start configure -text Stop -bg red
        .b.split configure -state normal -bg green
    }
    every 10 {
        set ::time [Time]
    }
 }
 proc Stop {} {
    if {[llength [after info]]} { after cancel [after info] }
    .b.start configure -text Reset -bg yellow
    .b.split configure -state disable -bg SystemButtonFace
         .a.t insert 1.0  "Stop : [Time]\n"
 } 
 proc Reset {} {
         set ::time 00:00:00.00
    .b.start configure -text Start -bg green
 } 
 proc Split {} {
         .a.t insert 1.0  "Split : [Time]\n"
 } 
 proc Save {} {
    set filetime [clock format [clock seconds] -format %y-%m-%d_%H^%M^%S]
    set name [tk_getSaveFile -initialfile iLogWatch-$filetime.txt \
       -filetypes [list "{Logs} .txt" {All *.*}]]
    if {$name != ""} {
                set fp [open $name w]
                puts $fp [.a.t get 1.0 end-1c]
                close $fp
    }
 } 
 proc Comment {} {
   .a.t insert 1.0  "Comment : $::Mess \n"; set ::Mess ""
 }
 #----- Size and Menu for PocketPC
 wm geometry . 240x268+0+0
 . config -menu [menu .m]
 .m add casc -label File -menu [menu .m.file -tearoff 0]
 .m.file add comm -label Save -comm Save
 .m.file add comm -label Exit -comm exit
 .m add casc -label Log -menu [menu .m.log -tearoff 0]
 .m.log add comm -label Clear -comm  [list .a.t delete 0.0 end]