--- trunk/RCS/lohnrechner.py 2005/01/14 13:04:09 22 +++ trunk/RCS/lohnrechner.py 2005/01/17 14:30:00 24 @@ -89,16 +89,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.bind("<>", self.NewLandSel) + self.landbox.select_set(0) + 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.NewLandSel() self.ResetInput() @@ -123,10 +124,20 @@ self.CalcOutput() def NewInput(self, event): + # 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 NewLandSel(self, event=0): + self.land = int(self.landbox.curselection()[0]) + def ResetInput(self): self.ResetInputLohn() + self.ResetInputKfb() def ResetInputLohn(self): self.lohn.delete(0, END) @@ -149,7 +160,7 @@ self.SetSteuerklasse(self.stkl.get()) self.SetKirchensteuer(self.kirche.get() * - self.laender[int(self.land.curselection()[0])][1]) + self.laender[self.land][1]) def CalcOutput(self): self.InitCalc()