As a result of a discussion in the chatroom today (July 9, 2002,) concerning the heat wave here(Kansas City, Missouri), I was asked to use a 'saner' temperature scale than Fahrenheit... so ...
#convert degrees F to degrees C
proc f2c { f } {
set res [expr int (($f - 32) * (5/9.))]
}
#convert degrees C to degrees F
proc c2f { c } {
set res [expr int (($c * (9/5.)) + 32) ]
}
#create GUI -not elegant scripting, but it works
label .fl -text "Degrees F:"
entry .ef -textvariable F -width 4
label .cl -text "Degrees C:"
entry .ec -textvariable C -width 4
grid .fl .ef -sticky ew
grid .cl .ec -row 1 -sticky ew
button .b -text "Exit" -command {exit}
grid .b -row 2 -columnspan 2 -sticky ew
#bindings
bind .ef <Return> {set C [f2c $F]}
bind .ec <Return> {set F [c2f $C]}
wm title . "F2C"Kinda ugly, but you get the idea...
If you never hang out in the chatroom, the discussion that followed was both diverse and enlightening.