Einheiten
Kleiner Einheiten-Umrechner für nicht-metrische Maßangaben.
Links eingetragene Werte rechnen in die rechte Spalte um und umgekehrt.
#!/usr/bin/wish package require Tk set tcl_precision 3 bind Entry <<Paste>> {catch { catch { %W delete sel.first sel.last } %W insert insert [::tk::GetSelection %W CLIPBOARD] tk::EntrySeeInsert %W } } destroy {*}[winfo children .] namespace import tcl::mathfunc::* wm title . Einheiten wm resizable . no no destroy .cutCopyPaste menu .cutCopyPaste -tearoff no .cutCopyPaste add command -label Cut -command {event generate [focus] <<Cut>>} .cutCopyPaste add command -label Copy -command {event generate [focus] <<Copy>>} .cutCopyPaste add command -label Paste -command {event generate [focus] <<Paste>>} bind Entry <3> {tk_popup .cutCopyPaste %X %Y} set lambda { {a c sum fac} { set aVal [double [expr [string map {, .} [$a get]]]] $a delete 0 end $a insert end [string map {. ,} $aVal] set val [expr "($aVal - $sum) * $fac"] $c delete 0 end $c insert end [string map {. ,} $val] } } set i 0 foreach { e0 e1 sum fac } { Knoten m/s 0 0.514 Knoten km/h 0 1.85 kW PS 0 1.35962 Unze Gramm 0 31.1034768 inch cm 0 2.54 m/s km/h 0 3.6 foot m 0 .305 fathom m 0 .305*2 yard m 0 .305*3 mile km 0 1.60934 kp Newton 0 9.807 lb kg 0 0.454 Grain Gramm 0 1.0/15.4324 °K °C 273.15 1.0 °F °C 32.0 5.0/9.0 °R °C 0 1.0/.8 } { set line [incr i] grid\ [entry .a$line -width 10 -justify right]\ [label .b$line -text "$e0 " -justify left]\ [label .eq$line -text "= "]\ [entry .c$line -width 10 -justify right]\ [label .d$line -text "$e1" -justify left]\ -sticky w set sum [expr $sum] set fac [expr $fac] bind .a$line <Return> [list apply $lambda .a$line .c$line $sum $fac] .a$line insert end 0 apply $lambda .a$line .c$line $sum $fac bind .c$line <Return> [list apply { {a c sum fac} { set cVal [double [expr [string map {, .} [$c get]]]] $c delete 0 end $c insert end [string map {. ,} $cVal] set val [expr "$cVal / $fac + $sum"] $a delete 0 end $a insert end [string map {. ,} $val] } } .a$line .c$line $sum $fac] bind .a$line <FocusIn> {%W selection range 0 end} bind .c$line <FocusIn> {%W selection range 0 end} } grid\ [entry .m -width 10 -justify right]\ [label .mLabel -justify left -text gram]\ [label .byV -justify right -text by]\ [entry .v -width 10 -justify right]\ [label .j -justify left -text {m/sec = 2,0 J}]\ -sticky w menu .j.copy -tearoff no .j.copy add command -label Copy -command { clipboard clear # clipboard append [string range [.j cget -text] 8 end-2] clipboard append [lindex [.j cget -text] end-1] } bind .j <3> {tk_popup .j.copy %X %Y} menu .m.caliber .m.caliber add command -label Cut -command {event generate [focus] <<Cut>>} .m.caliber add command -label Copy -command {event generate [focus] <<Copy>>} .m.caliber add command -label Paste -command {event generate [focus] <<Paste>>} .m.caliber add separator .m.caliber add command -label 5,5mm -command { .m delete 0 end .m insert end 1,0 focus .m } .m.caliber add command -label 4,5mm -command { .m delete 0 end .m insert end 0,5 focus .m } bind .m <3> { focus %W tk_popup .m.caliber %X %Y break } bind .m <FocusIn> {%W selection range 0 end} bind .v <FocusIn> {%W selection range 0 end} .m insert end 0,5 .v insert end 110,0 bind .m <Return> { apply { {} { set m [expr double([string map {, .} [.m get]])] .m delete 0 end .m insert end [string map {. ,} $m] set v [expr double([string map {, .} [.v get]])] .v delete 0 end .v insert end [string map {. ,} $v] set J [expr {$m/2*$v*$v/1000}] .j configure -text "m/sec = [string map {. ,} $J] J" } } } # =(B1)/2*B2*B2/1000 bind .v <Return> [bind .m <Return>]
12.10.2022
<< | Heimatseite | Verzeichnis | Stichworte | Autor | >>