Delete .history directory

This commit is contained in:
PeterBilly
2022-11-19 20:29:37 +08:00
committed by GitHub
parent 1ff182e900
commit d59eeaa656
16 changed files with 0 additions and 2084 deletions

View File

@@ -1,20 +0,0 @@
点名器.spec
build/点名器/点名器.exe.manifest
build/点名器/点名器.pkg
build/点名器/Analysis-00.toc
build/点名器/base_library.zip
build/点名器/EXE-00.toc
build/点名器/PKG-00.toc
build/点名器/PYZ-00.pyz
build/点名器/PYZ-00.toc
build/点名器/Tree-00.toc
build/点名器/Tree-01.toc
build/点名器/Tree-02.toc
build/点名器/warn-点名器.txt
build/点名器/xref-点名器.html
build/点名器/localpycs/pyimod01_archive.pyc
build/点名器/localpycs/pyimod02_importers.pyc
build/点名器/localpycs/pyimod03_ctypes.pyc
build/点名器/localpycs/pyimod04_pywin32.pyc
build/点名器/localpycs/struct.pyc
dist/点名器.exe

View File

@@ -1,31 +0,0 @@
点名器.spec
build/点名器/点名器.exe.manifest
build/点名器/点名器.pkg
build/点名器/Analysis-00.toc
build/点名器/base_library.zip
build/点名器/EXE-00.toc
build/点名器/PKG-00.toc
build/点名器/PYZ-00.pyz
build/点名器/PYZ-00.toc
build/点名器/Tree-00.toc
build/点名器/Tree-01.toc
build/点名器/Tree-02.toc
build/点名器/warn-点名器.txt
build/点名器/xref-点名器.html
build/点名器/localpycs/pyimod01_archive.pyc
build/点名器/localpycs/pyimod02_importers.pyc
build/点名器/localpycs/pyimod03_ctypes.pyc
build/点名器/localpycs/pyimod04_pywin32.pyc
build/点名器/localpycs/struct.pyc
dist/点名器.exe
README_Vanila.html
README_Vanila.md
README.html
.history/README_Vanila_20221107204953.md
.history/README_Vanila_20221107204954.md
.history/.gitignore_20221107235331
.history/点名器_20221107235625.pyw
.history/README_20221107235533.md
.history/.gitignore_20221107235715
.history/点名器_20221108000106.pyw
.history/.gitignore_20221119173544

View File

@@ -1,32 +0,0 @@
点名器.spec
build/点名器/点名器.exe.manifest
build/点名器/点名器.pkg
build/点名器/Analysis-00.toc
build/点名器/base_library.zip
build/点名器/EXE-00.toc
build/点名器/PKG-00.toc
build/点名器/PYZ-00.pyz
build/点名器/PYZ-00.toc
build/点名器/Tree-00.toc
build/点名器/Tree-01.toc
build/点名器/Tree-02.toc
build/点名器/warn-点名器.txt
build/点名器/xref-点名器.html
build/点名器/localpycs/pyimod01_archive.pyc
build/点名器/localpycs/pyimod02_importers.pyc
build/点名器/localpycs/pyimod03_ctypes.pyc
build/点名器/localpycs/pyimod04_pywin32.pyc
build/点名器/localpycs/struct.pyc
dist/点名器.exe
README_Vanila.html
README_Vanila.md
README.html
.history/README_Vanila_20221107204953.md
.history/README_Vanila_20221107204954.md
.history/.gitignore_20221107235331
.history/点名器_20221107235625.pyw
.history/README_20221107235533.md
.history/.gitignore_20221107235715
.history/点名器_20221108000106.pyw
.history/.gitignore_20221119173544
dist/names.xls

View File

