Posted to tcl by oldlaptop at Sun Aug 29 04:29:47 GMT 2021view raw
- #! /usr/bin/env tclsh
- package require Tk 8.5
- proc calculate {} {
- set ::cel [expr {($::fahr - 32) * 5.0 / 9.0}]
- }
- ttk::frame .f
- ttk::label .f.fahrlab -text Fahrenheit
- ttk::entry .f.fahren -textvariable ::fahr
- ttk::label .f.cellab -text Celsius
- ttk::entry .f.celen -textvariable ::cel -state readonly
- ttk::button .f.calc -text Calculate! -command calculate -width 0
- # The layout code looks way too obvious to work! And yet it does.
- grid .f.fahrlab .f.fahren -sticky ew
- grid .f.cellab .f.celen -sticky ew
- grid x .f.calc -sticky se
- grid rowconfigure .f 2 -weight 1
- grid columnconfigure .f 1 -weight 1
- grid .f -sticky nsew
- grid rowconfigure . 0 -weight 1
- grid columnconfigure . 0 -weight 1