📄 timer
字号:
#!/bin/sh# the next line restarts using wish \exec wish "$0" "$@"# timer --# This script generates a counter with start and stop buttons.## RCS: @(#) $Id: timer,v 1.3 2001/10/29 16:23:33 dkf Exp $label .counter -text 0.00 -relief raised -width 10 -padx 2m -pady 1mbutton .start -text Start -command { if {$stopped} { set stopped 0 set startMoment [clock clicks -milliseconds] tick .stop configure -state normal .start configure -state disabled }}button .stop -text Stop -state disabled -command { set stopped 1 .stop configure -state disabled .start configure -state normal}pack .counter -side bottom -fill bothpack .start -side left -fill both -expand yespack .stop -side right -fill both -expand yesset startMoment {}set stopped 1proc tick {} { global startMoment stopped if {$stopped} {return} after 50 tick set elapsedMS [expr {[clock clicks -milliseconds] - $startMoment}] .counter config -text [format "%.2f" [expr {double($elapsedMS)/1000}]]}bind . <Control-c> {destroy .}bind . <Control-q> {destroy .}focus .# Local Variables:# mode: tcl# End:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -