📄 clock.tcl
字号:
#############################################################################
# Visual Tcl v1.20 Project
#
#################################
# GLOBAL VARIABLES
#
global widget;
#################################
# USER DEFINED PROCEDURES
#
proc init {argc argv} {
}
init $argc $argv
proc {fileDialog} {} {
global input_file
set types {
{"Text files" {.txt} }
{"All files" *}
}
set input_file [tk_getOpenFile -filetypes $types]
if {$input_file != ""} {
readFile "$input_file"
}
}
proc {readFile} {fileName} {
if {[file exist $fileName]&&[file readable $fileName]} {
if {![catch {.top17.tex18 delete 1.0 end}]} {
set fid [open $fileName r]
while {![eof $fid]} {
.top17.tex18 insert end [read $fid]
}
close $fid
after 1000 readFile $fileName
} else {
exit
}
}
}
proc {main} {argc argv} {
readFile {clock.txt}
}
proc {Window} {args} {
global vTcl
set cmd [lindex $args 0]
set name [lindex $args 1]
set newname [lindex $args 2]
set rest [lrange $args 3 end]
if {$name == "" || $cmd == ""} {return}
if {$newname == ""} {
set newname $name
}
set exists [winfo exists $newname]
switch $cmd {
show {
if {$exists == "1" && $name != "."} {wm deiconify $name; return}
if {[info procs vTclWindow(pre)$name] != ""} {
eval "vTclWindow(pre)$name $newname $rest"
}
if {[info procs vTclWindow$name] != ""} {
eval "vTclWindow$name $newname $rest"
}
if {[info procs vTclWindow(post)$name] != ""} {
eval "vTclWindow(post)$name $newname $rest"
}
}
hide { if $exists {wm withdraw $newname; return} }
iconify { if $exists {wm iconify $newname; return} }
destroy { if $exists {destroy $newname; return} }
}
}
#################################
# VTCL GENERATED GUI PROCEDURES
#
proc vTclWindow. {base} {
if {$base == ""} {
set base .
}
###################
# CREATING WIDGETS
###################
wm focusmodel $base passive
wm geometry $base 200x200+154+154
wm maxsize $base 100 100
wm minsize $base 114 2
wm overrideredirect $base 0
wm resizable $base 0 0
wm withdraw $base
wm title $base "vt"
###################
# SETTING GEOMETRY
###################
}
proc vTclWindow.top17 {base} {
if {$base == ""} {
set base .top17
}
if {[winfo exists $base]} {
wm deiconify $base; return
}
###################
# CREATING WIDGETS
###################
toplevel $base -class Toplevel \
-menu .top17.m17
wm focusmodel $base passive
wm geometry $base 304x220+124+116
wm maxsize $base 1158 851
wm minsize $base 114 2
wm overrideredirect $base 0
wm resizable $base 0 0
wm deiconify $base
wm title $base "Alarm Clock"
text $base.tex18 \
-background #000000 -font {{courier} 8} -foreground #eb0214 \
-height 11 -width 36
frame $base.cpd19 \
-borderwidth 1 -height 30 -relief sunken -width 30
menubutton $base.cpd19.01 \
-anchor w -menu .top17.cpd19.01.02 -padx 4 -pady 3 -text File \
-width 4
menu $base.cpd19.01.02 \
-activeborderwidth 1 -borderwidth 1 -tearoff 0
$base.cpd19.01.02 add command \
-accelerator Ctrl-O -command fileDialog -label Open
$base.cpd19.01.02 add command \
-accelerator Ctrl-W -command {destroy .top17} -label Close
menubutton $base.cpd19.05 \
-anchor w -menu .top17.cpd19.05.06 -padx 4 -pady 3 -text Help \
-width 4
menu $base.cpd19.05.06 \
-activeborderwidth 1 -borderwidth 1 -tearoff 0
$base.cpd19.05.06 add command \
\
-command {tk_messageBox -icon info -message "Alarm Clock Version 2.0\n\nDesigned By: D. Cabanis\n\nLearn how to do this by\nattenting an Esperan\nTcl/Tk Workshop.\n\nwww.esperan.com" -type ok} \
-label About
menu $base.m17 \
-activeborderwidth 1 -borderwidth 1 -cursor {}
###################
# SETTING GEOMETRY
###################
place $base.tex18 \
-x 5 -y 35 -anchor nw -bordermode ignore
place $base.cpd19 \
-x -5 -y -5 -width 312 -height 28 -anchor nw
pack $base.cpd19.01 \
-in .top17.cpd19 -anchor center -expand 0 -fill none -side left
pack $base.cpd19.05 \
-in .top17.cpd19 -anchor center -expand 0 -fill none -side right
}
Window show .
Window show .top17
main $argc $argv
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -