終了用のショートカットキーを追加
This commit is contained in:
parent
a6082c1f0a
commit
e3d9f73fd7
1 changed files with 23 additions and 12 deletions
|
@ -10,6 +10,7 @@ import hashlib
|
||||||
import string
|
import string
|
||||||
import random
|
import random
|
||||||
import tkinter
|
import tkinter
|
||||||
|
import threading
|
||||||
|
|
||||||
class App(customtkinter.CTk):
|
class App(customtkinter.CTk):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -72,29 +73,41 @@ class Lock(customtkinter.CTkToplevel):
|
||||||
self.lift()
|
self.lift()
|
||||||
self.protocol("WM_DELETE_WINDOW", self.handler_close)
|
self.protocol("WM_DELETE_WINDOW", self.handler_close)
|
||||||
|
|
||||||
|
self.title_font = customtkinter.CTkFont(family="meiryo", size=24, weight="bold")
|
||||||
|
self.general_font = customtkinter.CTkFont(family="meiryo", size=14)
|
||||||
|
self.general_small_font = customtkinter.CTkFont(family="meiryo", size=12)
|
||||||
|
|
||||||
self.msg_title_frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color='transparent')
|
self.msg_title_frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color='transparent')
|
||||||
self.msg_title_frame.grid(row=0, column=0, sticky="nsew")
|
self.msg_title_frame.grid(row=0, column=0, sticky="nsew")
|
||||||
|
|
||||||
self.msg_title_1 = customtkinter.CTkLabel(self.msg_title_frame, text='ちょっと待って!!')
|
self.msg_title_1 = customtkinter.CTkLabel(self.msg_title_frame, text='ちょっと待って!!', font=self.title_font, anchor=tkinter.W)
|
||||||
self.msg_title_1.grid(row=0, column=0, padx=10, pady=10)
|
self.msg_title_1.grid(row=0, column=0, padx=10, pady=10)
|
||||||
|
|
||||||
self.msg_subtitle_frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color='transparent')
|
self.msg_subtitle_frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color='transparent')
|
||||||
self.msg_subtitle_frame.grid(row=1, column=0, sticky="nsew")
|
self.msg_subtitle_frame.grid(row=1, column=0, sticky="nsew")
|
||||||
|
|
||||||
self.msg_subtitle_1 = customtkinter.CTkLabel(self.msg_subtitle_frame, text='サインインするには、パスワードが必要です。')
|
self.msg_subtitle_1 = customtkinter.CTkLabel(self.msg_subtitle_frame, text='サインインするには、パスワードが必要です。', font=self.general_font, anchor=tkinter.W)
|
||||||
self.msg_subtitle_1.grid(row=0, column=0, padx=10, pady=10)
|
self.msg_subtitle_1.grid(row=0, column=0, padx=10, pady=10)
|
||||||
|
|
||||||
self.input_frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color='transparent')
|
self.input_frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color='transparent')
|
||||||
self.input_frame.grid(row=2, column=0, sticky="nsew")
|
self.input_frame.grid(row=2, column=0, sticky="nsew")
|
||||||
|
|
||||||
self.password_entry = customtkinter.CTkEntry(self.input_frame, placeholder_text='パスワード', width=380, show='*')
|
self.password_entry = customtkinter.CTkEntry(self.input_frame, placeholder_text='パスワード', width=380, show='*', font=self.general_small_font)
|
||||||
self.password_entry.grid(row=0, column=0, padx=10, pady=10)
|
self.password_entry.grid(row=0, column=0, padx=10, pady=10)
|
||||||
|
|
||||||
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, sticky="nsew")
|
self.button_frame.grid(row=3, column=0, sticky="nsew")
|
||||||
|
|
||||||
self.signin_button = customtkinter.CTkButton(self.button_frame, text='サインイン', command=self.auth)
|
self.signin_button = customtkinter.CTkButton(self.button_frame, text='サインイン', command=self.auth, font=self.general_font)
|
||||||
self.signin_button.grid(row=0, column=0, padx=10, pady=10)
|
self.signin_button.grid(row=0, column=1, padx=10, pady=10)
|
||||||
|
self.signin_button.pack(padx=10, anchor=tkinter.E)
|
||||||
|
|
||||||
|
self.keyboard_listener_thread = threading.Thread(target=self.keyboard_listener)
|
||||||
|
self.keyboard_listener_thread.daemon = True
|
||||||
|
self.keyboard_listener_thread.start()
|
||||||
|
|
||||||
|
def keyboard_listener(self):
|
||||||
|
keyboard.add_hotkey('ctrl+shift+q', self.exit)
|
||||||
|
|
||||||
def hash_genarate(self, source):
|
def hash_genarate(self, source):
|
||||||
hashed = hashlib.md5(source.encode())
|
hashed = hashlib.md5(source.encode())
|
||||||
|
@ -111,19 +124,16 @@ class Lock(customtkinter.CTkToplevel):
|
||||||
except:
|
except:
|
||||||
master_password_hash = self.hash_genarate(str(self.password_entry.get()))
|
master_password_hash = self.hash_genarate(str(self.password_entry.get()))
|
||||||
if client_config["master_password_hash"] == master_password_hash:
|
if client_config["master_password_hash"] == master_password_hash:
|
||||||
self.destroy()
|
self.exit()
|
||||||
app.exit()
|
|
||||||
else:
|
else:
|
||||||
self.msg_subtitle_1.configure(text='サインインするには、パスワードが必要です。\nネットワークエラーが発生しています。\n続行するには、マスターパスワードを入力して下さい。')
|
self.msg_subtitle_1.configure(text='サインインするには、パスワードが必要です。\nネットワークエラーが発生しています。\n続行するには、マスターパスワードを入力して下さい。')
|
||||||
|
|
||||||
if responce.status_code == 200:
|
if responce.status_code == 200:
|
||||||
self.destroy()
|
self.exit()
|
||||||
app.exit()
|
|
||||||
else:
|
else:
|
||||||
master_password_hash = self.hash_genarate(str(self.password_entry.get()))
|
master_password_hash = self.hash_genarate(str(self.password_entry.get()))
|
||||||
if client_config["master_password_hash"] == master_password_hash:
|
if client_config["master_password_hash"] == master_password_hash:
|
||||||
self.destroy()
|
self.exit()
|
||||||
app.exit()
|
|
||||||
else:
|
else:
|
||||||
self.msg_subtitle_1.configure(text='サインインするには、パスワードが必要です。\nパスワードが違います!')
|
self.msg_subtitle_1.configure(text='サインインするには、パスワードが必要です。\nパスワードが違います!')
|
||||||
|
|
||||||
|
@ -132,6 +142,7 @@ class Lock(customtkinter.CTkToplevel):
|
||||||
|
|
||||||
def exit(self):
|
def exit(self):
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
app.exit()
|
||||||
|
|
||||||
def master_password_gen():
|
def master_password_gen():
|
||||||
numbers = string.digits # (1)
|
numbers = string.digits # (1)
|
||||||
|
|
Loading…
Reference in a new issue