入力欄でEnterを押したときの処理を追加

This commit is contained in:
suti7yk5032 2024-07-25 16:17:33 +09:00
parent 451ea60140
commit e23662422e

View file

@ -121,6 +121,7 @@ class Lock(customtkinter.CTkToplevel):
self.password_entry = customtkinter.CTkEntry(self.input_frame, placeholder_text='パスワード', show='*', font=self.textbox_font) self.password_entry = customtkinter.CTkEntry(self.input_frame, placeholder_text='パスワード', show='*', font=self.textbox_font)
self.password_entry.grid(row=0, column=0, padx=10, sticky="ew") self.password_entry.grid(row=0, column=0, padx=10, sticky="ew")
self.password_entry.bind("<Return>", self.auth_start_ev)
self.button_frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color='transparent') self.button_frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color='transparent')
self.button_frame.grid(row=3, column=0, padx=10, pady=10, sticky="nsew") self.button_frame.grid(row=3, column=0, padx=10, pady=10, sticky="nsew")
@ -136,7 +137,7 @@ class Lock(customtkinter.CTkToplevel):
self.signin_button = customtkinter.CTkButton(self.button_frame, text='ヘルプ', command=self.help_dummy, font=self.button_font) self.signin_button = customtkinter.CTkButton(self.button_frame, text='ヘルプ', command=self.help_dummy, font=self.button_font)
self.signin_button.grid(row=0, column=0, padx=10, sticky="w") self.signin_button.grid(row=0, column=0, padx=10, sticky="w")
self.keyboard_listener_thread = threading.Thread(target=self.keyboard_listener) self.keyboard_listener_thread = threading.Thread(target=self.keyboard_listener)
self.keyboard_listener_thread.daemon = True self.keyboard_listener_thread.daemon = True
self.keyboard_listener_thread.start() self.keyboard_listener_thread.start()
@ -156,6 +157,12 @@ class Lock(customtkinter.CTkToplevel):
auth_thread.daemon = True auth_thread.daemon = True
auth_thread.start() auth_thread.start()
def auth_start_ev(self, event):
auth_thread = threading.Thread(target=self.auth)
auth_thread.daemon = True
auth_thread.start()
def auth(self): def auth(self):
password = str(self.password_entry.get()) password = str(self.password_entry.get())
if len(password) == 10: if len(password) == 10: