Skip to content

Instantly share code, notes, and snippets.

@ekd123
Last active December 24, 2015 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ekd123/6808469 to your computer and use it in GitHub Desktop.
Save ekd123/6808469 to your computer and use it in GitHub Desktop.
秒錶
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