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 _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 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)
class SignInDialog(DialogBase): def __init__(self, parent): DialogBase.__init__(self, parent) self.title("Sign in") self.setValidationCallback(self.validate) self._teName = None self._tePwd = None self._createFields() self.resizable(False, False) self._tePwd.focus() def validate(self) -> str or None: if len(self._teName.getValue()) < 1: return "Bitte Namen eingeben." if len(self._tePwd.getValue()) < 1: return "Bitte Passwort eingeben." return None 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 setName(self, name: str) -> None: self._teName.setValue(name) def getNameAndPassword(self) -> List[str]: return (self._teName.getValue(), self._tePwd.getValue())
class VermieterGroup(AddressGroup): def __init__(self, parent): AddressGroup.__init__(self, parent) self.setGroupTitle('Vermieterdaten') self._teSteuernummer = None #TextEntry 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 _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 _createTags(self, parent, row, col, padx, pady): Label(parent, text="Tags: ").grid(row=row, column=col, sticky='nw', padx=padx, pady=pady) col += 1 tags = TextEntry(parent) tags.grid(row=row, column=col, sticky='nwe', padx=padx, pady=pady) tags.bind('<Control-s>', self._onCtrlS) ToolTip(tags, "Enter as many comma-separated tags as you want") return tags
def _createTitle(self, parent, row, col, padx, pady) -> TextEntry: Label(parent, text="Caption: ").grid(row=row, column=col, sticky='nw', padx=padx, pady=pady) col += 1 title = TextEntry(parent) title.grid(row=row, column=col, sticky='nwe', padx=padx, pady=pady) title.bind('<Control-s>', self._onCtrlS) ToolTip(title, "This caption will be used to display this note in the tree") return title
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 _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 StammdatenView(ttk.Frame): def __init__(self, parent): ttk.Frame.__init__(self, parent) self._teStrasse = None self._tePlz = None self._teOrt = None self._teWhg_bez = None self._deAngeschafft_am = None self._teEinhwert_az = None self._cboVermieter = None self._cboVerwalter = None self._xwhgdatacopy = None self._btnSave = None self._btnCancel = None self._isModified = False self._modifyCallback = None self._actionCallback = None self._createUI() self._teStrasse.focus() 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) def _createSaveCancelButtons(self) -> ttk.Frame: f = ttk.Frame(self) btn = ttk.Button(f, text='Speichern', state='disabled', command=partial(self._onAction, StammdatenAction.save_changes)) btn.grid(column=0, row=0, sticky='nsw') self._btnSave = btn btn = ttk.Button(f, text='Verwerfen', state='disabled', command=partial(self._onAction, StammdatenAction.revert_changes)) btn.grid(column=1, row=0, sticky='nsw') self._btnCancel = btn return f def setButtonText(self, okbtntext: str, cancelbtntext: str) -> None: self._btnSave['text'] = okbtntext self._btnCancel['text'] = cancelbtntext def setButtonState(self, okbtnstate: str = None, cancelbtnstate: str = None) -> None: if okbtnstate: self._btnSave['state'] = okbtnstate if cancelbtnstate: self._btnCancel['state'] = cancelbtnstate def getButtonState(self) -> List[str]: return (self._btnSave['state'], self._btnCancel['state']) def _onWohnungModified(self, widget: Widget, name: str, index: str, mode: str): self._isModified = True if self._modifyCallback: self._modifyCallback() def _onAction(self, action, arg=None): if self._actionCallback: self._actionCallback(action, self.getData(), self._xwhgdatacopy) if action == StammdatenAction.save_changes or \ action == StammdatenAction.revert_changes: self._isModified = False def registerModifyCallback(self, callback) -> None: #function to register takes no arguments self._modifyCallback = callback def registerActionCallback(self, callback) -> None: #function to register has to take three arguments: # - StammdatenAction # - XWohnungDaten # - XWohnungDaten (values before modifying) self._actionCallback = callback def isModified(self) -> bool: return self._isModified def setData(self, data: XWohnungDaten) -> None: self._teStrasse.setValue(data.strasse) self._tePlz.setValue(data.plz) self._teOrt.setValue(data.ort) self._teWhg_bez.setValue(data.whg_bez) self._deAngeschafft_am.setValue(data.angeschafft_am) self._teEinhwert_az.setValue(data.einhwert_az) self._cboVermieter.setValue(data.vermieter) self._cboVerwalter.setValue(data.verwalter) self._isModified = False self.setButtonState('disabled', 'disabled') self._xwhgdatacopy = deepcopy(data) def setVerwalterList(self, vwlist: List[str]): self._cboVerwalter.setItems(vwlist) def setVerwalter(self, verwalter: str): self._cboVerwalter.setValue(verwalter) def setVermieterList(self, vmlist: List[str]): self._cboVermieter.setItems(vmlist) def getData(self) -> XWohnungDaten: d: XWohnungDaten = XWohnungDaten() if self._xwhgdatacopy: # _xwhgdatacopy only exists in editing mode, not in new mode d.whg_id = self._xwhgdatacopy.whg_id d.strasse = self._teStrasse.getValue() d.plz = self._tePlz.getValue() d.ort = self._teOrt.getValue() d.whg_bez = self._teWhg_bez.getValue() d.angeschafft_am = self._deAngeschafft_am.getValue() d.einhwert_az = self._teEinhwert_az.getValue() d.verwalter = self._cboVerwalter.getValue() d.vermieter = self._cboVermieter.getValue() # d.verwalter_list = self._cboVerwalter.getItems() # d.vermieter_list = self._cboVermieter.getItems() return d def clear(self): self._teStrasse.clear() self._teWhg_bez.clear() self._tePlz.clear() self._teOrt.clear() self._teEinhwert_az.clear() self._deAngeschafft_am.clear() self._xwhgdatacopy = None
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 _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)
class VerwalterView(ttk.Frame): def __init__(self, parent): ttk.Frame.__init__(self, parent) self._xverwaltercpy = None self._verwalter_id = -1 self._teFirma = None self._teStrasse = None self._tePlz = None self._teOrt = None self._teTelefon = None self._teEmail = None self._btnSave = None self._btnCancel = None self._isModified = False self._modifyCallback = None self._actionCallback = None self._createUI() self._teFirma.focus() 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 _createSaveCancelButtons(self) -> ttk.Frame: f = ttk.Frame(self) btn = ttk.Button(f, text='Speichern', state='disabled', command=partial(self._onAction, StammdatenAction.save_changes)) btn.grid(column=0, row=0, sticky='nsw') self._btnSave = btn btn = ttk.Button(f, text='Abbrechen', state='disabled', command=partial(self._onAction, StammdatenAction.revert_changes)) btn.grid(column=1, row=0, sticky='nsw') self._btnCancel = btn return f def registerModifyCallback(self, callback) -> None: #function to register takes no arguments self._modifyCallback = callback def registerActionCallback(self, callback) -> None: #function to register has to take three arguments: # - StammdatenAction # - XVerwalter # - XVerwalter (values before been modified) self._actionCallback = callback def isModified(self) -> bool: return self._isModified def setButtonState(self, okbtnstate:str, cancelbtnstate:str) -> None: self._btnSave['state'] = okbtnstate #one of 'normal', 'disabled' self._btnCancel['state'] = cancelbtnstate # one of 'normal', 'disabled' def setData(self, data:XVerwalter) -> None: self._xverwaltercpy = deepcopy(data) self._verwalter_id = data.verwalter_id self._teFirma.setValue(data.firma) self._teStrasse.setValue(data.strasse) self._tePlz.setValue(data.plz) self._teOrt.setValue(data.ort) self._teTelefon.setValue(data.telefon) self._teEmail.setValue(data.email) self._isModified = False def getData(self) -> XVerwalter: xdata:XVerwalter = XVerwalter() xdata.verwalter_id = self._verwalter_id xdata.firma = self._teFirma.getValue() xdata.strasse = self._teStrasse.getValue() xdata.plz = self._tePlz.getValue() xdata.ort = self._teOrt.getValue() xdata.telefon = self._teTelefon.getValue() xdata.email = self._teEmail.getValue() return xdata def clear(self) -> None: self._xverwaltercpy = None self._verwalter_id = -1 self._teFirma.clear() self._teStrasse.clear() self._tePlz.clear() self._teOrt.clear() self._teTelefon.clear() self._teEmail.clear() self._isModified = False def _onVerwalterModified(self, widget: Widget, name: str, index: str, mode: str) -> None: self._isModified = True if self._modifyCallback: self._modifyCallback() def _onAction(self, action, arg=None): if self._actionCallback: self._actionCallback(action, self.getData(), self._xverwaltercpy) if action == StammdatenAction.save_changes or \ action == StammdatenAction.revert_changes: self._isModified = False
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 _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