def _createFields(self): frame = self.clientArea MyLabel(frame, 'Name: ', 0, 0, "nw", None, 3, (10, 3)) self._teName = TextEntry(frame, 1, 0, "nwe", 3, (10, 3)) MyLabel(frame, 'Password: ', 0, 1, "nw", None, 3, (3, 10)) self._tePwd = TextEntry(frame, 1, 1, "nwe", 3, (3, 10)) self._tePwd.config(show="*")
def _createLabelAndFunctionBar(self, title: str, padx: int, pady: int): f = ttk.Frame(self) f.columnconfigure(1, weight=1) self._groupLabel = MyLabel(f, text=title, column=0, row=0, sticky='sw', pady=0) funcbar = EditSaveFunctionBar(f, self._onAction) funcbar.grid(column=1, row=0, sticky='se', pady=0) return f
def _createKuecheLabelframe(self, parent, padx, pady): s = ttk.Style() s.configure('ital.TLabelframe.Label', font=('courier', 13, 'italic')) lfKueche = ttk.Labelframe(parent, text='Küche', style='ital.TLabelframe') lfKueche.grid(column=0, row=0, sticky='nswe', padx=padx, pady=pady) c = r = 0 padx = (1, padx) ##### Art der Küche MyLabel(lfKueche, 'Küche ist', c, r, 'nswe', 'w', padx, pady) c += 1 cbo = MyCombobox(lfKueche) cbo.setItems( ('', 'Küchenzeile im Wohnraum', 'eigener Raum', 'Wohnküche')) cbo.setIndex(0) cbo.registerModifyCallback(self._onModified) cbo.grid(column=c, row=r, columnspan=3, sticky='nswe', padx=padx, pady=pady) self._cboKueche = cbo ########## Einbauküche? Mit welchen Geräten? c = 0 r = 1 cb = ttk.Checkbutton(lfKueche, text='Einbauküche', variable=self._ivarEbk) cb.grid(column=c, row=r, columnspan=2, sticky='nswe', padx=padx, pady=pady) self._cbEbk = cb c += 2 MyLabel(lfKueche, 'Geräte:', c, r, 'nswe', 'w', padx, pady) c += 1 cbo = MyCombobox(lfKueche) cbo.setItems(('', 'Keine', 'Herd', 'Herd, Kühlschrank', 'Herd, Kühlschrank, Geschirrspüler')) cbo.setWidth(26) cbo.setIndex(0) cbo.registerModifyCallback(self._onModified) cbo.grid(column=c, row=r, sticky='nswe', padx=padx, pady=pady) self._cboKuechenGeraete = cbo
def _createWohnungIdent(self, parent, padx, pady) -> ttk.Label: lbl = MyLabel(parent, text='', column=0, row=0, sticky='nswe', anchor='center', padx=padx, pady=pady) lbl.setBackground('whg_short.TLabel', 'gray') lbl.setForeground('whg_short.TLabel', 'white') lbl.setFont('Helvetica 14 bold') lbl['relief'] = 'sunken' lbl.setTextPadding('whg_short.TLabel', 10, 10) return lbl
def _createMietvertragFrame(self, row, xmargins: int, topmargin: int, bottommargin: int): padx = xmargins pady = (topmargin, bottommargin) lf = ttk.Labelframe(self, text='Mietvertrag', style='my.TLabelframe') lf.grid(column=0, row=row, sticky='nswe', padx=padx, pady=pady) padx = (5, 6) pady = (5, 5) ######### Vermietung ab col = row = 0 MyLabel(lf, 'Vermietung ab:', col, row, 'nswe', 'w', padx, pady) col += 1 de = DateEntry(lf) de.registerModifyCallback(self._onModified) de.grid(column=col, row=row, sticky='nswe', padx=padx, pady=pady) de.setWidth(10) self._deVermietetAb = de ######### Vermietung befristet bis col += 1 MyLabel(lf, 'befristet bis:', col, row, 'nswe', 'w', padx, pady) col += 1 de = DateEntry(lf) de.registerModifyCallback(self._onModified) de.grid(column=col, row=row, sticky='nsw', padx=padx, pady=pady) de.setWidth(10) self._deVermietetBis = de ######## Kaution row += 1 col = 0 MyLabel(lf, 'Kaution:', col, row, 'nswe', 'w', padx, pady) col += 1 ie = IntEntry(lf) ie.registerModifyCallback(self._onModified) ie.grid(column=col, row=row, sticky='nswe', padx=padx, pady=pady) ie.setWidth(5) self._ieKaution = ie ######### bei welcher Bank col += 1 MyLabel(lf, 'hinterlegt bei:', col, row, 'nswe', 'w', padx, pady) col += 1 te = TextEntry(lf, col, row, 'nswe', padx, pady) te.registerModifyCallback(self._onModified) self._teAngelegtBei = te
def _createAfaLabelframe(self, padx: int, pady: int) -> ttk.Labelframe: lf = ttk.Labelframe(self, text='AfA') #lf.columnconfigure(1, weight=1) MyLabel(lf, 'Art der Absetzung: ', 0, 1, 'nswe', 'e', padx, pady) cb = MyCombobox(lf) cb.setBackground('AfA.TCombobox', 'lightyellow') cb.setItems(('', 'linear', 'degressiv')) cb.setIndex(0) cb.setReadonly(True) cb.registerModifyCallback(self._onAfaModified) cb.grid(column=1, row=1, sticky='w', padx=padx, pady=pady) self._art_afa = cb MyLabel(lf, 'Prozentsatz: ', 2, 1, 'nswe', 'e', padx, pady) f = FloatEntry(lf) f.grid(column=3, row=1, sticky='w', padx=padx, pady=pady) f['width'] = 4 f.registerModifyCallback(self._onAfaModified) self._prozent_afa = f MyLabel(lf, 'Betrag: ', 0, 2, 'nswe', 'e', padx, pady) f = IntEntry(lf) f.setBackground('AfA.TEntry', 'lightyellow') f.grid(column=1, row=2, sticky='w', padx=padx, pady=pady) f.setWidth(8) f.registerModifyCallback(self._onAfaModified) self._betrag_afa = f MyLabel(lf, 'Wie Vorjahr: ', 2, 2, 'nswe', 'e', padx, pady) c = MyCombobox(lf) #c.setBackground('AfA.TCombobox', 'red') c.setStyle('AfA.TCombobox') c.setItems(('', 'Ja', 'Nein')) c.setIndex(0) c.setWidth(4) c.setReadonly(True) c.registerModifyCallback(self._onAfaModified) c.grid(column=3, row=2, sticky='w', padx=padx, pady=pady) self._afa_wie_vj = c return lf
def _createZubehoerFrame(self, row, padx, pady): lf = ttk.Labelframe(self, text='Weitere Merkmale der Wohnung', style='my.TLabelframe') lf.grid(column=0, row=row, sticky='nswe', padx=padx, pady=(pady + 8, pady)) c = r = 0 padx = (1, padx) ########### Balkon MyLabel(lf, 'Balkon: ', c, r, 'nsw', 'w', padx, pady) c += 1 cbo = MyCombobox(lf) cbo.setItems(('', 'Keiner', 'Nord', 'Ost', 'Süd', 'West')) cbo.setWidth(7) cbo.setIndex(0) cbo.registerModifyCallback(self._onModified) cbo.grid(column=c, row=r, sticky='nswe', padx=padx, pady=pady) self._cboBalkon = cbo c += 1 cb = ttk.Checkbutton(lf, text='Kellerabteil', variable=self._ivarKellerabteil) cb.grid(column=c, row=r, sticky='nswe', padx=(28, 5), pady=pady) self._cbKellerabteil = cb c += 1 MyLabel(lf, 'Garage: ', c, r, 'nswe', 'w', (28, 5), pady) c += 1 cbo = MyCombobox(lf) cbo.setItems(('', 'Keine', 'Stellplatz', 'TG-Stellplatz', 'Garage')) cbo.setWidth(13) cbo.setIndex(0) cbo.registerModifyCallback(self._onModified) cbo.grid(column=c, row=r, sticky='nswe', padx=padx, pady=pady) self._cboGarage = cbo
def _createHeizungFrame(self, lf, row, padx, pady) -> None: f = ttk.Frame(lf) f.grid(column=0, row=row, sticky='nswe', padx=padx, pady=pady) padx = (0, padx) MyLabel(f, 'Heizung:', 0, 0, 'nswe', 'w', padx, pady) cbo = MyCombobox(f) cbo.setItems(('', 'Gas-Etagenheizung', 'Oel Zentral', 'Gas Zentral', 'Fernwaerme', 'Nachtspeicher')) cbo.setIndex(1) cbo.registerModifyCallback(self._onModified) cbo.grid(column=1, row=0, sticky='nswe', padx=padx, pady=pady) self._cboHeizung = cbo
def _createVjFrame(self, parent, padx, pady) -> ttk.Frame: f = ttk.Frame(parent) f.columnconfigure(0, weight=1) f.columnconfigure(3, weight=2) # l = MyLabel(f, 'Veranlagungsjahr', 1, 0, 'w', 'w', padx, pady) l.setWidth(16) c = MyCombobox(f) c.setTextPadding('Vj.TCombobox', 5, 5, 0) c.setWidth(5) c.setFont('Helvetica 16 bold') yearlist = datehelper.getLastYears(3) yearlist.insert(0, '') c.setItems(yearlist) c.setIndex(0) c.setReadonly(True) c.registerModifyCallback(self._onAfaModified) c.grid(column=2, row=0, sticky='w', pady=pady) c.bind('<<ComboboxSelected>>', self._onVjSelectionChanged) self._vj_combo = c return f
def _createInseratText(self, row, xmargins: int, topmargin: int, bottommargin: int): padx = xmargins pady = (topmargin, bottommargin) lf = ttk.LabelFrame(self, text='Inserat', style='my.TLabelframe') lf.grid(column=0, row=row, sticky='nswe', padx=padx, pady=pady) lf.columnconfigure(1, weight=1) lf.columnconfigure(3, weight=1) row = col = 0 MyLabel(lf, 'Text:', col, row, 'nw', 'w', padx, pady) col += 1 txt = MyText(lf) txt['height'] = 6 txt['width'] = 50 txt.registerModifyCallback(self._onModified) txt.grid(column=col, row=row, sticky='nswe', padx=padx, pady=pady) self._txtInseratText = txt col += 1 MyLabel(lf, 'inseriert bei:', col, row, 'nw', 'w', padx, pady) col += 1 te = TextEntry(lf, col, row, 'nwe', padx, pady) te.registerModifyCallback(self._onModified) self._teInseriertBei = te
def _createUI(self): padx = pady = 5 self.columnconfigure(1, weight=1) MyLabel(self, 'Firma: ', 0, 0, 'nswe', 'e', padx, pady) self._teFirma = TextEntry(self, 1, 0, 'nswe', padx, pady) self._teFirma.setBackground('My.TEntry', 'lightyellow') self._teFirma.registerModifyCallback(self._onVerwalterModified) MyLabel(self, 'Straße: ', 0, 1, 'nswe', 'e', padx, pady) self._teStrasse = TextEntry(self, 1, 1, 'nswe', padx, pady) self._teStrasse.setWidth(30) self._teStrasse.registerModifyCallback(self._onVerwalterModified) MyLabel(self, 'PLZ/Ort: ', 0, 2, 'nswe', 'e', padx, pady) f = ttk.Frame(self) f.columnconfigure(1, weight=1) self._tePlz = TextEntry(f, 0, 0, 'nsw', padx=(0, 3)) self._tePlz['width'] = 6 self._tePlz.registerModifyCallback(self._onVerwalterModified) self._teOrt = TextEntry(f, 1, 0, 'nswe') self._teOrt.setWidth(30) self._teOrt.registerModifyCallback(self._onVerwalterModified) f.grid(column=1, row=2, sticky='nswe', padx=padx, pady=pady) MyLabel(self, 'Telefon: ', 0, 3, 'nswe', 'e', padx, pady) self._teTelefon = TextEntry(self, 1, 3, 'nswe', padx, pady) self._teTelefon.registerModifyCallback(self._onVerwalterModified) MyLabel(self, 'Mail-Adresse: ', 0, 4, 'nswe', 'e', padx, pady) self._teEmail = TextEntry(self, 1, 4, 'nswe', padx, pady) self._teEmail.registerModifyCallback(self._onVerwalterModified) f:ttk.Frame = self._createSaveCancelButtons() f.grid(column=1, row=5, sticky='se', padx=padx, pady=pady)
def createGroupBoxContent(self) -> None: AddressGroup.createGroupBoxContent(self) box = self.getGroupBoxFrame() padx = pady = 3 l = MyLabel(box, text='Steuernummer:', column=0, row=5, sticky='nw', padx=padx, pady=pady) self._teSteuernummer = TextEntry(box, column=1, row=5, sticky='nwe', padx=padx, pady=(pady, pady + 3)) self._teSteuernummer.grid(columnspan=3)
def _createWohnungLabelFrame(self, padx: int, pady: int) -> ttk.Labelframe: lf = ttk.Labelframe(self, text='Wohnung') lbl = MyLabel(lf, 'Angeschafft am: ', 0, 0, 'nsw', 'w', padx, pady) de = DateEntry(lf) de.setBackground('Whg.TEntry', 'lightyellow') de.setUseCalendar(False) de['width'] = 10 de.registerModifyCallback(self._onWhgModified) de.grid(column=1, row=0, sticky='nsw', padx=padx, pady=pady) self._angeschafft_am = de MyLabel(lf, 'Einh.wert-Az: ', 2, 0, 'nswe', 'e', padx, pady) te = TextEntry(lf, 3, 0, 'nsw', padx, pady) te.grid_configure(columnspan=2) te.setBackground('Whg.TEntry', 'lightyellow') te.registerModifyCallback(self._onWhgModified) self._einhwert_az = te lbl = MyLabel( lf, 'Steuerl. Überschuss/Verlust zurechnen auf Ehemann/Ehefrau (%):', 0, 1, 'nsw', 'w', padx, pady) lbl.grid_configure(columnspan=3) self._zurechng_ehemann = IntEntry(lf) ie = self._zurechng_ehemann ie.grid(column=3, row=1, sticky='nse', padx=padx, pady=pady) ie.setWidth(4) ie.setBackground('Whg.TEntry', 'lightyellow') ie.setValue(100) ie.registerModifyCallback(self._onWhgModified) self._zurechng_ehefrau = IntEntry(lf) ie2 = self._zurechng_ehefrau ie2.grid(column=4, row=1, sticky='nsw', padx=padx, pady=pady) ie2.setWidth(4) ie2.setBackground('Whg.TEntry', 'lightyellow') ie2.setValue(0) ie2.registerModifyCallback(self._onWhgModified) return lf
def _createAllgemeinFrame(self, row, padx, pady): lf = ttk.Labelframe(self, text='Allgemeine Daten', style='my.TLabelframe') lf.grid(column=0, row=row, sticky='nswe', padx=padx, pady=(pady + 8, pady)) ### Combo und Label für Etage col = 0 cbo = MyCombobox(lf) cbo.setItems((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)) cbo.setWidth(3) cbo.registerModifyCallback(self._onModified) cbo.grid(column=col, row=0, sticky='nswe', padx=padx, pady=pady) col += 1 self._cboEtage = cbo MyLabel(lf, '. Etage', col, 0, 'nswe', 'w', (0, padx), pady) #### Entry und Label für qm col += 1 ie = IntEntry(lf) ie.setWidth(3) ie.registerModifyCallback(self._onModified) ie.grid(column=col, row=0, sticky='nswe', padx=padx, pady=pady) self._ieQm = ie col += 1 lbl = MyLabel(lf, 'qm', col, 0, 'nswe', 'w', (0, padx), pady) ### Combo und Label für Zimmer col += 1 cbo = MyCombobox(lf) cbo.setItems((1, 1.5, 2, 2.5, 3, 3.5, 4, 5)) cbo.setIndex(2) cbo.setWidth(3) cbo.registerModifyCallback(self._onModified) cbo.grid(column=col, row=0, sticky='nswe', padx=padx, pady=pady) self._cboZimmer = cbo col += 1 MyLabel(lf, 'Zimmer', col, 0, 'nswe', 'w', (0, padx), pady) ### Entry und Label für Anteile col += 1 ie = IntEntry(lf) ie.setWidth(3) ie.grid(column=col, row=0, sticky='nswe', padx=padx, pady=pady) ie.registerModifyCallback(self._onModified) self._ieAnteil = ie col += 1 MyLabel(lf, 'Anteile am Gesamtobjekt', col, 0, 'nswe', 'w', (0, padx), pady) ### neue Zeile ### Checkbutton für Aufzug col = 0 cb = ttk.Checkbutton(lf, text='Aufzug im Haus', variable=self._ivarAufzug) cb.grid(column=col, row=1, columnspan=2, sticky='nswe', padx=padx, pady=pady) self._cbAufzug = cb ### neue Zeile ### Label und Entry für IBAN col = 0 lbl = MyLabel(lf, 'IBAN der WEG ', 0, 2, 'nswe', 'w', padx, pady) lbl.grid(columnspan=2) col += 2 te = TextEntry(lf, col, 2, 'nswe', (padx), pady) te.registerModifyCallback(self._onModified) te.grid(columnspan=5) self._teIbanWEG = te
def place_widgets(self): ROW = 0 self.frame_l = tk.Frame(self) self.frame_l.grid(row=0, column=0) self.frame_r = tk.Frame(self) self.frame_r.grid(row=0, column=1) # Heading MyHeading(self.frame_l, text="Mine bilar").grid(row=0, column=0, sticky=tk.W, pady=self.pady, padx=self.padx) MyLabel(self.frame_r, text="Merke:").grid(row=0, column=0, sticky=tk.W, pady=self.pady, padx=self.padx / 2) MyLabel(self.frame_r, text="Modell:").grid(row=1, column=0, sticky=tk.W, pady=self.pady, padx=self.padx / 2) MyLabel(self.frame_r, text="Årsmodell:").grid(row=2, column=0, sticky=tk.W, pady=self.pady, padx=self.padx / 2) MyLabel(self.frame_r, text="Kallenamn:", width=10).grid(row=3, column=0, sticky=tk.W, pady=self.pady, padx=self.padx / 2) self.l_make = MyLabel(self.frame_r, textvariable=self.make).grid(row=0, column=1, sticky=tk.W, pady=self.pady, padx=self.padx / 2) self.l_model = MyLabel(self.frame_r, textvariable=self.model).grid( row=1, column=1, sticky=tk.W, pady=self.pady, padx=self.padx / 2) self.l_year = MyLabel(self.frame_r, textvariable=self.year).grid(row=2, column=1, sticky=tk.W, pady=self.pady, padx=self.padx / 2) self.l_nick = MyLabel(self.frame_r, textvariable=self.nick).grid(row=3, column=1, sticky=tk.W, pady=self.pady, padx=self.padx / 2) # Car Labels for nick, ROW in zip( sorted([car["kallenamn"] for car in self.parent.cars]), range(len(self.parent.cars))): MyButton(self.frame_l, text=nick, fg="blue", command=lambda nick=nick: self.show_car_info(nick)).grid( row=ROW + 1, column=0, sticky=tk.W, pady=self.pady, padx=self.padx) MyButton(self.frame_l, text="Legg til ny bil", command=self.add_new_car).grid(row=ROW + 2, column=0, sticky=tk.W, pady=self.pady, padx=self.padx) MyButton(self.frame_l, text="Slett bil", command=self.delete_car).grid(row=ROW + 3, column=0, sticky=tk.W, pady=self.pady, padx=self.padx) MyButton(self.frame_l, text="Attende", command=lambda: self.parent.show_main(self)).grid( row=ROW + 4, column=0, sticky=tk.W, padx=self.padx, pady=self.pady)
def add_new_car(self): root = tk.Toplevel(self) MyLabel(root, text="Merke:").grid(row=0, column=0, sticky=tk.W, pady=self.pady, padx=self.padx) MyLabel(root, text="Modell:").grid(row=1, column=0, sticky=tk.W, pady=self.pady, padx=self.padx) MyLabel(root, text="Årsmodell:").grid(row=2, column=0, sticky=tk.W, pady=self.pady, padx=self.padx) MyLabel(root, text="Kallenamn:").grid(row=3, column=0, sticky=tk.W, pady=self.pady, padx=self.padx) l_make = MyEntry(root) l_make.grid(row=0, column=1, sticky=tk.W, pady=self.pady, padx=self.padx) l_model = MyEntry(root) l_model.grid(row=1, column=1, sticky=tk.W, pady=self.pady, padx=self.padx) l_year = MyEntry(root) l_year.grid(row=2, column=1, sticky=tk.W, pady=self.pady, padx=self.padx) l_nick = MyEntry(root) l_nick.grid(row=3, column=1, sticky=tk.W, pady=self.pady, padx=self.padx) l_make.focus_set() def add_car(): new_car = {} new_car["merke"] = l_make.get() new_car["modell"] = l_model.get() new_car["årsmodell"] = l_year.get() new_car["kallenamn"] = l_nick.get() # Update text variables self.make.set(new_car["merke"]) self.model.set(new_car["modell"]) self.year.set(new_car["årsmodell"]) self.nick.set(new_car["kallenamn"]) # Create new car and update window self.parent.cars.append(new_car) self.parent.dump_cars() self.update_widgets() root.destroy() MyButton(root, text="Legg til", command=add_car).grid(row=4, column=0, sticky=tk.W, pady=self.pady, padx=self.padx) MyButton(root, text="Avbryt ", command=root.destroy).grid(row=5, column=0, sticky=tk.W, pady=self.pady, padx=self.padx)
def _createUI(self): padx = pady = 5 self.columnconfigure(1, weight=1) MyLabel(self, 'Straße: ', 0, 0, 'nswe', 'e', padx, pady) self._teStrasse = TextEntry(self, 1, 0, 'nswe', padx, pady) self._teStrasse.setBackground('My.TEntry', 'lightyellow') self._teStrasse.setWidth(30) self._teStrasse.registerModifyCallback(self._onWohnungModified) MyLabel(self, 'PLZ/Ort: ', 0, 1, 'nswe', 'e', padx, pady) f = ttk.Frame(self) f.columnconfigure(1, weight=1) self._tePlz = TextEntry(f, 0, 0, 'nsw', padx=(0, 3)) self._tePlz['width'] = 6 self._tePlz.setBackground('My.TEntry', 'lightyellow') self._tePlz.registerModifyCallback(self._onWohnungModified) self._teOrt = TextEntry(f, 1, 0, 'nswe') self._teOrt.setBackground('My.TEntry', 'lightyellow') self._teOrt.setWidth(30) self._teOrt.registerModifyCallback(self._onWohnungModified) f.grid(column=1, row=1, sticky='nswe', padx=padx, pady=pady) MyLabel(self, 'Whg.-Bez.: ', 0, 2, 'nswe', 'e', padx, pady) self._teWhg_bez = TextEntry(self, 1, 2, 'nswe', padx, pady) self._teWhg_bez.setBackground('My.TEntry', 'lightyellow') self._teWhg_bez.registerModifyCallback(self._onWohnungModified) MyLabel(self, 'Angeschafft am: ', 0, 3, 'nswe', 'e', padx, pady) de = DateEntry(self) de.setUseCalendar(False) de['width'] = 10 de.grid(column=1, row=3, sticky='nw', padx=padx, pady=pady) self._deAngeschafft_am = de self._deAngeschafft_am.registerModifyCallback(self._onWohnungModified) MyLabel(self, 'Einhts.wert-Az: ', 0, 4, 'nswe', 'e', padx, pady) self._teEinhwert_az = TextEntry(self, 1, 4, 'nswe', padx, pady) #self._teEinhwert_az.grid(columnspan=2) self._teEinhwert_az.registerModifyCallback(self._onWohnungModified) MyLabel(self, 'Vermieter:', column=0, row=5, sticky='nse', anchor='e', padx=padx, pady=pady) cbo = MyCombobox(self) cbo.setReadonly(True) cbo.registerModifyCallback(self._onWohnungModified) cbo.grid(column=1, row=5, sticky='we', padx=padx, pady=pady) self._cboVermieter = cbo btn = ButtonFactory.getNewButton( self, 'Neuen Vermieter anlegen', partial(self._onAction, StammdatenAction.new_vermieter)) btn.grid(column=2, row=5, sticky='swe', padx=(0, 0), pady=pady) btnEdit = ButtonFactory.getEditButton( self, 'Vermieterdaten ändern', partial(self._onAction, StammdatenAction.edit_vermieter)) btnEdit.grid(column=3, row=5, sticky='swe', padx=(0, 0), pady=pady) MyLabel(self, 'Verwalter:', column=0, row=6, sticky='nse', padx=padx, pady=pady) cbo = MyCombobox(self) cbo.setReadonly(True) cbo.registerModifyCallback(self._onWohnungModified) cbo.grid(column=1, row=6, sticky='we', padx=padx, pady=pady) self._cboVerwalter = cbo btn2 = ButtonFactory.getNewButton( self, 'Neuen Verwalter anlegen', partial(self._onAction, StammdatenAction.new_verwalter)) btn2.grid(column=2, row=6, sticky='swe', padx=(0, 0), pady=pady) btnEdit2 = ButtonFactory.getEditButton( self, 'Verwalterdaten ändern', partial(self._onAction, StammdatenAction.edit_verwalter)) btnEdit2.grid(column=3, row=6, sticky='swe', padx=(0, 0), pady=pady) f: ttk.Frame = self._createSaveCancelButtons() f.grid(column=1, columnspan=3, sticky='e', padx=padx, pady=pady)
class EditableGroup(ttk.Frame, ABC): def __init__(self, parent, title: str = None): ttk.Frame.__init__(self, parent) self._functionBar = None self._groupLabel = None self._groupBox = None self._xgroupdata = None self._actionCallback = None padx = pady = 5 self._functionBar = self._createLabelAndFunctionBar(title, padx, pady) self._functionBar.grid(column=0, row=0, sticky='swe', padx=padx, pady=0) #self._createFunctionBar(title, padx, pady) self._createGroupBox(padx, pady) self.createGroupBoxContent() self.columnconfigure(0, weight=1) def _createLabelAndFunctionBar(self, title: str, padx: int, pady: int): f = ttk.Frame(self) f.columnconfigure(1, weight=1) self._groupLabel = MyLabel(f, text=title, column=0, row=0, sticky='sw', pady=0) funcbar = EditSaveFunctionBar(f, self._onAction) funcbar.grid(column=1, row=0, sticky='se', pady=0) return f def _createFunctionBar(self, title: str, padx, pady) -> None: fb = ttk.Frame(self) fb.grid(column=0, row=0, sticky='ne', padx=padx, pady=0) #self._groupLabel = MyLabel(fb, text=title, column=0, row=0, sticky='sw', pady=0) # cbo = MyCombobox(fb) # cbo.setReadonly(True) # cbo.setItems(('item1', 'item2')) # cbo.grid(column=1, row=0, padx=(3, 0), pady=3, sticky='ne') # self._cbo = cbo buttonframe = self._createButtonFrame(fb) buttonframe.grid(column=2, row=0, padx=10, pady=(0, 3), sticky='nw') self._functionBar = fb def _createButtonFrame(self, parent): # Frame containing buttons: frame = ttk.Frame(parent) # Button style s = ttk.Style() s.theme_use('clam') s.configure("My.TButton", padding=0, relief="flat", borderwith=0) # Button "Choose" self.dropdownpng = PhotoImage(file=imagepath + "/dropdown_22x22.png") self.chooseBtn = ttk.Button( frame, image=self.dropdownpng, style="My.TButton", command=partial(self._onAction, EditableGroupAction.choose)) self.chooseBtn.grid(column=0, row=0, sticky=(N, W)) ToolTip(self.chooseBtn, 'Gewünschten Datensatz aus einer Liste wählen') # Button "Edit" self.editpng = PhotoImage(file=imagepath + "/edit_22x22.png") self.editBtn = ttk.Button(frame, image=self.editpng, style="My.TButton", command=partial(self._onAction, EditableGroupAction.edit)) self.editBtn.grid(column=1, row=0, sticky=(N, W)) ToolTip(self.editBtn, 'Daten ändern') # Button "New" self.newpng = PhotoImage(file=imagepath + "/plus_22x22.png") self.newBtn = ttk.Button(frame, image=self.newpng, style="My.TButton", command=partial(self._onAction, EditableGroupAction.new)) self.newBtn.grid(column=2, row=0, sticky=(N, W)) ToolTip(self.newBtn, 'Neuen Datensatz anlegen') # Button "Save" self.savepng = PhotoImage(file=imagepath + "/save_22x22.png") self.saveBtn = ttk.Button(frame, image=self.savepng, style="My.TButton", command=partial(self._onAction, EditableGroupAction.save)) self.saveBtn.grid(column=3, row=0, sticky=(N, W)) ToolTip(self.saveBtn, 'Änderungen speichern') return frame def _createGroupBox(self, padx, pady): gp = ttk.Frame(self, relief='groove', borderwidth=1) gp.grid(column=0, row=1, sticky='nswe', padx=padx, pady=0) self._groupBox = gp def _onAction(self, action: EditableGroupAction): if self._actionCallback: self._actionCallback(action) def registerActionCallback(self, cb): self._actionCallback = cb def setGroupTitle(self, title: str) -> None: self._groupLabel.setValue(title) def setComboItems(self, items: list or tuple): self._cbo.setItems(items) def getComboItems(self) -> list or tuple: return self._cbo.getItems() def getSelectedComboIndex(self) -> int: return self._cbo.getCurrentIndex() def getGroupBoxFrame(self) -> ttk.Frame: return self._groupBox @abstractmethod def createGroupBoxContent(self) -> None: # when you're adding your widgets to the box you will need to # specify the appropriate parent (this groupbox). # You can get it by calling self.getGroupBoxFrame() pass
def createGroupBoxContent(self) -> None: box = self.getGroupBoxFrame() padx = pady = 3 topy = 12 row = 0 v = IntVar() self._rbFrau = ttk.Radiobutton(box, text='Frau', variable=v, value=1) self._rbFrau.grid(column=1, row=row, sticky='nsw', padx=padx, pady=(topy, pady)) self._rbHerr = ttk.Radiobutton(box, text='Herr', variable=v, value=2) self._rbHerr.grid(column=2, row=row, sticky='nsw', padx=padx, pady=(topy, pady)) self._rbFirma = ttk.Radiobutton(box, text='Firma', variable=v, value=3) self._rbFirma.grid(column=3, row=row, sticky='nsw', padx=padx, pady=(topy, pady)) row += 1 l = MyLabel(box, text='Name:', column=0, row=row, sticky='ne', padx=padx, pady=pady, align='e') self._teName = TextEntry(box, column=1, row=row, sticky='nwe', padx=padx, pady=pady) self._teName.grid(columnspan=3) row += 1 MyLabel(box, text='ggf. Vorname:', column=0, row=row, sticky='ne', padx=padx, pady=pady, align='e') self._teVorname = TextEntry(box, column=1, row=row, sticky='nwe', padx=padx, pady=pady) self._teVorname.grid(columnspan=3) row += 1 l = MyLabel(box, text='Straße:', column=0, row=row, sticky='ne', padx=padx, pady=pady, align='e') self._teStrasse = TextEntry(box, column=1, row=row, sticky='nwe', padx=padx, pady=pady) self._teStrasse.setWidth(35) self._teStrasse.grid(columnspan=3) row += 1 #PLZ/Ort l = MyLabel(box, text='PLZ / Ort:', column=0, row=row, sticky='ne', padx=padx, pady=pady, align='e') f = ttk.Frame(box) self._tePlz = TextEntry(f, column=0, row=0, sticky='nw', padx=padx, pady=pady) self._tePlz.setWidth(6) self._teOrt = TextEntry(f, column=1, row=0, sticky='ne', padx=padx, pady=pady) f.grid(column=1, columnspan=3, row=row, sticky='nswe', padx=0, pady=0) self._teOrt.setWidth(30)
def _createMieterFrame(self, row, xmargins: int, topmargin: int, bottommargin: int): padx = xmargins pady = (topmargin, bottommargin) lf = ttk.Labelframe(self, text='Mieter', style='my.TLabelframe') lf.grid(column=0, row=row, sticky='nswe', padx=padx, pady=pady) padx = (5, 6) pady = (5, 5) col = row = 0 ######### Anrede MyLabel(lf, 'Anrede:', col, row, 'nswe', 'w', padx, pady) col += 1 cbo = MyCombobox(lf) cbo.setItems(('Frau', 'Herr')) cbo.setWidth(4) cbo.registerModifyCallback(self._onModified) cbo.grid(column=col, row=row, sticky='nsw', padx=padx, pady=pady) self._cboAnrede = cbo ######### Name col += 1 MyLabel(lf, 'Name:', col, row, 'nswe', 'w', padx, pady) col += 1 te = TextEntry(lf, col, row, 'nswe', padx, pady) te.registerModifyCallback(self._onModified) self._teName = te ######### Vorname col += 1 MyLabel(lf, 'Vorname:', col, row, 'nswe', 'w', padx, pady) col += 1 te = TextEntry(lf, col, row, 'nswe', padx, pady) te.registerModifyCallback(self._onModified) self._teVorname = te ######### Geburtstag row += 1 col = 0 MyLabel(lf, 'Geburtstag:', col, row, 'nswe', 'w', padx, pady) col += 1 te = TextEntry(lf, col, row, 'nswe', padx, pady) te.registerModifyCallback(self._onModified) self._teGeboren_am = te ######### Perso-Nr. col += 1 MyLabel(lf, 'Personalausweis-Nr.:', col, row, 'nswe', 'w', padx, pady) col += 1 te = TextEntry(lf, col, row, 'nswe', padx, pady) te.grid(columnspan=2) te.registerModifyCallback(self._onModified) self._teAusweisId = te ######## Telefon row += 1 col = 0 MyLabel(lf, 'Telefon:', col, row, 'nswe', 'w', padx, pady) col += 1 te = TextEntry(lf, col, row, 'nswe', padx, pady) te.registerModifyCallback(self._onModified) self._teTelefon = te ######### mailto col += 1 MyLabel(lf, 'Mailto:', col, row, 'nswe', 'w', padx, pady) col += 1 te = TextEntry(lf, col, row, 'nswe', padx, pady) te.grid(columnspan=2) te.registerModifyCallback(self._onModified) self._teMailto = te ######## Bankverbindung row += 1 col = 0 MyLabel(lf, 'IBAN:', col, row, 'nswe', 'w', padx, pady) col += 1 te = TextEntry(lf, col, row, 'nswe', padx, pady) te.registerModifyCallback(self._onModified) te.grid(columnspan=2) self._teIban = te
def _createUI(self, padx, pady) -> None: r = c = 0 lf = ttk.Frame(self) lf.grid(column=c, row=r, sticky='nswe', padx=10, pady=10) ########### Wohnung and Year header ####################### col = 1 for i in range(self._nWhg): ident = self._jdcoll_list[i].getWohnungIdent() col_span = self._nYears lbl = MyLabel(lf, text=ident, column=col, row=r, sticky='nwe', anchor='center', padx=padx, pady=pady) lbl.grid(columnspan=col_span) col += col_span r += 1 col = 1 for n in range(self._nWhg): for i in range(self._nYears): year = str(self._yearlist[i]) lbl = MyLabel(lf, text=year, column=col, row=r, sticky='swe', anchor='center', padx=padx, pady=pady) lbl['style'] = 'year.TLabel' col += 1 r += 1 ####regelmäßige Ein-/Auszahlungen############## lbl = MyLabel(lf, text='Regelmäßige\nEin-/Auszahlungen', column=c, row=r, sticky='nw', anchor='w', padx=1, pady=pady) lbl['style'] = 'fat.TLabel' r += 1 lbl = MyLabel(lf, text='Nettomiete', column=c, row=r, sticky='nw', anchor='w', padx=padx, pady=pady) self._createOut(lf, Vergleichswert.nettomiete, r, pady) r += 1 lbl = MyLabel(lf, text='NK-Voraus', column=c, row=r, sticky='nw', anchor='w', padx=padx, pady=pady) self._createOut(lf, Vergleichswert.nk_voraus, r, pady) r += 1 lbl = MyLabel(lf, text='HG-Voraus', column=c, row=r, sticky='nw', anchor='w', padx=padx, pady=pady) self._createOut(lf, Vergleichswert.hg_voraus, r, pady) r += 1 ####### sonstige Ein-/Auszahlungen ################ lbl = MyLabel(lf, text='Sonstige\nEin-/Auszahlungen', column=c, row=r, sticky='nw', anchor='w', padx=1, pady=(20, pady)) lbl['style'] = 'fat.TLabel' r += 1 lbl = MyLabel(lf, text='Rechnungen und\nEntnahme Rücklagen', column=c, row=r, sticky='nw', anchor='w', padx=padx, pady=pady) self._createOut(lf, Vergleichswert.rechng, r, 10) r += 1 lbl = MyLabel(lf, text='sonst. Kosten', column=c, row=r, sticky='nw', anchor='w', padx=padx, pady=pady) self._createOut(lf, Vergleichswert.sonst_kosten, r, pady) r += 1 lbl = MyLabel(lf, text='NK-Abrechnung', column=c, row=r, sticky='nw', anchor='w', padx=padx, pady=pady) self._createOut(lf, Vergleichswert.nk_abrechng, r, pady) r += 1 lbl = MyLabel(lf, text='HG-Abrechnung', column=c, row=r, sticky='nw', anchor='w', padx=padx, pady=pady) self._createOut(lf, Vergleichswert.hg_abrechng, r, pady) r += 1 ###### Ergebnis ################### py = (25, 0) lbl = MyLabel(lf, text='Ergebnis', column=c, row=r, sticky='nw', anchor='w', padx=1, pady=py) lbl['style'] = 'bigfat.TLabel' #self._rowList.append((r, 22)) self._createOut(lf, Vergleichswert.ergebnis, r, py) r += 1 ######### Sonderumlagen ##################### py = (15, 0) lbl = MyLabel(lf, text='Sonderumlagen', column=c, row=r, sticky='nw', anchor='w', padx=1, pady=py) lbl['style'] = 'fat.TLabel' self._createOut(lf, Vergleichswert.sonderumlage, r, py) r += 1 ######### Ein-/Auszahlungen je qm ##################### py = (15, 3) lbl = MyLabel(lf, text='Ein-/Auszahlungen\nje qm u. Monat', column=c, row=r, sticky='nw', anchor='w', padx=1, pady=py) lbl['style'] = 'fat.TLabel' r += 1 lbl = MyLabel(lf, text='Nettomiete', column=c, row=r, sticky='nw', anchor='w', padx=padx, pady=pady) self._createOut(lf, Vergleichswert.nettomiete_qm, r, pady) r += 1 lbl = MyLabel(lf, text='NK', column=c, row=r, sticky='nw', anchor='w', padx=padx, pady=pady) self._createOut(lf, Vergleichswert.nk_qm, r, pady) r += 1 lbl = MyLabel(lf, text='HG gesamt', column=c, row=r, sticky='nw', anchor='w', padx=padx, pady=pady) self._createOut(lf, Vergleichswert.hg_ges_qm, r, pady) r += 1 lbl = MyLabel(lf, text='davon Rücklagen', column=c, row=r, sticky='nw', anchor='w', padx=padx, pady=pady) self._createOut(lf, Vergleichswert.rueck_qm, r, pady) if self._nWhg > 1: col = self._nYears for n in range(self._nWhg - 1): ttk.Separator(lf, orient=VERTICAL).\ grid(column=col, row=0, rowspan=r+1, sticky='nse') col += self._nYears self._outputLabelframe = lf