--- trunk/RCS/lohnrechner.py 2005/01/14 13:04:09 22 +++ trunk/RCS/lohnrechner.py 2005/01/31 08:55:33 29 @@ -46,13 +46,20 @@ ("Schleswig-Holstein", 9), ("Thüringen", 9)] - root.title("Lohnrechner 2005 - v%s" % _release_version) - root.resizable(NO, NO) self.root = root + self.root.title("Lohnrechner 2005 - v%s" % _release_version) + + self.SetupUI() + self.ResetInput() + + def SetupUI(self): + self.root.resizable(NO, NO) + frame = Frame(root) frame.grid(padx=10, pady=10) + # Steuern Ein/Ausgabe Label(frame, text="Lohn:").grid(row=0, sticky=E) self.lohn = Entry(frame) self.lohn.bind("", self.NewInput) @@ -69,7 +76,7 @@ ("V", 5), ("VI", 6)]: stklradio = Radiobutton(stklframe, text=text, value=val, - indicatoron=0, command=self.CalcOutput, + indicatoron=0, command=self.NewInput, variable=self.stkl) if text == "I": stklradio.select() @@ -78,8 +85,9 @@ Label(frame, text="Kirchensteuer:").grid(row=2, sticky=E) self.kirche = IntVar() kircheradio = Checkbutton(frame, onvalue=1, offvalue=0, - command=self.CalcOutput, - variable=self.kirche).grid(row=2, column=1, sticky=W) + command=self.NewInput, + variable=self.kirche).grid(row=2, column=1, + sticky=W) Label(frame, text="Kinderfreibetrag:").grid(row=3, sticky=E) self.kfb = Entry(frame) @@ -89,19 +97,17 @@ Label(frame, text="Bundesland:").grid(row=4, sticky=E) landframe = Frame(frame) scrollbar = Scrollbar(landframe, orient=VERTICAL) - self.land = Listbox(landframe, height=4, selectmode=SINGLE, - yscrollcommand=scrollbar.set) + self.landbox = Listbox(landframe, height=4, selectmode=SINGLE, + yscrollcommand=scrollbar.set) for land in self.laender: - self.land.insert(END, land[0]) - self.land.select_set(0) - self.land.bind("", self.NewInput) - self.land.pack(side=RIGHT, fill=Y) - scrollbar.config(command=self.land.yview) + self.landbox.insert(END, land[0]) + self.landbox.select_set(0) + self.landbox.bind("<>", self.NewLandSel) + self.landbox.pack(side=RIGHT, fill=Y) + scrollbar.config(command=self.landbox.yview) scrollbar.pack(side=LEFT, fill=BOTH, expand=1) landframe.grid(row=4, column=1, sticky=W) - self.ResetInput() - Label(frame, text="Lohnsteuer:").grid(row=0, column=2, sticky=E) self.lst = Entry(frame) self.lst.grid(row=0, column=3, sticky=W) @@ -114,19 +120,37 @@ self.kist = Entry(frame) self.kist.grid(row=2, column=3, sticky=W) + Label(frame, text="Lohn nach Steuern:").grid(row=3, column=2, sticky=E) + self.netto = Entry(frame) + self.netto.grid(row=3, column=3, sticky=W) + + # Allgemeine UI Elemente buttons = Frame(frame) buttons.grid(row=4, column=2, columnspan=2) Button(buttons, text="Quit", command=root.quit).pack(side=LEFT) Button(buttons, text="Info", command=self.Info).pack(side=LEFT) Button(buttons, text="Berechnen", command=self.CalcOutput).pack(side=LEFT) - + + def NewInput(self, event=0): + # Es ist möglich alle Einträge in der Listbox zu deselektieren, + # es ist aber immer genau ein Eintrag aktuell, darum wird er ggf. + # zwangsselektiert: + # FIX ME: eigendlich wäre das ein Fall für ein custom widget! + if len(self.landbox.curselection()) == 0: + self.landbox.select_set(self.land) self.CalcOutput() - def NewInput(self, event): + def UpdateLand(self): + self.land = int(self.landbox.curselection()[0]) + + def NewLandSel(self, event=0): + self.UpdateLand() self.CalcOutput() def ResetInput(self): self.ResetInputLohn() + self.ResetInputKfb() + self.NewLandSel() def ResetInputLohn(self): self.lohn.delete(0, END) @@ -148,18 +172,22 @@ self.ResetInputKfb() self.SetSteuerklasse(self.stkl.get()) - self.SetKirchensteuer(self.kirche.get() * - self.laender[int(self.land.curselection()[0])][1]) + self.SetKirchensteuerProzent(self.kirche.get() * + self.laender[self.land][1]) def CalcOutput(self): self.InitCalc() self.Calc() self.lst.delete(0, END) - self.lst.insert(0, "%.2f" % self.GetLohnsteuer()) + self.lst.insert(0, "%.2f" % self.GetLohnsteuer()) self.soli.delete(0, END) - self.soli.insert(0, "%.2f" % self.GetSoli()) + self.soli.insert(0, "%.2f" % self.GetSoli()) self.kist.delete(0, END) - self.kist.insert(0, "%.2f" % self.GetKirchensteuer()) + self.kist.insert(0, "%.2f" % self.GetKirchensteuer()) + self.netto.delete(0, END) + self.netto.insert(0, "%.2f" % + (self.GetLohn() - self.GetLohnsteuer() + - self.GetSoli() - self.GetKirchensteuer())) def Info(self): infowin = Toplevel(self.root) @@ -180,4 +208,3 @@ root = Tk() lr = Lohnrechner(root) root.mainloop() -