@@ -1,47 +0,0 @@
# ---一个点名器的python实现---
## 读取相同目录下的names.xls数据库文件
## 程序启动后如果检测到数据库文件会自动加上隐藏属性
## names.xls必须满足以下条件
### 1. 至少两行和不多于也不少于四列
### 2. 第一行的四个单元格分别是 |序号|班级|学科|姓名
### 3. 第二行以下分别按照第一行的要求填写
#### P.S. 第一行的四个单元格会被程序自动忽略,这四个名称只是为了让人方便阅读
### 软件会自动读取数据库中所有可用的班级名称,并将列举在软件右侧的选择框内。
![image](https://user-images.githubusercontent.com/10991308/200275407-fc43e648-275f-455e-a7c7-2fec00e074e2.png)
### 左击选择框可以选择按照班级的筛选,可以多选,如果不选,则默认不进行筛选。
![image](https://user-images.githubusercontent.com/10991308/200275805-0d64667f-238e-42bb-a332-3be33fd0b5ec.png)
### 点击`立即摇人!`可以在所有满足筛选条件的人员中随机挑选一位,并将其姓名,班级号和学科种类显示在界面上。
![image](https://user-images.githubusercontent.com/10991308/200276213-2eabcb19-7bde-4eca-985e-e0ddf939b484.png)
### 点击`应用班级选用`可以提前应用筛选条件,但不会进行挑选。
~~但是点击摇人的时候本来就会重新应用当前选好的筛选条件,所以这个按钮其实就是做来好看的。~~
### 为了防止被搞心态,不会出现连续抽到两个一样的人的情况。~~因为懒得写动画所以如果连续抽到两个一样的人就几乎看不出来了~~
## 隐藏功能使用config.data文件对指定编号的人员进行指定概率编辑
~~究竟是什么居心的人才想让我开发这么一个鬼功能~~
![image](https://user-images.githubusercontent.com/10991308/200277374-0ff24e74-53d6-4d22-b513-bccc9f1af241.png)
![image](https://user-images.githubusercontent.com/10991308/200277421-a81b11a2-eec2-4373-957a-37dc134ef0b8.png)
### 在相同目录下编辑一个config.data文件
### 如果程序没有检测到文件,什么都不会发生
### 如果检测到了,自动加隐藏属性并读取文件
### config.data需要符合以下语法
#### 1. 由N行组成
#### 2. 每一行对应一位需要更改概率的序号
#### 3. 每一行的内容为 `X,+/-/0` 即需要编辑的序号加上一个英文字符逗号加上英文字符+或者-或者数字0
#### 4. 请再看一遍`3.`并确保你记住了每一个词
#### 5. 如果输入了`+`那么该序号被抽到的概率增加前提是满足由班级选择器控制的筛选条件。具体增加方法为每次抽人都有5% * (被标记为‘+’的人的人数)的概率只在被标记为‘+的人中抽取这个总概率的上限为30%。
#### 6. 如果输入了`-`那么该序号被抽到的概率减少。具体减少方法是每次抽人都有8% * (被标记为‘-的人的人数直接排除掉这些被标记的人。这个概率的上限是40%。
#### 7. 如果输入了`0`,那么该序号便会被拒绝录入。即数据库中虽然存在该编号,但是程序不会将其视为可被抽取的对象。
#### 8. 如欲更改配置,仅需在保存了更改后的配置文件后重启点名器程序即可。

View File

@@ -1,47 +0,0 @@
# ---一个点名器的python实现---
## 读取相同目录下的names.xls数据库文件
## 程序启动后如果检测到数据库文件会自动加上隐藏属性
## names.xls必须满足以下条件
### 1. 至少两行和不多于也不少于四列
### 2. 第一行的四个单元格分别是 |序号|班级|学科|姓名
### 3. 第二行以下分别按照第一行的要求填写
#### P.S. 第一行的四个单元格会被程序自动忽略,这四个名称只是为了让人方便阅读
### 软件会自动读取数据库中所有可用的班级名称,并将列举在软件右侧的选择框内。
![image](https://user-images.githubusercontent.com/10991308/200275407-fc43e648-275f-455e-a7c7-2fec00e074e2.png)
### 左击选择框可以选择按照班级的筛选,可以多选,如果不选,则默认不进行筛选。
![image](https://user-images.githubusercontent.com/10991308/200275805-0d64667f-238e-42bb-a332-3be33fd0b5ec.png)
### 点击`立即摇人!`可以在所有满足筛选条件的人员中随机挑选一位,并将其姓名,班级号和学科种类显示在界面上。
![image](https://user-images.githubusercontent.com/10991308/200276213-2eabcb19-7bde-4eca-985e-e0ddf939b484.png)
### 点击`应用班级选用`可以提前应用筛选条件,但不会进行挑选。
~~但是点击摇人的时候本来就会重新应用当前选好的筛选条件,所以这个按钮其实就是做来好看的。~~
### 为了防止被搞心态,不会出现连续抽到两个一样的人的情况。~~因为懒得写动画所以如果连续抽到两个一样的人就几乎看不出来了~~
## 隐藏功能使用config.data文件对指定编号的人员进行指定概率编辑
~~究竟是什么居心的人才想让我开发这么一个鬼功能~~
![image](https://user-images.githubusercontent.com/10991308/200277374-0ff24e74-53d6-4d22-b513-bccc9f1af241.png)
![image](https://user-images.githubusercontent.com/10991308/200277421-a81b11a2-eec2-4373-957a-37dc134ef0b8.png)
### 在相同目录下编辑一个config.data文件
### 如果程序没有检测到文件,什么都不会发生
### 如果检测到了,自动加隐藏属性并读取文件
### config.data需要符合以下语法
#### 1. 由N行组成
#### 2. 每一行对应一位需要更改概率的序号
#### 3. 每一行的内容为 `X,+/-/0` 即需要编辑的序号加上一个英文字符逗号加上英文字符+或者-或者数字0
#### 4. 请再看一遍`3.`并确保你记住了每一个词
#### 5. 如果输入了`+`那么该序号被抽到的概率增加前提是满足由班级选择器控制的筛选条件且针对这些人的防搞心态保护失效。具体增加方法为每次抽人都有5% * (被标记为‘+’的人的人数)的概率只在被标记为‘+的人中抽取这个总概率的上限为30%。
#### 6. 如果输入了`-`那么该序号被抽到的概率减少。具体减少方法是每次抽人都有8% * (被标记为‘-的人的人数直接排除掉这些被标记的人。这个概率的上限是40%。
#### 7. 如果输入了`0`,那么该序号便会被拒绝录入。即数据库中虽然存在该编号,但是程序不会将其视为可被抽取的对象。
#### 8. 如欲更改配置,仅需在保存了更改后的配置文件后重启点名器程序即可。

View File

@@ -1,189 +0,0 @@
import xlrd as excel
from tkinter import *
import tkinter.messagebox as msgbox
import random
import sys
import win32con, win32api
gui = Tk()
class Student(object):
name = ""
subject = ""
id = ""
class_name = ""
def __init__(self,id,class_name,subject,name):
self.id = id
self.class_name = class_name
self.subject = subject
self.name = name
protection_override = False
up_percent = 30
down_persent = 40
filename = "names.xls"
configname = "config.data"
elim_rows = 1
gui_size = "620x200"
percent_override = True
try:
excel_data = excel.open_workbook(filename)
table = excel_data.sheets()[0]
win32api.SetFileAttributes(filename,win32con.FILE_ATTRIBUTE_HIDDEN)
except FileNotFoundError:
msgbox.showerror('找不到数据库文件', '在相同目录下未能找到 names.xls 文件,请确认您的文件存在', parent=gui)
sys.exit()
try:
cols = table.ncols
rows = table.nrows
assert cols == 4
assert rows > 1
except AssertionError:
msgbox.showerror('数据库文件格式不正确', '数据库文件内行/列数不合法请确认数据库文件拥有超过1的行数和等于4的列数当前行数' + str(rows) + ' 当前列数:' + str(cols), parent=gui)
sys.exit()
elim_id = []
up_id = []
down_id = []
try:
with open(configname,'r') as file:
win32api.SetFileAttributes(configname,win32con.FILE_ATTRIBUTE_HIDDEN)
config = file.read().splitlines()
for unit in config:
temp = unit.split(",")
if temp[1] == '0':
elim_id.append(int(temp[0]))
elif temp[1] == '+':
up_id.append(int(temp[0]))
elif temp[1] == "-":
down_id.append(int(temp[0]))
else:
pass
except:
percent_override = False
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
students = []
classes = []
subjects = []
filter = []
last_choice = ""
# 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)]
if (int(float(tmp_list[0])) not in elim_id):
student = Student(tmp_list[0],tmp_list[1],tmp_list[2],tmp_list[3])
students.append(student)
cur_stu = []
cur_stu = students[:]
for student in students:
if student.class_name not in classes:
classes.append(student.class_name)
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):
cur_name.set(name)
upd_name("")
listbox = Listbox(gui, selectmode = MULTIPLE, height = 5)
for tmp_class in classes:
listbox.insert("end",tmp_class)
def sel_class(flag = 1):
global filter, listbox, classes, cur_stu, students
filter.clear()
for selection in listbox.curselection():
# print(selection)
filter.append(classes[selection])
# print(filter)
if filter:
if flag:
msgbox.showinfo('班级选择已应用', '已应用当前班级选择', parent=gui)
cur_stu.clear()
for student in students:
if student.class_name in filter:
# print(student.name)
cur_stu.append(student)
else:
if flag:
msgbox.showwarning('班级选择已应用', '当前设置会选择所有班级的名单,这样对吗?', parent=gui)
filter = classes[:]
cur_stu = students[:]
def choose():
global last_choice, cur_stu
sel_class(0)
# 触发30%概率从up中挑选
if (random.randint(1,100) < up_percent and percent_override):
protection_override = True;
temp = []
for student in cur_stu:
if int(float(student.id)) in up_id:
temp.append(student)
cur_stu = temp[:]
elif (random.randint(1,100) < down_persent and percent_override):
protection_override = True;
temp = [];
for student in cur_stu:
if int(float(student.id)) not in down_id:
temp.append(student)
cur_stu = temp[:]
else:
protection_override = False
if not cur_stu:
protection_override = False
sel_class(0)
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:
choice = random.choice(cur_stu)
counter = counter + 1
if counter >= 100:
break
# print(choice.name)
upd_name(choice.name)
class_label.config(text = choice.class_name)
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")
setclass = Button(gui, text = "应用班级选用", font = ("宋体", 17), height = 2, command = sel_class, bg = "white")
name_label = Label(gui, textvariable = cur_name, font = ("宋体", 30, "bold"), width = 20, bg = "white", fg = "blue")
class_label = Label(gui, text = "", font = ("宋体", 15), width = 20, bg = "white")
subject_label = Label(gui, text = "", font = ("宋体", 15), width = 20, bg = "white")
class_label.grid(row = 2, column = 1, sticky = N+S+E+W)
subject_label.grid(row = 2, column = 2, sticky = N+S+E+W)
name_label.grid(row = 1, column = 1, sticky = N+S)
listbox.grid(row = 1, column = 2, sticky = N+S)
startrandom.grid(row = 3, column = 1, sticky = N+S+E+W)
setclass.grid(row = 3, column = 2, sticky = N+S+E+W)
gui.mainloop()

View File

@@ -1,189 +0,0 @@
import xlrd as excel
from tkinter import *
import tkinter.messagebox as msgbox
import random
import sys
import win32con, win32api
gui_size = "620x200"
gui = Tk()
gui.title("点名器")
gui.geometry(gui_size)
gui.resizable(0,0)
gui.configure(bg = "white")
class Student(object):
name = ""
subject = ""
id = ""
class_name = ""
def __init__(self,id,class_name,subject,name):
self.id = id
self.class_name = class_name
self.subject = subject
self.name = name
protection_override = False
up_percent = 30
down_persent = 40
filename = "names.xls"
configname = "config.data"
elim_rows = 1
percent_override = True
try:
excel_data = excel.open_workbook(filename)
table = excel_data.sheets()[0]
win32api.SetFileAttributes(filename,win32con.FILE_ATTRIBUTE_HIDDEN)
except FileNotFoundError:
msgbox.showerror('找不到数据库文件', '在相同目录下未能找到 names.xls 文件,请确认您的文件存在', parent=gui)
sys.exit()
try:
cols = table.ncols
rows = table.nrows
assert cols == 4
assert rows > 1
except AssertionError:
msgbox.showerror('数据库文件格式不正确', '数据库文件内行/列数不合法请确认数据库文件拥有超过1的行数和等于4的列数当前行数' + str(rows) + ' 当前列数:' + str(cols), parent=gui)
sys.exit()
elim_id = []
up_id = []
down_id = []
try:
with open(configname,'r') as file:
win32api.SetFileAttributes(configname,win32con.FILE_ATTRIBUTE_HIDDEN)
config = file.read().splitlines()
for unit in config:
temp = unit.split(",")
if temp[1] == '0':
elim_id.append(int(temp[0]))
elif temp[1] == '+':
up_id.append(int(temp[0]))
elif temp[1] == "-":
down_id.append(int(temp[0]))
else:
pass
except:
percent_override = False
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
students = []
classes = []
subjects = []
filter = []
last_choice = ""
# 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)]
if (int(float(tmp_list[0])) not in elim_id):
student = Student(tmp_list[0],tmp_list[1],tmp_list[2],tmp_list[3])
students.append(student)
cur_stu = []
cur_stu = students[:]
for student in students:
if student.class_name not in classes:
classes.append(student.class_name)
if student.subject not in subjects:
subjects.append(student.subject)
cur_name = StringVar()
def upd_name(name):
cur_name.set(name)
upd_name("")
listbox = Listbox(gui, selectmode = MULTIPLE, height = 5)
for tmp_class in classes:
listbox.insert("end",tmp_class)
def sel_class(flag = 1):
global filter, listbox, classes, cur_stu, students
filter.clear()
for selection in listbox.curselection():
# print(selection)
filter.append(classes[selection])
# print(filter)
if filter:
if flag:
msgbox.showinfo('班级选择已应用', '已应用当前班级选择', parent=gui)
cur_stu.clear()
for student in students:
if student.class_name in filter:
# print(student.name)
cur_stu.append(student)
else:
if flag:
msgbox.showwarning('班级选择已应用', '当前设置会选择所有班级的名单,这样对吗?', parent=gui)
filter = classes[:]
cur_stu = students[:]
def choose():
global last_choice, cur_stu
sel_class(0)
# 触发30%概率从up中挑选
if (random.randint(1,100) < up_percent and percent_override):
protection_override = True;
temp = []
for student in cur_stu:
if int(float(student.id)) in up_id:
temp.append(student)
cur_stu = temp[:]
elif (random.randint(1,100) < down_persent and percent_override):
protection_override = True;
temp = [];
for student in cur_stu:
if int(float(student.id)) not in down_id:
temp.append(student)
cur_stu = temp[:]
else:
protection_override = False
if not cur_stu:
protection_override = False
sel_class(0)
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:
choice = random.choice(cur_stu)
counter = counter + 1
if counter >= 100:
break
# print(choice.name)
upd_name(choice.name)
class_label.config(text = choice.class_name)
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")
setclass = Button(gui, text = "应用班级选用", font = ("宋体", 17), height = 2, command = sel_class, bg = "white")
name_label = Label(gui, textvariable = cur_name, font = ("宋体", 30, "bold"), width = 20, bg = "white", fg = "blue")
class_label = Label(gui, text = "", font = ("宋体", 15), width = 20, bg = "white")
subject_label = Label(gui, text = "", font = ("宋体", 15), width = 20, bg = "white")
class_label.grid(row = 2, column = 1, sticky = N+S+E+W)
subject_label.grid(row = 2, column = 2, sticky = N+S+E+W)
name_label.grid(row = 1, column = 1, sticky = N+S)
listbox.grid(row = 1, column = 2, sticky = N+S)
startrandom.grid(row = 3, column = 1, sticky = N+S+E+W)
setclass.grid(row = 3, column = 2, sticky = N+S+E+W)
gui.mainloop()

View File

@@ -1,189 +0,0 @@
import xlrd as excel
from tkinter import *
import tkinter.messagebox as msgbox
import random
import sys
import win32con, win32api
gui_size = "620x200"
gui = Tk()
gui.title("点名器")
gui.geometry(gui_size)
gui.resizable(0,0)
gui.configure(bg = "white")
class Student(object):
name = ""
subject = ""
id = ""
class_name = ""
def __init__(self,id,class_name,subject,name):
self.id = id
self.class_name = class_name
self.subject = subject
self.name = name
protection_override = False
up_percent = 30
down_persent = 40
filename = "names.xls"
configname = "config.data"
elim_rows = 1
percent_override = True
try:
excel_data = excel.open_workbook(filename)
table = excel_data.sheets()[0]
win32api.SetFileAttributes(filename,win32con.FILE_ATTRIBUTE_HIDDEN)
except FileNotFoundError:
msgbox.showerror('找不到数据库文件', '在相同目录下未能找到 names.xls 文件,请确认您的文件存在')
sys.exit()
try:
cols = table.ncols
rows = table.nrows
assert cols == 4
assert rows > 1
except AssertionError:
msgbox.showerror('数据库文件格式不正确', '数据库文件内行/列数不合法请确认数据库文件拥有超过1的行数和等于4的列数当前行数' + str(rows) + ' 当前列数:' + str(cols))
sys.exit()
elim_id = []
up_id = []
down_id = []
try:
with open(configname,'r') as file:
win32api.SetFileAttributes(configname,win32con.FILE_ATTRIBUTE_HIDDEN)
config = file.read().splitlines()
for unit in config:
temp = unit.split(",")
if temp[1] == '0':
elim_id.append(int(temp[0]))
elif temp[1] == '+':
up_id.append(int(temp[0]))
elif temp[1] == "-":
down_id.append(int(temp[0]))
else:
pass
except:
percent_override = False
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
students = []
classes = []
subjects = []
filter = []
last_choice = ""
# 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)]
if (int(float(tmp_list[0])) not in elim_id):
student = Student(tmp_list[0],tmp_list[1],tmp_list[2],tmp_list[3])
students.append(student)
cur_stu = []
cur_stu = students[:]
for student in students:
if student.class_name not in classes:
classes.append(student.class_name)
if student.subject not in subjects:
subjects.append(student.subject)
cur_name = StringVar()
def upd_name(name):
cur_name.set(name)
upd_name("")
listbox = Listbox(gui, selectmode = MULTIPLE, height = 5)
for tmp_class in classes:
listbox.insert("end",tmp_class)
def sel_class(flag = 1):
global filter, listbox, classes, cur_stu, students
filter.clear()
for selection in listbox.curselection():
# print(selection)
filter.append(classes[selection])
# print(filter)
if filter:
if flag:
msgbox.showinfo('班级选择已应用', '已应用当前班级选择', parent=gui)
cur_stu.clear()
for student in students:
if student.class_name in filter:
# print(student.name)
cur_stu.append(student)
else:
if flag:
msgbox.showwarning('班级选择已应用', '当前设置会选择所有班级的名单,这样对吗?', parent=gui)
filter = classes[:]
cur_stu = students[:]
def choose():
global last_choice, cur_stu
sel_class(0)
# 触发30%概率从up中挑选
if (random.randint(1,100) < up_percent and percent_override):
protection_override = True;
temp = []
for student in cur_stu:
if int(float(student.id)) in up_id:
temp.append(student)
cur_stu = temp[:]
elif (random.randint(1,100) < down_persent and percent_override):
protection_override = True;
temp = [];
for student in cur_stu:
if int(float(student.id)) not in down_id:
temp.append(student)
cur_stu = temp[:]
else:
protection_override = False
if not cur_stu:
protection_override = False
sel_class(0)
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:
choice = random.choice(cur_stu)
counter = counter + 1
if counter >= 100:
break
# print(choice.name)
upd_name(choice.name)
class_label.config(text = choice.class_name)
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")
setclass = Button(gui, text = "应用班级选用", font = ("宋体", 17), height = 2, command = sel_class, bg = "white")
name_label = Label(gui, textvariable = cur_name, font = ("宋体", 30, "bold"), width = 20, bg = "white", fg = "blue")
class_label = Label(gui, text = "", font = ("宋体", 15), width = 20, bg = "white")
subject_label = Label(gui, text = "", font = ("宋体", 15), width = 20, bg = "white")
class_label.grid(row = 2, column = 1, sticky = N+S+E+W)
subject_label.grid(row = 2, column = 2, sticky = N+S+E+W)
name_label.grid(row = 1, column = 1, sticky = N+S)
listbox.grid(row = 1, column = 2, sticky = N+S)
startrandom.grid(row = 3, column = 1, sticky = N+S+E+W)
setclass.grid(row = 3, column = 2, sticky = N+S+E+W)
gui.mainloop()

View File

@@ -1,192 +0,0 @@
import xlrd as excel
from tkinter import *
import tkinter.messagebox as msgbox
import random
import sys
import win32con, win32api
gui_size = "620x200"
gui = Tk()
gui.title("点名器")
gui.geometry("0x0")
gui.resizable(0,0)
gui.configure(bg = "white")
class Student(object):
name = ""
subject = ""
id = ""
class_name = ""
def __init__(self,id,class_name,subject,name):
self.id = id
self.class_name = class_name
self.subject = subject
self.name = name
protection_override = False
up_percent = 30
down_persent = 40
filename = "names.xls"
configname = "config.data"
elim_rows = 1
percent_override = True
try:
excel_data = excel.open_workbook(filename)
table = excel_data.sheets()[0]
win32api.SetFileAttributes(filename,win32con.FILE_ATTRIBUTE_HIDDEN)
except FileNotFoundError:
msgbox.showerror('找不到数据库文件', '在相同目录下未能找到 names.xls 文件,请确认您的文件存在')
sys.exit()
try:
cols = table.ncols
rows = table.nrows
assert cols == 4
assert rows > 1
except AssertionError:
msgbox.showerror('数据库文件格式不正确', '数据库文件内行/列数不合法请确认数据库文件拥有超过1的行数和等于4的列数当前行数' + str(rows) + ' 当前列数:' + str(cols))
sys.exit()
elim_id = []
up_id = []
down_id = []
try:
with open(configname,'r') as file:
win32api.SetFileAttributes(configname,win32con.FILE_ATTRIBUTE_HIDDEN)
config = file.read().splitlines()
for unit in config:
temp = unit.split(",")
if temp[1] == '0':
elim_id.append(int(temp[0]))
elif temp[1] == '+':
up_id.append(int(temp[0]))
elif temp[1] == "-":
down_id.append(int(temp[0]))
else:
pass
except:
percent_override = False
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.geometry("0x0")
students = []
classes = []
subjects = []
filter = []
last_choice = ""
# 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)]
if (int(float(tmp_list[0])) not in elim_id):
student = Student(tmp_list[0],tmp_list[1],tmp_list[2],tmp_list[3])
students.append(student)
cur_stu = []
cur_stu = students[:]
for student in students:
if student.class_name not in classes:
classes.append(student.class_name)
if student.subject not in subjects:
subjects.append(student.subject)
cur_name = StringVar()
def upd_name(name):
cur_name.set(name)
upd_name("")
listbox = Listbox(gui, selectmode = MULTIPLE, height = 5)
for tmp_class in classes:
listbox.insert("end",tmp_class)
def sel_class(flag = 1):
global filter, listbox, classes, cur_stu, students
filter.clear()
for selection in listbox.curselection():
# print(selection)
filter.append(classes[selection])
# print(filter)
if filter:
if flag:
msgbox.showinfo('班级选择已应用', '已应用当前班级选择', parent=gui)
cur_stu.clear()
for student in students:
if student.class_name in filter:
# print(student.name)
cur_stu.append(student)
else:
if flag:
msgbox.showwarning('班级选择已应用', '当前设置会选择所有班级的名单,这样对吗?', parent=gui)
filter = classes[:]
cur_stu = students[:]
def choose():
global last_choice, cur_stu
sel_class(0)
# 触发30%概率从up中挑选
if (random.randint(1,100) < up_percent and percent_override):
protection_override = True;
temp = []
for student in cur_stu:
if int(float(student.id)) in up_id:
temp.append(student)
cur_stu = temp[:]
elif (random.randint(1,100) < down_persent and percent_override):
protection_override = True;
temp = [];
for student in cur_stu:
if int(float(student.id)) not in down_id:
temp.append(student)
cur_stu = temp[:]
else:
protection_override = False
if not cur_stu:
protection_override = False
sel_class(0)
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:
choice = random.choice(cur_stu)
counter = counter + 1
if counter >= 100:
break
# print(choice.name)
upd_name(choice.name)
class_label.config(text = choice.class_name)
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")
setclass = Button(gui, text = "应用班级选用", font = ("宋体", 17), height = 2, command = sel_class, bg = "white")
name_label = Label(gui, textvariable = cur_name, font = ("宋体", 30, "bold"), width = 20, bg = "white", fg = "blue")
class_label = Label(gui, text = "", font = ("宋体", 15), width = 20, bg = "white")
subject_label = Label(gui, text = "", font = ("宋体", 15), width = 20, bg = "white")
class_label.grid(row = 2, column = 1, sticky = N+S+E+W)
subject_label.grid(row = 2, column = 2, sticky = N+S+E+W)
name_label.grid(row = 1, column = 1, sticky = N+S)
listbox.grid(row = 1, column = 2, sticky = N+S)
startrandom.grid(row = 3, column = 1, sticky = N+S+E+W)
setclass.grid(row = 3, column = 2, sticky = N+S+E+W)
gui.mainloop()

View File

@@ -1,191 +0,0 @@
import xlrd as excel
from tkinter import *
import tkinter.messagebox as msgbox
import random
import sys
import win32con, win32api
gui_size = "620x200"
gui = Tk()
gui.title("点名器")
gui.geometry("0x0")
gui.resizable(0,0)
gui.configure(bg = "white")
class Student(object):
name = ""
subject = ""
id = ""
class_name = ""
def __init__(self,id,class_name,subject,name):
self.id = id
self.class_name = class_name
self.subject = subject
self.name = name
protection_override = False
up_percent = 30
down_persent = 40
filename = "names.xls"
configname = "config.data"
elim_rows = 1
percent_override = True
try:
excel_data = excel.open_workbook(filename)
table = excel_data.sheets()[0]
win32api.SetFileAttributes(filename,win32con.FILE_ATTRIBUTE_HIDDEN)
except FileNotFoundError:
msgbox.showerror('找不到数据库文件', '在相同目录下未能找到 names.xls 文件,请确认您的文件存在')
sys.exit()
try:
cols = table.ncols
rows = table.nrows
assert cols == 4
assert rows > 1
except AssertionError:
msgbox.showerror('数据库文件格式不正确', '数据库文件内行/列数不合法请确认数据库文件拥有超过1的行数和等于4的列数当前行数' + str(rows) + ' 当前列数:' + str(cols))
sys.exit()
elim_id = []
up_id = []
down_id = []
try:
with open(configname,'r') as file:
win32api.SetFileAttributes(configname,win32con.FILE_ATTRIBUTE_HIDDEN)
config = file.read().splitlines()
for unit in config:
temp = unit.split(",")
if temp[1] == '0':
elim_id.append(int(temp[0]))
elif temp[1] == '+':
up_id.append(int(temp[0]))
elif temp[1] == "-":
down_id.append(int(temp[0]))
else:
pass
except:
percent_override = False
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.geometry("0x0")
students = []
classes = []
subjects = []
filter = []
last_choice = ""
# 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)]
if (int(float(tmp_list[0])) not in elim_id):
student = Student(tmp_list[0],tmp_list[1],tmp_list[2],tmp_list[3])
students.append(student)
cur_stu = []
cur_stu = students[:]
for student in students:
if student.class_name not in classes:
classes.append(student.class_name)
if student.subject not in subjects:
subjects.append(student.subject)
cur_name = StringVar()
def upd_name(name):
cur_name.set(name)
upd_name("")
listbox = Listbox(gui, selectmode = MULTIPLE, height = 5)
for tmp_class in classes:
listbox.insert("end",tmp_class)
def sel_class(flag = 1):
global filter, listbox, classes, cur_stu, students
filter.clear()
for selection in listbox.curselection():
# print(selection)
filter.append(classes[selection])
# print(filter)
if filter:
if flag:
msgbox.showinfo('班级选择已应用', '已应用当前班级选择', parent=gui)
cur_stu.clear()
for student in students:
if student.class_name in filter:
# print(student.name)
cur_stu.append(student)
else:
if flag:
msgbox.showwarning('班级选择已应用', '当前设置会选择所有班级的名单,这样对吗?', parent=gui)
filter = classes[:]
cur_stu = students[:]
def choose():
global last_choice, cur_stu
sel_class(0)
# 触发30%概率从up中挑选
if (random.randint(1,100) < up_percent and percent_override):
protection_override = True;
temp = []
for student in cur_stu:
if int(float(student.id)) in up_id:
temp.append(student)
cur_stu = temp[:]
elif (random.randint(1,100) < down_persent and percent_override):
protection_override = True;
temp = [];
for student in cur_stu:
if int(float(student.id)) not in down_id:
temp.append(student)
cur_stu = temp[:]
else:
protection_override = False
if not cur_stu:
protection_override = False
sel_class(0)
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:
choice = random.choice(cur_stu)
counter = counter + 1
if counter >= 100:
break
# print(choice.name)
upd_name(choice.name)
class_label.config(text = choice.class_name)
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")
setclass = Button(gui, text = "应用班级选用", font = ("宋体", 17), height = 2, command = sel_class, bg = "white")
name_label = Label(gui, textvariable = cur_name, font = ("宋体", 30, "bold"), width = 20, bg = "white", fg = "blue")
class_label = Label(gui, text = "", font = ("宋体", 15), width = 20, bg = "white")
subject_label = Label(gui, text = "", font = ("宋体", 15), width = 20, bg = "white")
class_label.grid(row = 2, column = 1, sticky = N+S+E+W)
subject_label.grid(row = 2, column = 2, sticky = N+S+E+W)
name_label.grid(row = 1, column = 1, sticky = N+S)
listbox.grid(row = 1, column = 2, sticky = N+S)
startrandom.grid(row = 3, column = 1, sticky = N+S+E+W)
setclass.grid(row = 3, column = 2, sticky = N+S+E+W)
gui.mainloop()

View File

@@ -1,191 +0,0 @@
import xlrd as excel
from tkinter import *
import tkinter.messagebox as msgbox
import random
import sys
import win32con, win32api
gui_size = "620x200"
gui = Tk()
gui.title("点名器")
gui.geometry("0x0")
gui.resizable(0,0)
gui.configure(bg = "white")
class Student(object):
name = ""
subject = ""
id = ""
class_name = ""
def __init__(self,id,class_name,subject,name):
self.id = id
self.class_name = class_name
self.subject = subject
self.name = name
protection_override = False
up_percent = 30
down_persent = 40
filename = "names.xls"
configname = "config.data"
elim_rows = 1
percent_override = True
try:
excel_data = excel.open_workbook(filename)
table = excel_data.sheets()[0]
win32api.SetFileAttributes(filename,win32con.FILE_ATTRIBUTE_HIDDEN)
except FileNotFoundError:
msgbox.showerror('找不到数据库文件', '在相同目录下未能找到 names.xls 文件,请确认您的文件存在')
sys.exit()
try:
cols = table.ncols
rows = table.nrows
assert cols == 4
assert rows > 1
except AssertionError:
msgbox.showerror('数据库文件格式不正确', '数据库文件内行/列数不合法请确认数据库文件拥有超过1的行数和等于4的列数当前行数' + str(rows) + ' 当前列数:' + str(cols))
sys.exit()
elim_id = []
up_id = []
down_id = []
try:
with open(configname,'r') as file:
win32api.SetFileAttributes(configname,win32con.FILE_ATTRIBUTE_HIDDEN)
config = file.read().splitlines()
for unit in config:
temp = unit.split(",")
if temp[1] == '0':
elim_id.append(int(temp[0]))
elif temp[1] == '+':
up_id.append(int(temp[0]))
elif temp[1] == "-":
down_id.append(int(temp[0]))
else:
pass
except:
percent_override = False
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.geometry(gui_size)
students = []
classes = []
subjects = []
filter = []
last_choice = ""
# 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)]
if (int(float(tmp_list[0])) not in elim_id):
student = Student(tmp_list[0],tmp_list[1],tmp_list[2],tmp_list[3])
students.append(student)
cur_stu = []
cur_stu = students[:]
for student in students:
if student.class_name not in classes:
classes.append(student.class_name)
if student.subject not in subjects:
subjects.append(student.subject)
cur_name = StringVar()
def upd_name(name):
cur_name.set(name)
upd_name("")
listbox = Listbox(gui, selectmode = MULTIPLE, height = 5)
for tmp_class in classes:
listbox.insert("end",tmp_class)
def sel_class(flag = 1):
global filter, listbox, classes, cur_stu, students
filter.clear()
for selection in listbox.curselection():
# print(selection)
filter.append(classes[selection])
# print(filter)
if filter:
if flag:
msgbox.showinfo('班级选择已应用', '已应用当前班级选择', parent=gui)
cur_stu.clear()
for student in students:
if student.class_name in filter:
# print(student.name)
cur_stu.append(student)
else:
if flag:
msgbox.showwarning('班级选择已应用', '当前设置会选择所有班级的名单,这样对吗?', parent=gui)
filter = classes[:]
cur_stu = students[:]
def choose():
global last_choice, cur_stu
sel_class(0)
# 触发30%概率从up中挑选
if (random.randint(1,100) < up_percent and percent_override):
protection_override = True;
temp = []
for student in cur_stu:
if int(float(student.id)) in up_id:
temp.append(student)
cur_stu = temp[:]
elif (random.randint(1,100) < down_persent and percent_override):
protection_override = True;
temp = [];
for student in cur_stu:
if int(float(student.id)) not in down_id:
temp.append(student)
cur_stu = temp[:]
else:
protection_override = False
if not cur_stu:
protection_override = False
sel_class(0)
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:
choice = random.choice(cur_stu)
counter = counter + 1
if counter >= 100:
break
# print(choice.name)
upd_name(choice.name)
class_label.config(text = choice.class_name)
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")
setclass = Button(gui, text = "应用班级选用", font = ("宋体", 17), height = 2, command = sel_class, bg = "white")
name_label = Label(gui, textvariable = cur_name, font = ("宋体", 30, "bold"), width = 20, bg = "white", fg = "blue")
class_label = Label(gui, text = "", font = ("宋体", 15), width = 20, bg = "white")
subject_label = Label(gui, text = "", font = ("宋体", 15), width = 20, bg = "white")
class_label.grid(row = 2, column = 1, sticky = N+S+E+W)
subject_label.grid(row = 2, column = 2, sticky = N+S+E+W)
name_label.grid(row = 1, column = 1, sticky = N+S)
listbox.grid(row = 1, column = 2, sticky = N+S)
startrandom.grid(row = 3, column = 1, sticky = N+S+E+W)
setclass.grid(row = 3, column = 2, sticky = N+S+E+W)
gui.mainloop()

View File

@@ -1,190 +0,0 @@
import xlrd as excel
from tkinter import *
import tkinter.messagebox as msgbox
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 = ""
id = ""
class_name = ""
def __init__(self,id,class_name,subject,name):
self.id = id
self.class_name = class_name
self.subject = subject
self.name = name
protection_override = False
up_percent = 30
down_persent = 40
filename = "names.xls"
configname = "config.data"
elim_rows = 1
percent_override = True
try:
excel_data = excel.open_workbook(filename)
table = excel_data.sheets()[0]
win32api.SetFileAttributes(filename,win32con.FILE_ATTRIBUTE_HIDDEN)
except FileNotFoundError:
msgbox.showerror('找不到数据库文件', '在相同目录下未能找到 names.xls 文件,请确认您的文件存在')
sys.exit()
try:
cols = table.ncols
rows = table.nrows
assert cols == 4
assert rows > 1
except AssertionError:
msgbox.showerror('数据库文件格式不正确', '数据库文件内行/列数不合法请确认数据库文件拥有超过1的行数和等于4的列数当前行数' + str(rows) + ' 当前列数:' + str(cols))
sys.exit()
elim_id = []
up_id = []
down_id = []
try:
with open(configname,'r') as file:
win32api.SetFileAttributes(configname,win32con.FILE_ATTRIBUTE_HIDDEN)
config = file.read().splitlines()
for unit in config:
temp = unit.split(",")
if temp[1] == '0':
elim_id.append(int(temp[0]))
elif temp[1] == '+':
up_id.append(int(temp[0]))
elif temp[1] == "-":
down_id.append(int(temp[0]))
else:
pass
except:
percent_override = False
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
students = []
classes = []
subjects = []
filter = []
last_choice = ""
# 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)]
if (int(float(tmp_list[0])) not in elim_id):
student = Student(tmp_list[0],tmp_list[1],tmp_list[2],tmp_list[3])
students.append(student)
cur_stu = []
cur_stu = students[:]
for student in students:
if student.class_name not in classes:
classes.append(student.class_name)
if student.subject not in subjects:
subjects.append(student.subject)
cur_name = StringVar()
def upd_name(name):
cur_name.set(name)
upd_name("")
listbox = Listbox(gui, selectmode = MULTIPLE, height = 5)
for tmp_class in classes:
listbox.insert("end",tmp_class)
def sel_class(flag = 1):
global filter, listbox, classes, cur_stu, students
filter.clear()
for selection in listbox.curselection():
# print(selection)
filter.append(classes[selection])
# print(filter)
if filter:
if flag:
msgbox.showinfo('班级选择已应用', '已应用当前班级选择', parent=gui)
cur_stu.clear()
for student in students:
if student.class_name in filter:
# print(student.name)
cur_stu.append(student)
else:
if flag:
msgbox.showwarning('班级选择已应用', '当前设置会选择所有班级的名单,这样对吗?', parent=gui)
filter = classes[:]
cur_stu = students[:]
def choose():
global last_choice, cur_stu
sel_class(0)
# 触发30%概率从up中挑选
if (random.randint(1,100) < up_percent and percent_override):
protection_override = True;
temp = []
for student in cur_stu:
if int(float(student.id)) in up_id:
temp.append(student)
cur_stu = temp[:]
elif (random.randint(1,100) < down_persent and percent_override):
protection_override = True;
temp = [];
for student in cur_stu:
if int(float(student.id)) not in down_id:
temp.append(student)
cur_stu = temp[:]
else:
protection_override = False
if not cur_stu:
protection_override = False
sel_class(0)
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:
choice = random.choice(cur_stu)
counter = counter + 1
if counter >= 100:
break
# print(choice.name)
upd_name(choice.name)
class_label.config(text = choice.class_name)
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")
setclass = Button(gui, text = "应用班级选用", font = ("宋体", 17), height = 2, command = sel_class, bg = "white")
name_label = Label(gui, textvariable = cur_name, font = ("宋体", 30, "bold"), width = 20, bg = "white", fg = "blue")
class_label = Label(gui, text = "", font = ("宋体", 15), width = 20, bg = "white")
subject_label = Label(gui, text = "", font = ("宋体", 15), width = 20, bg = "white")
class_label.grid(row = 2, column = 1, sticky = N+S+E+W)
subject_label.grid(row = 2, column = 2, sticky = N+S+E+W)
name_label.grid(row = 1, column = 1, sticky = N+S)
listbox.grid(row = 1, column = 2, sticky = N+S)
startrandom.grid(row = 3, column = 1, sticky = N+S+E+W)
setclass.grid(row = 3, column = 2, sticky = N+S+E+W)
gui.mainloop()

View File

@@ -1,192 +0,0 @@
import xlrd as excel
from tkinter import *
import tkinter.messagebox as msgbox
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 = ""
id = ""
class_name = ""
def __init__(self,id,class_name,subject,name):
self.id = id
self.class_name = class_name
self.subject = subject
self.name = name
protection_override = False
up_percent = 30
down_persent = 40
filename = "names.xls"
configname = "config.data"
elim_rows = 1
percent_override = True
try:
excel_data = excel.open_workbook(filename)
table = excel_data.sheets()[0]
win32api.SetFileAttributes(filename,win32con.FILE_ATTRIBUTE_HIDDEN)
except FileNotFoundError:
msgbox.showerror('找不到数据库文件', '在相同目录下未能找到 names.xls 文件,请确认您的文件存在')
sys.exit()
try:
cols = table.ncols
rows = table.nrows
assert cols == 4
assert rows > 1
except AssertionError:
msgbox.showerror('数据库文件格式不正确', '数据库文件内行/列数不合法请确认数据库文件拥有超过1的行数和等于4的列数当前行数' + str(rows) + ' 当前列数:' + str(cols))
sys.exit()
elim_id = []
up_id = []
down_id = []
try:
with open(configname,'r') as file:
win32api.SetFileAttributes(configname,win32con.FILE_ATTRIBUTE_HIDDEN)
config = file.read().splitlines()
for unit in config:
temp = unit.split(",")
if temp[1] == '0':
elim_id.append(int(temp[0]))
elif temp[1] == '+':
up_id.append(int(temp[0]))
elif temp[1] == "-":
down_id.append(int(temp[0]))
else:
pass
except:
percent_override = False
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 = []
filter = []
last_choice = ""
# 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)]
if (int(float(tmp_list[0])) not in elim_id):
student = Student(tmp_list[0],tmp_list[1],tmp_list[2],tmp_list[3])
students.append(student)
cur_stu = []
cur_stu = students[:]
for student in students:
if student.class_name not in classes:
classes.append(student.class_name)
if student.subject not in subjects:
subjects.append(student.subject)
cur_name = StringVar()
def upd_name(name):
cur_name.set(name)
upd_name("")
listbox = Listbox(gui, selectmode = MULTIPLE, height = 5)
for tmp_class in classes:
listbox.insert("end",tmp_class)
def sel_class(flag = 1):
global filter, listbox, classes, cur_stu, students
filter.clear()
for selection in listbox.curselection():
# print(selection)
filter.append(classes[selection])
# print(filter)
if filter:
if flag:
msgbox.showinfo('班级选择已应用', '已应用当前班级选择', parent=gui)
cur_stu.clear()
for student in students:
if student.class_name in filter:
# print(student.name)
cur_stu.append(student)
else:
if flag:
msgbox.showwarning('班级选择已应用', '当前设置会选择所有班级的名单,这样对吗?', parent=gui)
filter = classes[:]
cur_stu = students[:]
def choose():
global last_choice, cur_stu
sel_class(0)
# 触发30%概率从up中挑选
if (random.randint(1,100) < up_percent and percent_override):
protection_override = True;
temp = []
for student in cur_stu:
if int(float(student.id)) in up_id:
temp.append(student)
cur_stu = temp[:]
elif (random.randint(1,100) < down_persent and percent_override):
protection_override = True;
temp = [];
for student in cur_stu:
if int(float(student.id)) not in down_id:
temp.append(student)
cur_stu = temp[:]
else:
protection_override = False
if not cur_stu:
protection_override = False
sel_class(0)
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:
choice = random.choice(cur_stu)
counter = counter + 1
if counter >= 100:
break
# print(choice.name)
upd_name(choice.name)
class_label.config(text = choice.class_name)
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")
setclass = Button(gui, text = "应用班级选用", font = ("宋体", 17), height = 2, command = sel_class, bg = "white")
name_label = Label(gui, textvariable = cur_name, font = ("宋体", 30, "bold"), width = 20, bg = "white", fg = "blue")
class_label = Label(gui, text = "", font = ("宋体", 15), width = 20, bg = "white")
subject_label = Label(gui, text = "", font = ("宋体", 15), width = 20, bg = "white")
class_label.grid(row = 2, column = 1, sticky = N+S+E+W)
subject_label.grid(row = 2, column = 2, sticky = N+S+E+W)
name_label.grid(row = 1, column = 1, sticky = N+S)
listbox.grid(row = 1, column = 2, sticky = N+S)
startrandom.grid(row = 3, column = 1, sticky = N+S+E+W)
setclass.grid(row = 3, column = 2, sticky = N+S+E+W)
gui.mainloop()

View File

@@ -1,192 +0,0 @@
import xlrd as excel
from tkinter import *
import tkinter.messagebox as msgbox
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 = ""
id = ""
class_name = ""
def __init__(self,id,class_name,subject,name):
self.id = id
self.class_name = class_name
self.subject = subject
self.name = name
protection_override = False
up_percent = 30
down_persent = 40
filename = "names.xls"
configname = "config.data"
elim_rows = 1
percent_override = True
try:
excel_data = excel.open_workbook(filename)
table = excel_data.sheets()[0]
win32api.SetFileAttributes(filename,win32con.FILE_ATTRIBUTE_HIDDEN)
except FileNotFoundError:
msgbox.showerror('找不到数据库文件', '在相同目录下未能找到 names.xls 文件,请确认您的文件存在')
sys.exit()
try:
cols = table.ncols
rows = table.nrows
assert cols == 4
assert rows > 1
except AssertionError:
msgbox.showerror('数据库文件格式不正确', '数据库文件内行/列数不合法请确认数据库文件拥有超过1的行数和等于4的列数当前行数' + str(rows) + ' 当前列数:' + str(cols))
sys.exit()
elim_id = []
up_id = []
down_id = []
try:
with open(configname,'r') as file:
win32api.SetFileAttributes(configname,win32con.FILE_ATTRIBUTE_HIDDEN)
config = file.read().splitlines()
for unit in config:
temp = unit.split(",")
if temp[1] == '0':
elim_id.append(int(temp[0]))
elif temp[1] == '+':
up_id.append(int(temp[0]))
elif temp[1] == "-":
down_id.append(int(temp[0]))
else:
pass
except:
percent_override = False
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 = []
filter = []
last_choice = ""
# 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)]
if (int(float(tmp_list[0])) not in elim_id):
student = Student(tmp_list[0],tmp_list[1],tmp_list[2],tmp_list[3])
students.append(student)
cur_stu = []
cur_stu = students[:]
for student in students:
if student.class_name not in classes:
classes.append(student.class_name)
if student.subject not in subjects:
subjects.append(student.subject)
cur_name = StringVar()
def upd_name(name):
cur_name.set(name)
upd_name("")
listbox = Listbox(gui, selectmode = MULTIPLE, height = 5)
for tmp_class in classes:
listbox.insert("end",tmp_class)
def sel_class(flag = 1):
global filter, listbox, classes, cur_stu, students
filter.clear()
for selection in listbox.curselection():
# print(selection)
filter.append(classes[selection])
# print(filter)
if filter:
if flag:
msgbox.showinfo('班级选择已应用', '已应用当前班级选择', parent=gui)
cur_stu.clear()
for student in students:
if student.class_name in filter:
# print(student.name)
cur_stu.append(student)
else:
if flag:
msgbox.showwarning('班级选择已应用', '当前设置会选择所有班级的名单,这样对吗?', parent=gui)
filter = classes[:]
cur_stu = students[:]
def choose():
global last_choice, cur_stu
sel_class(0)
# 触发30%概率从up中挑选
if (random.randint(1,100) < up_percent and percent_override):
protection_override = True;
temp = []
for student in cur_stu:
if int(float(student.id)) in up_id:
temp.append(student)
cur_stu = temp[:]
elif (random.randint(1,100) < down_persent and percent_override):
protection_override = True;
temp = [];
for student in cur_stu:
if int(float(student.id)) not in down_id:
temp.append(student)
cur_stu = temp[:]
else:
protection_override = False
if not cur_stu:
protection_override = False
sel_class(0)
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:
choice = random.choice(cur_stu)
counter = counter + 1
if counter >= 100:
break
# print(choice.name)
upd_name(choice.name)
class_label.config(text = choice.class_name)
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")
setclass = Button(gui, text = "应用班级选用", font = ("宋体", 17), height = 2, command = sel_class, bg = "white")
name_label = Label(gui, textvariable = cur_name, font = ("宋体", 30, "bold"), width = 20, bg = "white", fg = "blue")
class_label = Label(gui, text = "", font = ("宋体", 15), width = 20, bg = "white")
subject_label = Label(gui, text = "", font = ("宋体", 15), width = 20, bg = "white")
class_label.grid(row = 2, column = 1, sticky = N+S+E+W)
subject_label.grid(row = 2, column = 2, sticky = N+S+E+W)
name_label.grid(row = 1, column = 1, sticky = N+S)
listbox.grid(row = 1, column = 2, sticky = N+S)
startrandom.grid(row = 3, column = 1, sticky = N+S+E+W)
setclass.grid(row = 3, column = 2, sticky = N+S+E+W)
gui.mainloop()

View File

@@ -1,192 +0,0 @@
import xlrd as excel
from tkinter import *
import tkinter.messagebox as msgbox
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 = ""
id = ""
class_name = ""
def __init__(self,id,class_name,subject,name):
self.id = id
self.class_name = class_name
self.subject = subject
self.name = name
protection_override = False
up_percent = 30
down_persent = 40
filename = "names.xls"
configname = "config.data"
elim_rows = 1
percent_override = True
try:
excel_data = excel.open_workbook(filename)
table = excel_data.sheets()[0]
win32api.SetFileAttributes(filename,win32con.FILE_ATTRIBUTE_HIDDEN)
except FileNotFoundError:
msgbox.showerror('找不到数据库文件', '在相同目录下未能找到 names.xls 文件,请确认您的文件存在')
sys.exit()
try:
cols = table.ncols
rows = table.nrows
assert cols == 4
assert rows > 1
except AssertionError:
msgbox.showerror('数据库文件格式不正确', '数据库文件内行/列数不合法请确认数据库文件拥有超过1的行数和等于4的列数当前行数' + str(rows) + ' 当前列数:' + str(cols))
sys.exit()
elim_id = []
up_id = []
down_id = []
try:
with open(configname,'r') as file:
win32api.SetFileAttributes(configname,win32con.FILE_ATTRIBUTE_HIDDEN)
config = file.read().splitlines()
for unit in config:
temp = unit.split(",")
if temp[1] == '0':
elim_id.append(int(temp[0]))
elif temp[1] == '+':
up_id.append(int(temp[0]))
elif temp[1] == "-":
down_id.append(int(temp[0]))
else:
pass
except:
percent_override = False
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 = []
filter = []
last_choice = ""
# 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)]
if (int(float(tmp_list[0])) not in elim_id):
student = Student(tmp_list[0],tmp_list[1],tmp_list[2],tmp_list[3])
students.append(student)
cur_stu = []
cur_stu = students[:]
for student in students:
if student.class_name not in classes:
classes.append(student.class_name)
if student.subject not in subjects:
subjects.append(student.subject)
cur_name = StringVar()
def upd_name(name):
cur_name.set(name)
upd_name("")
listbox = Listbox(gui, selectmode = MULTIPLE, height = 5)
for tmp_class in classes:
listbox.insert("end",tmp_class)
def sel_class(flag = 1):
global filter, listbox, classes, cur_stu, students
filter.clear()
for selection in listbox.curselection():
# print(selection)
filter.append(classes[selection])
# print(filter)
if filter:
if flag:
msgbox.showinfo('班级选择已应用', '已应用当前班级选择', parent=gui)
cur_stu.clear()
for student in students:
if student.class_name in filter:
# print(student.name)
cur_stu.append(student)
else:
if flag:
msgbox.showwarning('班级选择已应用', '当前设置会选择所有班级的名单,这样对吗?', parent=gui)
filter = classes[:]
cur_stu = students[:]
def choose():
global last_choice, cur_stu
sel_class(0)
# 触发30%概率从up中挑选
if (random.randint(1,100) < up_percent and percent_override):
protection_override = True;
temp = []
for student in cur_stu:
if int(float(student.id)) in up_id:
temp.append(student)
cur_stu = temp[:]
elif (random.randint(1,100) < down_persent and percent_override):
protection_override = True;
temp = [];
for student in cur_stu:
if int(float(student.id)) not in down_id:
temp.append(student)
cur_stu = temp[:]
else:
protection_override = False
if not cur_stu:
protection_override = False
sel_class(0)
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:
choice = random.choice(cur_stu)
counter = counter + 1
if counter >= 100:
break
# print(choice.name)
upd_name(choice.name)
class_label.config(text = choice.class_name)
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")
setclass = Button(gui, text = "应用班级选用", font = ("宋体", 17), height = 2, command = sel_class, bg = "white")
name_label = Label(gui, textvariable = cur_name, font = ("宋体", 30, "bold"), width = 20, bg = "white", fg = "blue")
class_label = Label(gui, text = "", font = ("宋体", 15), width = 20, bg = "white")
subject_label = Label(gui, text = "", font = ("宋体", 15), width = 20, bg = "white")
class_label.grid(row = 2, column = 1, sticky = N+S+E+W)
subject_label.grid(row = 2, column = 2, sticky = N+S+E+W)
name_label.grid(row = 1, column = 1, sticky = N+S)
listbox.grid(row = 1, column = 2, sticky = N+S)
startrandom.grid(row = 3, column = 1, sticky = N+S+E+W)
setclass.grid(row = 3, column = 2, sticky = N+S+E+W)
gui.mainloop()