Compare commits

...

2 Commits

Author SHA1 Message Date
d757e81f78
bump version to v1.2 2024-06-22 23:29:46 +08:00
9ba1335546
fix some display layer issue 2024-06-22 23:28:59 +08:00

11
main.py

@ -14,7 +14,7 @@ REGISTRY_PATH = r"Software\StudentIDDraw"
DEFAULT_ALLOW_REPEAT = False DEFAULT_ALLOW_REPEAT = False
DEFAULT_MIN_ID = 1 DEFAULT_MIN_ID = 1
DEFAULT_MAX_ID = 45 DEFAULT_MAX_ID = 45
PASSWORD = "Admin@123" PASSWORD = "admin000"
selected_ids = [] selected_ids = []
temp_selected_ids = [] temp_selected_ids = []
@ -185,7 +185,7 @@ def open_settings():
update_history_list() update_history_list()
def add_id(): def add_id():
new_id = simpledialog.askstring("新增学号", "请输入新的学号:") new_id = simpledialog.askstring("新增学号", "请输入新的学号:", parent=settings_window)
if new_id: if new_id:
if new_id.isdigit(): if new_id.isdigit():
new_id = int(new_id) new_id = int(new_id)
@ -197,6 +197,7 @@ def open_settings():
messagebox.showerror("错误", f"学号必须在 {min_id}{max_id} 之间") messagebox.showerror("错误", f"学号必须在 {min_id}{max_id} 之间")
else: else:
messagebox.showerror("错误", "请输入有效的学号") messagebox.showerror("错误", "请输入有效的学号")
settings_window.focus_force()
def delete_id(): def delete_id():
selected = history_list.curselection() selected = history_list.curselection()
@ -210,6 +211,7 @@ def open_settings():
history_list.select_set(index - 1) history_list.select_set(index - 1)
else: else:
messagebox.showerror("错误", "请选择一个学号进行删除") messagebox.showerror("错误", "请选择一个学号进行删除")
settings_window.focus_force()
def edit_id(): def edit_id():
selected = history_list.curselection() selected = history_list.curselection()
@ -217,7 +219,7 @@ def open_settings():
index = selected[0] index = selected[0]
current_id, _ = temp_selected_ids[index] current_id, _ = temp_selected_ids[index]
new_id = simpledialog.askstring( new_id = simpledialog.askstring(
"修改学号", "请输入新的学号:", initialvalue=str(current_id) "修改学号", "请输入新的学号:", initialvalue=str(current_id), parent=settings_window
) )
if new_id: if new_id:
if new_id.isdigit(): if new_id.isdigit():
@ -233,6 +235,7 @@ def open_settings():
messagebox.showerror("错误", "请输入有效的学号") messagebox.showerror("错误", "请输入有效的学号")
else: else:
messagebox.showerror("错误", "请选择一个学号进行修改") messagebox.showerror("错误", "请选择一个学号进行修改")
settings_window.focus_force()
def clear_all_ids(): def clear_all_ids():
global temp_selected_ids global temp_selected_ids
@ -337,7 +340,7 @@ settings_button.pack(pady=10)
# 创建多行标签,用于显示信息,内容居中显示 # 创建多行标签,用于显示信息,内容居中显示
info_label = tk.Label( info_label = tk.Label(
root, root,
text="LuckyDraw v1.1 2024/06/22\nCopyright 2024 earthjasonlin\n保留所有权利。\n本程序仅作为交流学习使用", text="LuckyDraw v1.2 2024/06/22\nCopyright 2024 earthjasonlin\n保留所有权利。\n本程序仅作为交流学习使用",
font=("宋体", 10), font=("宋体", 10),
justify="center", justify="center",
anchor="center", anchor="center",