特定のキーをブロックするように

This commit is contained in:
suti7yk5032 2024-06-06 23:08:15 +09:00
parent e849afbf91
commit f2679a8307

View file

@ -3,21 +3,32 @@ import os
import json
import customtkinter
from winotify import Notification, audio
import keyboard
class App(customtkinter.CTk):
def __init__(self):
super().__init__()
self.title("Dislocker ロック中")
self.attributes('-fullscreen', True)
Lock()
self.frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color='transparent')
self.frame.grid(row=0, column=0, sticky='nsew')
self.restore_button = customtkinter.CTkButton(self.frame, text='認証ウィンドウを再表示', command=self.handler_close, width=240)
self.restore_button.grid(row=0, column=0)
self.block_key()
lock = Lock()
def exit(self):
self.toast()
self.destroy()
def block_key(self):
block_keys = ['ctrl', 'alt', 'windows', 'shift', 'delete']
for i in block_keys:
keyboard.block_key(i)
def toast(self):
resource_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "resource")
success = Notification(
@ -29,13 +40,19 @@ class App(customtkinter.CTk):
success.set_audio(audio.Default, loop=False)
success.show()
def handler_close(self):
pass
class Lock(customtkinter.CTkToplevel):
def __init__(self):
super().__init__()
self.title('Dislocker | PC番号 10 | ロックされています')
self.geometry('400x500')
self.geometry('400x200')
self.resizable(height=False, width=False)
self.attributes('-topmost', True)
self.lift()
self.protocol("WM_DELETE_WINDOW", self.handler_close)
self.msg_title_frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color='transparent')
self.msg_title_frame.grid(row=0, column=0, sticky="nsew")
@ -75,6 +92,12 @@ class Lock(customtkinter.CTkToplevel):
else:
self.msg_subtitle_1.configure(text='サインインするには、パスワードが必要です。\nパスワードが違います!')
def handler_close(self):
pass
def exit(self):
self.destroy()
@ -100,4 +123,5 @@ elif os.path.isfile(db_config_path):
if __name__ == '__main__':
app = App()
app.protocol("WM_DELETE_WINDOW", app.handler_close)
app.mainloop()