mirror of
https://github.com/HChaZZY/Random-Picker.git
synced 2025-12-06 10:33:50 +08:00
优化了报错弹窗的表现
This commit is contained in:
19
点名器.pyw
19
点名器.pyw
@@ -5,8 +5,15 @@ import random
|
||||
import sys
|
||||
import win32con, win32api
|
||||
|
||||
gui_size = "620x200"
|
||||
|
||||
gui = Tk()
|
||||
|
||||
gui.withdraw()
|
||||
gui.title("点名器")
|
||||
gui.geometry(gui_size)
|
||||
gui.resizable(0,0)
|
||||
gui.configure(bg = "white")
|
||||
class Student(object):
|
||||
name = ""
|
||||
subject = ""
|
||||
@@ -25,7 +32,6 @@ down_persent = 40
|
||||
filename = "names.xls"
|
||||
configname = "config.data"
|
||||
elim_rows = 1
|
||||
gui_size = "620x200"
|
||||
percent_override = True
|
||||
|
||||
try:
|
||||
@@ -33,7 +39,7 @@ try:
|
||||
table = excel_data.sheets()[0]
|
||||
win32api.SetFileAttributes(filename,win32con.FILE_ATTRIBUTE_HIDDEN)
|
||||
except FileNotFoundError:
|
||||
msgbox.showerror('找不到数据库文件', '在相同目录下未能找到 names.xls 文件,请确认您的文件存在', parent=gui)
|
||||
msgbox.showerror('找不到数据库文件', '在相同目录下未能找到 names.xls 文件,请确认您的文件存在')
|
||||
sys.exit()
|
||||
|
||||
try:
|
||||
@@ -42,7 +48,7 @@ try:
|
||||
assert cols == 4
|
||||
assert rows > 1
|
||||
except AssertionError:
|
||||
msgbox.showerror('数据库文件格式不正确', '数据库文件内行/列数不合法,请确认数据库文件拥有超过1的行数和等于4的列数,当前行数:' + str(rows) + ' 当前列数:' + str(cols), parent=gui)
|
||||
msgbox.showerror('数据库文件格式不正确', '数据库文件内行/列数不合法,请确认数据库文件拥有超过1的行数和等于4的列数,当前行数:' + str(rows) + ' 当前列数:' + str(cols))
|
||||
sys.exit()
|
||||
|
||||
elim_id = []
|
||||
@@ -69,6 +75,8 @@ except:
|
||||
up_percent = len(up_id) * 5 if len(up_id) <= 6 else 30
|
||||
down_percent = len(down_id) * 8 if len(down_id) <= 5 else 40
|
||||
|
||||
gui.deiconify()
|
||||
|
||||
students = []
|
||||
classes = []
|
||||
subjects = []
|
||||
@@ -94,11 +102,6 @@ for student in students:
|
||||
if student.subject not in subjects:
|
||||
subjects.append(student.subject)
|
||||
|
||||
gui.title("点名器")
|
||||
gui.geometry(gui_size)
|
||||
gui.resizable(0,0)
|
||||
gui.configure(bg = "white")
|
||||
|
||||
cur_name = StringVar()
|
||||
|
||||
def upd_name(name):
|
||||
|
||||
Reference in New Issue
Block a user