openVote : Script or program?
With Tcl it is clear: all Tcl scripts are (interpreted) programs, real software, written by real men, even if
they wear skirts. Even if they're not scottish. But how about Tk? When is a Tcl/Tk source an intelligent
script and when is it a dumb program?
In fact, it is rather easy. You should just see the spark of it. I'll show you the spark.
openVote : Tcl/Tk Script
What you see here is a small Tcl/Tk script, dumping a few buttons on screen:
#! /usr/bin/wish
proc sync {} {
do something
}
wm title . "Waiter control"
set Data0 0
set Ctrl1 0
set Ctrl2 1
frame .input
frame .out1
frame .ctrl
button .ctrl.sync -text "Sync" -command { sync }
button .ctrl.quit -text "Quit" -command { destroy . }
button .out1.but1 -text "Data 0" -command {set Data0 [expr !$Data0]; sync }
checkbutton .out1.chk1 -variable Data0
checkbutton .input.chk1 -text "IN 1" -variable Ctrl1
checkbutton .input.chk2 -text "IN 2" -variable Ctrl2
pack .out1.chk1 .out1.but1 -side left -padx 10 -pady 5
pack .input.chk1 .input.chk2 -side left -padx 10 -pady 5
pack .ctrl.sync .ctrl.quit -side left -padx 10 -pady 5
pack .out1
pack .input
pack .ctrl
openVote : Tcl/Tk program
And this is the same source but now as a real program. Notice the subtle difference?
#! /usr/bin/wish
proc sync {} {
do something
}
proc run {} {
wm title . "Waiter control"
set Data0 0
set Ctrl1 0
set Ctrl2 1
frame .input
frame .out1
frame .ctrl
button .ctrl.sync -text "Sync" -command { sync }
button .ctrl.quit -text "Quit" -command { destroy . }
button .out1.but1 -text "Data 0" -command {set Data0 [expr !$Data0]; sync }
checkbutton .out1.chk1 -variable Data0
checkbutton .input.chk1 -text "IN 1" -variable Ctrl1
checkbutton .input.chk2 -text "IN 2" -variable Ctrl2
pack .out1.chk1 .out1.but1 -side left -padx 10 -pady 5
pack .input.chk1 .input.chk2 -side left -padx 10 -pady 5
pack .ctrl.sync .ctrl.quit -side left -padx 10 -pady 5
pack .out1
pack .input
pack .ctrl
}
run
openVote : leaving out the cruft
OK, I will strip off all the non-essential lines and put the sources side by side:
| Script | Program |
|---|---|
#! /usr/bin/wish
wm title . "Waiter control"
pack .out1
pack .input
pack .ctrl
|
#! /usr/bin/wish
proc run {} {
wm title . "Waiter control"
pack .out1
pack .input
pack .ctrl
}
run
|
Page created on 3 April 2008 and
Page equipped with FroogleBuster technology