From b2ede4d5a45f8498e0849306c4ae6ea204cc2f98 Mon Sep 17 00:00:00 2001 From: Alexander Malzkuhn Date: Thu, 17 Apr 2025 10:26:33 +0200 Subject: [PATCH] =?UTF-8?q?Pin=20Pad=20in=20Klasse=20=C3=BCberf=C3=BChrt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __pycache__/definitions.cpython-311.pyc | Bin 462 -> 619 bytes __pycache__/users.cpython-311.pyc | Bin 0 -> 5202 bytes ui.py | 140 +++++++++++++----------- 3 files changed, 78 insertions(+), 62 deletions(-) create mode 100644 __pycache__/users.cpython-311.pyc diff --git a/__pycache__/definitions.cpython-311.pyc b/__pycache__/definitions.cpython-311.pyc index 5c90a03f295d63600f86411b50ec18528f819541..29fae7fdb9cdede967718f26031071e4662b23c8 100644 GIT binary patch delta 229 zcmX@d{F;StIWI340}z~D$&eAoIFV0+v2UV!ohWM*X9`;sR|9=@Ofx@Z9C8@ausW~OLcoR#D5nN5) ziRZ&?Zi$o@rxw9XNXyJg%}dNpy~PVQ1kU9wE=epYEsoF3yTt`%=9iXCR%Hz25(he! q5r~W9CpR#b*zlR44SMHcPTSza!wX!44b@?F_23T XsEiSai`^!(Fu8Iza5Zoh@dNn)(Z~@0 diff --git a/__pycache__/users.cpython-311.pyc b/__pycache__/users.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1fb46983f8b6b8227c99fff15640455a513c12a1 GIT binary patch literal 5202 zcmdT|U2GKB6~6Pgf1b5>y^C$I35&78TZ0$dr41BZoM2LZ;x-~LY(iFB&)8nGKhDfp z7;BwcRUQ^(2`3`8NsVHul)5EVQPs5RTTEK@rImK9saTC<38~_Nr!IvDToPBC!-13bdQgw zv{b3;RJEu!p+;g!7;CYq32mq_BYiN1%9H)T%oCa5KY@S2fGwQF0_D-#upse3ZPZ4) zWCI)RCXY4@mHq)JK%Rr&lSQgc16nK+GX<)F9|CKR+Os8vBl3ig{~<&r8kY;u;?G{~B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X2?UgcdqSzefw&CyI#M~sNV-Usr!I| z=PBcCzw6KWo8|{U94s8!0|=CM+C|A@6ncuJ+_n`*(YsmdfkV9Jy6UrpY!|Jk;Fo?GGheusUfh554=W zDQO~(ycmhRI}wdrJqpHh8gpsxqu^OiSNWHOrs>wQV{WJ*al=pjA&{BUm1j8t<5C56 z@j?qE8bu=33Xpe{NT62Oh1CKH)CmoFvYA-Z)01<+nu* zB@3k*V<$G8($kP5(AV**iSTg27nLVJ0WwcUAO*Q_65crqD)CXCZ0i)`1+r-Vrc#+C zK&B2SV)?sFwfVm}k!C(%XJ0!=mdA*MnqZ1Q8NSkih~WKFi~pvg#u zPX*MU>#n15$i(rjv2W@nWFrVEwd-g+H584jeZUm^ahcVlKxRl*ykOmP-JiAoZr>jc z{Pw_~*+1F;BHk1K7S5gz>&M?Rj=!b%ylwQn4T70BN&~1b;gCi{O*`raD+~6~ePs&N zfJ!4xSJ^P-3=G7d+D0wOQA=*Ji>{v^(VM!ArY@LD7cUs%g_(g|jc4YpHKS-PO(P6a zT7j4~l01wbJYuP&YJGCST|&RR&@U}Co3QcUAIx zL>MOTB8+RsiC2!)&Cn}HYG&y5fQ)6o&YgFBhXH78CXcc0X}KfKu#6Y7icN%C{U4ZF BI1T^+ literal 0 HcmV?d00001 diff --git a/ui.py b/ui.py index ea4b0a8..4cfebe5 100644 --- a/ui.py +++ b/ui.py @@ -10,83 +10,99 @@ from definitions import app_title, app_version # Pinpad -def win_pinpad(): +class win_pinpad(tk.Toplevel): + def __init__(self, parent): + super().__init__(parent) - def update_time(): - string_time = strftime('%A, der %d.%m.%Y - %H:%M:%S') - nonlocal digital_clock - digital_clock.config(text=string_time) - digital_clock.after(1000, update_time) + def update_time(): + string_time = strftime('%A, der %d.%m.%Y - %H:%M:%S') + nonlocal digital_clock + digital_clock.config(text=string_time) + digital_clock.after(1000, update_time) - root = tk.Tk() - root.title(app_title + " " + app_version) - root.eval('tk::PlaceWindow . center') + self.title(app_title + " " + app_version) - # Digital clock label configuration - digital_clock = tk.Label(root) - digital_clock.grid(row=0, column=0, columnspan=3, padx=10, pady=10) - # Initial call to update_time function - update_time() + # Digital clock label configuration + digital_clock = tk.Label(self) + digital_clock.grid(row=0, column=0, columnspan=3, padx=10, pady=10) + # Initial call to update_time function + update_time() - # Benutzernummer - def usernr_changed(UserNr): - nonlocal usernr - if len(str(usernr.get())) > 0: - buttons["OK"].configure(state="active") - else: - buttons["OK"].configure(state="disabled") + # Benutzernummer + def usernr_changed(UserNr): + nonlocal usernr + if len(str(usernr.get())) > 0: + buttons["OK"].configure(state="active") + else: + buttons["OK"].configure(state="disabled") - tk.Label(root, text="Benutzernummer:").grid(row=1, column=0) - UserNr = tk.StringVar() - UserNr.trace("w", lambda name, index, mode, UserNr=UserNr: usernr_changed(UserNr)) - usernr = tk.Entry(root, width=10, textvariable=UserNr) - usernr.grid(row=1,column=1) + tk.Label(self, text="Benutzernummer:").grid(row=1, column=0) + UserNr = tk.StringVar() + UserNr.trace("w", lambda name, index, mode, UserNr=UserNr: usernr_changed(UserNr)) + usernr = tk.Entry(self, width=10, textvariable=UserNr) + usernr.grid(row=1,column=1) - # Pinpad + # Pinpad - def buttonPress(key): + def buttonPress(key): - nonlocal usernr - if type(key) is int: - if key < 10: - usernr.insert('end', str(key)) - if key =="OK": - print("OK pressed") - if key == "<-": - usernr.delete(usernr.index("end") - 1 ) - if len(usernr.get()) > 0: - buttons["OK"].configure(state="active") - else: - buttons["OK"].configure(state="disabled") + nonlocal usernr + if type(key) is int: + if key < 10: + usernr.insert('end', str(key)) + if key =="OK": + print("OK pressed") + if key == "<-": + usernr.delete(usernr.index("end") - 1 ) + if len(usernr.get()) > 0: + buttons["OK"].configure(state="active") + else: + buttons["OK"].configure(state="disabled") - # Buttons definieren - button_width = 7 - button_height = 3 - pinframe = tk.Frame(root) - pinframe.grid(row=2, column=0, columnspan=3, padx=10, pady=10) - buttons = { } + # Buttons definieren + button_width = 7 + button_height = 3 + pinframe = tk.Frame(self) + pinframe.grid(row=2, column=0, columnspan=3, padx=10, pady=10) + buttons = { } - keys = [ - [ 1, 2, 3], - [ 4, 5, 6], - [ 7, 8, 9], - [ "<-", 0, "OK"] - ] + keys = [ + [ 1, 2, 3], + [ 4, 5, 6], + [ 7, 8, 9], + [ "<-", 0, "OK"] + ] - for y, row in enumerate(keys, 1): - for x, key in enumerate(row): - button = tk.Button(pinframe, width=button_width, height=button_height, text=key, command=lambda key=key: buttonPress(key)) - button.grid(row=y, column=x) - buttons[key] = button + for y, row in enumerate(keys, 1): + for x, key in enumerate(row): + button = tk.Button(pinframe, width=button_width, height=button_height, text=key, command=lambda key=key: buttonPress(key)) + button.grid(row=y, column=x) + buttons[key] = button - buttons["OK"].configure(state="disabled") + buttons["OK"].configure(state="disabled") - usernr.focus_set() + usernr.focus_set() - # Tkinter main loop +class mainwindow(tk.Tk): + def __init__(self): + super().__init__() - root.mainloop() + self.geometry('300x200') + self.title('Main Window') + + # place a button on the root window + tk.Button(self, + text='Login Window', + command=self.open_window).pack(expand=True) + + def open_window(self): + window = win_pinpad(self) + window.grab_set() + + +if __name__ == "__main__": + app = mainwindow() + app.mainloop() -def win_userselection():