--- trunk/RCS/lohnrechner.py 2005/01/13 10:01:01 7 +++ trunk/RCS/lohnrechner.py 2005/01/13 13:01:58 16 @@ -30,6 +30,7 @@ Label(root, text="Lohn:").grid(row=0, sticky=E) self.lohn = Entry(root) + self.lohn.bind("", self.NewInput) self.lohn.grid(row=0, column=1, sticky=W) Label(root, text="Steuerklasse:").grid(row=1, sticky=E) @@ -43,33 +44,63 @@ ("V", "5"), ("VI", "6")]: stklradio = Radiobutton(stklframe, text=text, value=val, - indicatoron=0, + indicatoron=0, command=self.CalcOutput, variable=self.stkl) if text == "I": stklradio.select() stklradio.pack(side=LEFT) + Label(root, text="Kirchensteuer (%):").grid(row=2, sticky=E) + self.kirche = StringVar() + kircheframe = Frame(root) + kircheframe.grid(row=2, column=1, sticky=W) + for text, val in [("keine", "0"), + ("8 %", "8"), + ("9 %", "9")]: + kircheradio = Radiobutton(kircheframe, text=text, value=val, + indicatoron=0, command=self.CalcOutput, + variable=self.kirche) + if val == "0": + kircheradio.select() + kircheradio.pack(side=LEFT) + self.ResetInput() Label(root, text="Lohnsteuer:").grid(row=0, column=2, sticky=E) self.lst = Entry(root) self.lst.grid(row=0, column=3, sticky=W) - Label(root, text="Lolidaritätszuschlag:").grid(row=1, column=2, sticky=E) + Label(root, text="Solidaritätszuschlag:").grid(row=1, column=2, sticky=E) self.soli = Entry(root) self.soli.grid(row=1, column=3, sticky=W) + Label(root, text="Kirchensteuer:").grid(row=2, column=2, sticky=E) + self.kist = Entry(root) + self.kist.grid(row=2, column=3, sticky=W) + self.calcbutton = Button(root, text="Berechnen", command=self.CalcOutput) self.calcbutton.grid(row=3, columnspan=4) self.CalcOutput() - + + def NewInput(self, event): + self.CalcOutput() + def ResetInput(self): + self.ResetInputLohn() + + def ResetInputLohn(self): + self.lohn.delete(0, END) self.lohn.insert(0, "0") def InitCalc(self): - self.SetLohn(float(self.lohn.get())) + try: + self.SetLohn(float(self.lohn.get())) + except: + self.ResetInputLohn() + self.SetSteuerklasse(int(self.stkl.get())) + self.SetKirchensteuer(int(self.kirche.get())) def CalcOutput(self): self.InitCalc() @@ -78,6 +109,8 @@ self.lst.insert(0, "%.2f" % self.GetLohnsteuer()) self.soli.delete(0, END) self.soli.insert(0, "%.2f" % self.GetSoli()) + self.kist.delete(0, END) + self.kist.insert(0, "%.2f" % self.GetKirchensteuer()) if __name__ == "__main__":