wtk::wm title . "Feet to Meters"
wtk::grid [wtk::frame .c -padding "3 3 12 12"] -column 0 -row 0 -sticky nwes
wtk::grid columnconfigure .c 0 -weight 1; wtk::grid rowconfigure .c 0 -weight 1
wtk::grid [wtk::button .c.calc -text "Calculate" -radius 7 -bg violet -fg lightgreen -command calculate] -column 0 -row 1 -sticky w
wtk::grid [wtk::entry .c.feet -width 7 -textvariable feet -bg GreenYellow -fg Red] -column 1 -row 1 -sticky we
wtk::grid [wtk::label .c.flbl -text "feet" -bg yellow] -column 2 -row 1 -sticky w
wtk::grid [wtk::label .c.islbl -text "is equivalent to"] -column 0 -row 2 -sticky e
wtk::grid [wtk::label .c.meters -textvariable meters] -column 1 -row 2 -sticky we
wtk::grid [wtk::label .c.mlbl -text "meters"] -column 2 -row 2 -sticky w
foreach w [wtk::winfo children .c] {wtk::grid configure $w -padx 50 -pady 50}; #not working yet
wtk::grid [wtk::text .text -rows 4 -cols 40 -bg GreenYellow -fg Red -textvariable textval] -column 0 -row 2 -sticky ew
wtk::grid [wtk::frame .d -padding "3 3 12 12"] -column 0 -row 3 -sticky nwes
wtk::grid columnconfigure .d 0 -weight 1; wtk::grid rowconfigure .d 0 -weight 1
wtk::grid rowconfigure . 3 -weight 1
wtk::grid [wtk::button .d.ib -text "" -src /images/logo.png -width 63 -height 63 -command swapimages] -column 0 -row 0 -sticky e
wtk::grid [wtk::label .d.iblbl -text "<-- Click Me"] -column 1 -row 0 -sticky w
wtk::grid [wtk::combobox .d.cb -text "ComboBox" -options "zero one two three" -variable textval -command selectimg] -column 2 -row 0 -sticky w
wtk::grid [wtk::checkbutton .d.ck -bg violet -fg Red -variable checkval -command docheck] -column 3 -row 0 -sticky w
wtk::grid [wtk::label .d.cklbl -textvariable ckstatus] -column 4 -row 0 -sticky w
foreach w [wtk::winfo children .d] {wtk::grid configure $w -padx 150 -pady 150}; #not working yet
wtk::focus .c.feet
wtk::bind . <Return> {calculate}
set ::image 0
proc docheck {} {
if {$::checkval} {
set ::ckstatus "checked"
} else {
set ::ckstatus ""
}
}
proc calculate {} {
if {[catch {
set ::meters [expr {round($::feet*0.3048*10000.0)/10000.0}]
set ::textval "hey!"
}]!=0} {
set ::meters ""
}
}
proc swapimages {} {
switch -- $::image {
0 {set ::image 1; set ::textval "one"
.d.ib configure -src /images/cameralens1.jpg}
1 {set ::image 2; set ::textval "two"
.d.ib configure -src /images/rainbow.gif}
2 {set ::image 3; set ::textval "three"
.d.ib configure -src /images/cameralens2.jpg}
3 {set ::image 0; set ::textval "zero"
.d.ib configure -src /images/logo.png}
}
}
proc selectimg {} {
switch -- $::textval {
zero {set ::image 0
.d.ib configure -src /images/logo.png}
one {set ::image 1
.d.ib configure -src /images/cameralens1.jpg}
two {set ::image 2
.d.ib configure -src /images/rainbow.gif}
three {set ::image 3
.d.ib configure -src /images/cameralens2.jpg}
}
}