GUIを再設計 (thanks for 八咫烏!)

This commit is contained in:
suti7yk5032 2024-07-04 20:40:03 +09:00
parent 5cd099a411
commit 0a7bb89a98

View file

@ -21,12 +21,12 @@ class App(customtkinter.CTk):
else: else:
self.attributes('-fullscreen', True) self.attributes('-fullscreen', True)
self.attributes('-topmost', True) self.attributes('-topmost', True)
self.block_taskmgr()
self.block_key()
self.frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color='transparent') self.frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color='transparent')
self.frame.grid(row=0, column=0, sticky='nsew') self.frame.grid(row=0, column=0, sticky='nsew')
self.block_taskmgr()
self.block_key()
lock = Lock() lock = Lock()
def exit(self): def exit(self):
@ -65,6 +65,9 @@ class App(customtkinter.CTk):
class Lock(customtkinter.CTkToplevel): class Lock(customtkinter.CTkToplevel):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
if client_config["testing"] == 1:
self.title(f'{app_name} | PC番号 {client_config["pc_number"]} | テストモード')
else:
self.title(f'{app_name} | PC番号 {client_config["pc_number"]} | ロックされています') self.title(f'{app_name} | PC番号 {client_config["pc_number"]} | ロックされています')
self.geometry("600x400") self.geometry("600x400")
self.resizable(height=False, width=False) self.resizable(height=False, width=False)
@ -73,48 +76,57 @@ 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.emoji_font = customtkinter.CTkFont(family="Segoe UI Emoji", size=32)
self.general_font = customtkinter.CTkFont(family="meiryo", size=14) self.title_font = customtkinter.CTkFont(family="meiryo", size=32, weight="bold")
self.title_small_font = customtkinter.CTkFont(family="meiryo", size=16)
self.general_font = customtkinter.CTkFont(family="meiryo", size=18)
self.general_small_font = customtkinter.CTkFont(family="meiryo", size=12) self.general_small_font = customtkinter.CTkFont(family="meiryo", size=12)
self.textbox_font = customtkinter.CTkFont(family="meiryo", size=14)
self.button_font = customtkinter.CTkFont(family="meiryo", size=14)
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, padx=10, pady=10, sticky="nsew")
self.msg_title_1 = customtkinter.CTkLabel(self.msg_title_frame, text='ちょっと待って!!', font=self.title_font, anchor=tkinter.W) self.icon_title_1 = customtkinter.CTkLabel(self.msg_title_frame, text='😎', font=self.emoji_font, justify="left")
self.msg_title_1.grid(row=0, column=0, padx=10, pady=10) self.icon_title_1.grid(row=0, column=0, padx=10, sticky="w")
self.msg_title_2 = customtkinter.CTkLabel(self.msg_title_frame, text="本当にあなたですか?", font=self.title_font, anchor=tkinter.W) self.msg_title_1 = customtkinter.CTkLabel(self.msg_title_frame, text='ちょっと待って!!', font=self.title_font, justify="left")
self.msg_title_2.grid(row=1, column=0, padx=10, pady=10) self.msg_title_1.grid(row=0, column=1, padx=10, sticky="w")
self.msg_title_2 = customtkinter.CTkLabel(self.msg_title_frame, text="本当にあなたですか?", font=self.title_small_font, justify="left")
self.msg_title_2.grid(row=1, column=1, padx=10, sticky="w")
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, padx=10, pady=10, sticky="nsew")
self.msg_subtitle_frame.grid_columnconfigure(0, weight=1)
self.msg_subtitle_1 = customtkinter.CTkLabel(self.msg_subtitle_frame, text='サインインするには、Discordのダイレクトメッセージに', font=self.general_font, anchor=tkinter.W) self.msg_subtitle_1 = customtkinter.CTkLabel(self.msg_subtitle_frame, text='サインインするには、Discordのダイレクトメッセージに送信された\nパスワードを入力してください。', font=self.general_font, justify="left")
self.msg_subtitle_1.grid(row=0, column=0, padx=10, pady=10) self.msg_subtitle_1.grid(row=0, column=0, padx=10, sticky="ew")
self.msg_subtitle_2 = customtkinter.CTkLabel(self.msg_subtitle_frame, text='送信されたパスワードを入力してください。', font=self.general_font, anchor=tkinter.W) self.msg_subtitle_2 = customtkinter.CTkLabel(self.msg_subtitle_frame, text='※ パスワードの有効期限は23:59までです。', font=self.general_small_font, justify="left")
self.msg_subtitle_2.grid(row=1, column=0, padx=10, pady=10) self.msg_subtitle_2.grid(row=1, column=0, padx=10, sticky="w")
self.msg_subtitle_3 = customtkinter.CTkLabel(self.msg_subtitle_frame, text='パスワードの有効期限は23:59までです。', font=self.general_font, anchor=tkinter.W)
self.msg_subtitle_3.grid(row=2, 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, padx=10, pady=10, sticky="nsew")
self.input_frame.columnconfigure(0, weight=1)
self.password_entry = customtkinter.CTkEntry(self.input_frame, placeholder_text='パスワード', width=380, show='*', font=self.general_small_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, pady=10) self.password_entry.grid(row=0, column=0, padx=10, sticky="ew")
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, padx=10, pady=10, sticky="nsew")
self.button_frame.columnconfigure(0, weight=3)
self.button_frame.columnconfigure(1, weight=1)
self.button_frame.columnconfigure(2, weight=1)
self.signin_button = customtkinter.CTkButton(self.button_frame, text='サインイン', command=self.auth, font=self.general_font) self.signin_button = customtkinter.CTkButton(self.button_frame, text='サインイン', command=self.auth, font=self.button_font)
self.signin_button.grid(row=0, column=2, padx=10, pady=10) self.signin_button.grid(row=0, column=2, padx=10, sticky="e")
self.logout_button = customtkinter.CTkButton(self.button_frame, text='ログアウト', command=self.auth, font=self.general_font) self.logout_button = customtkinter.CTkButton(self.button_frame, text='ログアウト', command=self.handler_close, font=self.button_font)
self.logout_button.grid(row=0, column=1, padx=10, pady=10) self.logout_button.grid(row=0, column=1, padx=10, sticky="e")
self.signin_button = customtkinter.CTkButton(self.button_frame, text='ヘルプ', command=self.auth, font=self.general_font) self.signin_button = customtkinter.CTkButton(self.button_frame, text='ヘルプ', command=self.handler_close, font=self.button_font)
self.signin_button.grid(row=0, column=0, padx=10, pady=10) 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
@ -128,6 +140,7 @@ class Lock(customtkinter.CTkToplevel):
return hashed.hexdigest() return hashed.hexdigest()
def auth(self): def auth(self):
print("認証サーバーにアクセスします。")
auth_url = client_config["auth_host_url"] + "/verify" auth_url = client_config["auth_host_url"] + "/verify"
auth_json = { auth_json = {
"pc_number": int(client_config["pc_number"]), "pc_number": int(client_config["pc_number"]),
@ -135,21 +148,20 @@ class Lock(customtkinter.CTkToplevel):
} }
try: try:
responce = requests.post(auth_url, json=auth_json) responce = requests.post(auth_url, json=auth_json)
except:
master_password_hash = self.hash_genarate(str(self.password_entry.get()))
if client_config["master_password_hash"] == master_password_hash:
self.exit()
else:
self.msg_subtitle_1.configure(text='サインインするには、パスワードが必要です。\nネットワークエラーが発生しています。\n続行するには、マスターパスワードを入力して下さい。')
if responce.status_code == 200: if responce.status_code == 200:
print("認証サーバー経由で認証しました。")
self.exit() self.exit()
else:
except:
print("認証サーバーにアクセスできません。マスターパスワードで認証を試行します。")
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:
print("マスターパスワードで認証しました。")
self.exit() self.exit()
else: else:
self.msg_subtitle_1.configure(text='サインインするには、パスワードが必要です。\nパスワードが違います!') print("マスターパスワードで認証できませんでした。")
self.msg_subtitle_1.configure(text='ネットワークエラーが発生しています。\n続行するには、マスターパスワードを入力して下さい。 ')
def handler_close(self): def handler_close(self):
pass pass