Created
November 9, 2019 19:55
-
-
Save barahilia/1f40be06b1509c6b3b3a71b9fcd5617b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts $argc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package require Tk | |
grid [ttk::button .b -text "Hello World"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package require Tk | |
wm title . "Feet to Meters" | |
grid [ttk::frame .c -padding "3 3 12 12"] -column 0 -row 0 -sticky nwes | |
grid columnconfigure . 0 -weight 1; grid rowconfigure . 0 -weight 1 | |
grid [ttk::entry .c.feet -width 7 -textvariable feet] -column 2 -row 1 -sticky we | |
grid [ttk::label .c.meters -textvariable meters] -column 2 -row 2 -sticky we | |
grid [ttk::button .c.calc -text "Calculate" -command calculate] -column 3 -row 3 -sticky w | |
grid [ttk::label .c.flbl -text "feet"] -column 3 -row 1 -sticky w | |
grid [ttk::label .c.islbl -text "is equivalent to"] -column 1 -row 2 -sticky e | |
grid [ttk::label .c.mlbl -text "meters"] -column 3 -row 2 -sticky w | |
foreach w [winfo children .c] {grid configure $w -padx 5 -pady 5} | |
focus .c.feet | |
bind . <Return> {calculate} | |
proc calculate {} { | |
if {[catch { | |
set ::meters [expr {round($::feet*0.3048*10000.0)/10000.0}] | |
}]!=0} { | |
set ::meters "" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Here it goes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment