Tcl/Tk quick start - Free
Tcl/Tk quick start - Free
Tcl/Tk quick start - Free
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Presented by developerWorks, your source for great tutorials<br />
ibm.com/developerWorks<br />
#<br />
# netset.tcl<br />
# 03.26.2001 bilbrey<br />
set ConFile "~/.netsetrc"<br />
if [catch {open $ConFile r} Conf] {<br />
puts stderr "Open $ConFile failed"<br />
return 1<br />
}<br />
# parse config, define buttons<br />
set Bcount 0<br />
while {[gets $Conf Cline] >= 0} {<br />
if {1 == [string match #* $Cline]} continue<br />
if {[string length $Cline] < 4} continue<br />
set Nend [string wordend $Cline 0]<br />
incr Nend -1<br />
set Bname [string range $Cline 0 $Nend]<br />
set Cbeg [expr $Nend + 2]<br />
set Bcomd "exec "<br />
append Bcomd [string range $Cline $Cbeg end]<br />
incr Bcount<br />
set NextBut "button$Bcount"<br />
button .$NextBut -text $Bname -command $Bcomd<br />
}<br />
if {$Bcount == 1} {<br />
puts stderr "No buttons defined"<br />
return 2<br />
}<br />
# display buttons<br />
while {$Bcount >= 1} {<br />
set NextBut "button$Bcount"<br />
pack .$NextBut -padx 10 -pady 10<br />
incr Bcount -1<br />
}<br />
button .exit -text Exit -command {exit}<br />
pack .exit -padx 10 -pady 10<br />
<strong>Tcl</strong>/<strong>Tk</strong> <strong>quick</strong> <strong>start</strong> Page 20 of 29