mirror of
https://github.com/HChaZZY/Random-Picker.git
synced 2025-12-06 10:33:50 +08:00
更改为英文字符
This commit is contained in:
14
点名器.pyw
14
点名器.pyw
@@ -39,7 +39,7 @@ try:
|
||||
table = excel_data.sheets()[0]
|
||||
win32api.SetFileAttributes(filename,win32con.FILE_ATTRIBUTE_HIDDEN)
|
||||
except FileNotFoundError:
|
||||
msgbox.showerror('找不到数据库文件', '在相同目录下未能找到 names.xls 文件,请确认您的文件存在')
|
||||
msgbox.showerror('找不到数据库文件', '在相同目录下未能找到 names.xls 文件,请确认您的文件存在')
|
||||
sys.exit()
|
||||
|
||||
try:
|
||||
@@ -48,7 +48,7 @@ try:
|
||||
assert cols == 4
|
||||
assert rows > 1
|
||||
except AssertionError:
|
||||
msgbox.showerror('数据库文件格式不正确', '数据库文件内行/列数不合法,请确认数据库文件拥有超过1的行数和等于4的列数,当前行数:' + str(rows) + ' 当前列数:' + str(cols))
|
||||
msgbox.showerror('数据库文件格式不正确', '数据库文件内行/列数不合法,请确认数据库文件拥有超过1的行数和等于4的列数,当前行数:' + str(rows) + ' 当前列数:' + str(cols))
|
||||
sys.exit()
|
||||
|
||||
elim_id = []
|
||||
@@ -84,7 +84,7 @@ filter = []
|
||||
|
||||
last_choice = ""
|
||||
|
||||
# print("读取数据库成功:" + str(cols) + "列 " + str(rows) + "行")
|
||||
# print("读取数据库成功:" + str(cols) + "列 " + str(rows) + "行")
|
||||
|
||||
for i in range(elim_rows,rows):
|
||||
tmp_list = [str(table.cell_value(i,j)) for j in range(0,cols)]
|
||||
@@ -131,14 +131,14 @@ def sel_class(flag = 1):
|
||||
cur_stu.append(student)
|
||||
else:
|
||||
if flag:
|
||||
msgbox.showwarning('班级选择已应用', '当前设置会选择所有班级的名单,这样对吗?', parent=gui)
|
||||
msgbox.showwarning('班级选择已应用', '当前设置会选择所有班级的名单,这样对吗?', parent=gui)
|
||||
filter = classes[:]
|
||||
cur_stu = students[:]
|
||||
|
||||
def choose():
|
||||
global last_choice, cur_stu
|
||||
sel_class(0)
|
||||
# 触发30%概率,从up中挑选
|
||||
# 触发30%概率,从up中挑选
|
||||
if (random.randint(1,100) < up_percent and percent_override):
|
||||
protection_override = True;
|
||||
temp = []
|
||||
@@ -163,7 +163,7 @@ def choose():
|
||||
choice = random.choice(cur_stu)
|
||||
# print(choice.name)
|
||||
counter = 0;
|
||||
while (last_choice == choice.name and (not protection_override)) or choice.id in elim_id:
|
||||
while (last_choice == choice.name and (not protection_override) and (len(cur_stu) > 1)) or choice.id in elim_id:
|
||||
choice = random.choice(cur_stu)
|
||||
counter = counter + 1
|
||||
if counter >= 100:
|
||||
@@ -174,7 +174,7 @@ def choose():
|
||||
subject_label.config(text = choice.subject)
|
||||
last_choice = choice.name
|
||||
|
||||
startrandom = Button(gui, text = "立刻摇人!", font = ("宋体", 17, "bold"), height = 2, fg = "red", command = choose, bg = "white")
|
||||
startrandom = Button(gui, text = "立刻摇人!", font = ("宋体", 17, "bold"), height = 2, fg = "red", command = choose, bg = "white")
|
||||
|
||||
setclass = Button(gui, text = "应用班级选用", font = ("宋体", 17), height = 2, command = sel_class, bg = "white")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user