Compare commits
2 Commits
v1.0
...
ae467e072a
Author | SHA1 | Date | |
---|---|---|---|
ae467e072a
|
|||
044f40ec78
|
28
main.py
28
main.py
@ -3,6 +3,7 @@ from tkinter import simpledialog, messagebox
|
|||||||
import random
|
import random
|
||||||
import winreg
|
import winreg
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
import os
|
||||||
|
|
||||||
# 注册表路径
|
# 注册表路径
|
||||||
REGISTRY_PATH = r"Software\StudentIDDraw"
|
REGISTRY_PATH = r"Software\StudentIDDraw"
|
||||||
@ -11,7 +12,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 = "admin123"
|
PASSWORD = "Admin@123"
|
||||||
|
|
||||||
selected_ids = []
|
selected_ids = []
|
||||||
|
|
||||||
@ -155,10 +156,6 @@ def open_settings():
|
|||||||
settings_window.grid_columnconfigure(1, weight=1)
|
settings_window.grid_columnconfigure(1, weight=1)
|
||||||
settings_window.grid_rowconfigure(4, weight=1)
|
settings_window.grid_rowconfigure(4, weight=1)
|
||||||
|
|
||||||
tk.Label(settings_window, text="历史记录:", font=("宋体", 12)).grid(
|
|
||||||
row=0, column=0, padx=5, pady=5, sticky="w"
|
|
||||||
)
|
|
||||||
|
|
||||||
load_selected_ids()
|
load_selected_ids()
|
||||||
|
|
||||||
history_frame = tk.Frame(settings_window)
|
history_frame = tk.Frame(settings_window)
|
||||||
@ -232,26 +229,26 @@ def open_settings():
|
|||||||
selected_ids = []
|
selected_ids = []
|
||||||
update_history_list()
|
update_history_list()
|
||||||
|
|
||||||
tk.Button(settings_window, text="新增记录", font=("宋体", 12), command=add_id).grid(
|
tk.Button(settings_window, text="新增记录", font=("宋体", 10), command=add_id).grid(
|
||||||
row=2, column=0, padx=5, pady=5, sticky="ew"
|
row=2, column=0, padx=5, pady=5, sticky="ew"
|
||||||
)
|
)
|
||||||
tk.Button(settings_window, text="删除记录", font=("宋体", 12), command=delete_id).grid(
|
tk.Button(settings_window, text="删除记录", font=("宋体", 10), command=delete_id).grid(
|
||||||
row=2, column=1, padx=5, pady=5, sticky="ew"
|
row=2, column=1, padx=5, pady=5, sticky="ew"
|
||||||
)
|
)
|
||||||
tk.Button(settings_window, text="修改记录", font=("宋体", 12), command=edit_id).grid(
|
tk.Button(settings_window, text="修改记录", font=("宋体", 10), command=edit_id).grid(
|
||||||
row=3, column=0, padx=5, pady=5, sticky="ew"
|
row=3, column=0, padx=5, pady=5, sticky="ew"
|
||||||
)
|
)
|
||||||
tk.Button(
|
tk.Button(
|
||||||
settings_window, text="清空记录", font=("宋体", 12), command=clear_all_ids
|
settings_window, text="清空记录", font=("宋体", 10), command=clear_all_ids
|
||||||
).grid(row=3, column=1, padx=5, pady=5, sticky="ew")
|
).grid(row=3, column=1, padx=5, pady=5, sticky="ew")
|
||||||
|
|
||||||
allow_repeat_var = tk.BooleanVar(value=allow_repeat)
|
allow_repeat_var = tk.BooleanVar(value=allow_repeat)
|
||||||
tk.Checkbutton(
|
tk.Checkbutton(
|
||||||
settings_window, text="允许重复抽号", font=("宋体", 12), variable=allow_repeat_var
|
settings_window, text="允许重复抽号", font=("宋体", 10), variable=allow_repeat_var
|
||||||
).grid(row=5, column=0, padx=5, pady=5, sticky="w")
|
).grid(row=5, column=0, padx=5, pady=5, sticky="w")
|
||||||
|
|
||||||
tk.Label(settings_window, text="学号范围:", font=("宋体", 12)).grid(
|
tk.Label(settings_window, text="学号范围:", font=("宋体", 10)).grid(
|
||||||
row=6, column=0, padx=5, pady=5, sticky="w"
|
row=6, column=0, padx=5, pady=5, sticky="e"
|
||||||
)
|
)
|
||||||
min_id_var = tk.StringVar(value=min_id)
|
min_id_var = tk.StringVar(value=min_id)
|
||||||
max_id_var = tk.StringVar(value=max_id)
|
max_id_var = tk.StringVar(value=max_id)
|
||||||
@ -274,7 +271,7 @@ def open_settings():
|
|||||||
else:
|
else:
|
||||||
messagebox.showerror("错误", "密码错误")
|
messagebox.showerror("错误", "密码错误")
|
||||||
|
|
||||||
tk.Button(settings_window, text="保存", font=("宋体", 12), command=save_changes).grid(
|
tk.Button(settings_window, text="保存", font=("宋体", 10), command=save_changes).grid(
|
||||||
row=8, column=0, columnspan=2, padx=5, pady=20, sticky="ew"
|
row=8, column=0, columnspan=2, padx=5, pady=20, sticky="ew"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -303,7 +300,10 @@ history_list = None
|
|||||||
# 创建主窗口
|
# 创建主窗口
|
||||||
root = tk.Tk()
|
root = tk.Tk()
|
||||||
root.title("随机抽号机")
|
root.title("随机抽号机")
|
||||||
root.attributes("-topmost", 1) # 置顶显示
|
root.attributes("-topmost", 1)
|
||||||
|
icon_path = os.path.join("icon.png")
|
||||||
|
icon_image = tk.PhotoImage(file=icon_path)
|
||||||
|
root.iconphoto(True, icon_image)
|
||||||
|
|
||||||
# 创建标签,用于显示抽取的学号
|
# 创建标签,用于显示抽取的学号
|
||||||
label = tk.Label(root, text="", font=("宋体", 50))
|
label = tk.Label(root, text="", font=("宋体", 50))
|
||||||
|
Reference in New Issue
Block a user