Version 2 of A small calculator

Updated 2005-01-09 22:37:41

button .quit -text "Off" -command exit

 label .readout -textvariable aufgabe 
 set aufgabe " "
 button .key0 -text "0" -width 3 -command {append aufgabe 0}
 button .key1 -text "1" -width 3 -command {append aufgabe 1}
 button .key2 -text "2" -width 3 -command {append aufgabe 2}
 button .key3 -text "3" -width 3 -command {append aufgabe 3}
 button .key4 -text "4" -width 3 -command {append aufgabe 4}
 button .key5 -text "5" -width 3 -command {append aufgabe 5}
 button .key6 -text "6" -width 3 -command {append aufgabe 6} 
 button .key7 -text "7" -width 3 -command {append aufgabe 7}
 button .key8 -text "8" -width 3 -command {append aufgabe 8}
 button .key9 -text "9" -width 3 -command {append aufgabe 9}

 button .point -text "." -width 3 -command {append aufgabe .}
 button .plus -text "+" -width 3 -command {append aufgabe +}
 button .minus -text "-" -width 3 -command {append aufgabe -}
 button .times -text "*" -width 3 -command {append aufgabe *}
 button .div -text "/" -width 3 -command {append aufgabe /}
 button .equal -text "="  -width 3 -command {append aufgabe = [expr $aufgabe]}
 button .sign -text "+/-" -width 3 -command {set aufgabe [expr $aufgabe*-1]}
 button .clear -text "C/CE" -width 3 -command {set aufgabe ""}


 grid .quit .readout -sticky nsew 
 grid .key7 .key8 .key9 .times .clear -sticky nsew
 grid .key4 .key5 .key6 .minus .div -sticky nsew
 grid .key1 .key2 .key3 .plus .equal -sticky nsew
 grid .key0 .sign .point -sticky nsew

 #uber vier Spalten:
 #grid configure .sbar -columnspan 4 -padx 4
 grid configure .readout -columnspan 4 -padx 4
 grid configure .plus -rowspan 2
 grid configure .equal -rowspan 2


 #bind . <1> {append aufgabe 1}
 #bind . <2> {append aufgabe 2}
 #bind . <3> {append aufgabe 3}
 bind . <4> {append aufgabe 4}
 bind . <r> {append aufgabe 5}
 focus -force .