Last active
December 24, 2015 13:49
-
-
Save ekd123/6808469 to your computer and use it in GitHub Desktop.
秒錶
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set seconds {} | |
set timetext 00:00:00 | |
set id {} | |
ttk::label .time -textvariable timetext -font {Arial 32} | |
ttk::button .reset -text 清零 -command reset | |
ttk::button .start -text 計時 -command { | |
reset | |
set seconds -1 | |
setSeconds | |
} | |
proc setSeconds {} { | |
set ::id [after 1000 setSeconds] | |
incr ::seconds | |
} | |
proc reset {} { | |
if {$::id != {}} { | |
after cancel $::id | |
} | |
set ::id {} | |
set ::seconds 0 | |
} | |
trace add variable seconds write updateTime | |
proc updateTime {args} { | |
set ::timetext [clock format $::seconds -gmt 7 -format %H:%M:%S] | |
} | |
pack .time .reset .start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment