v1.2.2:传参可以显示软件信息 变量声明移至头部 更新README 关于软件

This commit is contained in:
13632530821
2022-11-22 16:53:45 +08:00
parent 87c3037430
commit 7c59584d3d
3 changed files with 73 additions and 21 deletions

3
.gitignore vendored
View File

@@ -4,4 +4,5 @@ Build32.bat
bin/
bin32/
data/
*.spec
*.spec
.vscode/

View File

@@ -1,6 +1,6 @@
# 随机点名器 README
> 当前`README.md`以 `点名器 v1.2.1` 为最新版,会与最新版本持续更新。
> 当前`README.md`以 `点名器 v1.2.2` 为最新版,会与最新版本持续更新。
## 基本结构
@@ -150,5 +150,15 @@
+ 请在[gitee仓库](https://gitee.com/hchazzy/random_picker)中检查是否有新版本,如果有,请删除本软件,并重新安装最新版本
+ 如果仍未解决问题,请联系作者<peter13632530821@163.com>
## 关于本软件
本软件受`GNU General Public License v3.0`开源协议保护,任何人均可随意使用/修改本软件,任何对本软件的分发需随附源码与许可证,如果对本软件进行了修改并二次分发,请注明修改部分及修改时间,详细内容请参阅[GPL v3协议](https://www.gnu.org/licenses/)。
你可以在[这里](https://gitee.com/hchazzy/random_picker/blob/master/LICENCE)查看随源码附带的LICENCE文件如果需要分发本软件请随附此许可证。
如果需要分发软件的编译版本也请随附LICENCE文件如果不便附加文件请告知[查看LICENCE文件的方法](#推荐的在编译版本中查看licence的方法)。
#### 推荐的在编译版本中查看LICENCE的方法
运行本程序时,传入`--licence`参数程序将打开许可证信息并提示用户访问LICENCE文件。可以通过`命令提示符``快捷方式`来运行程序以传入参数。
> The actual science of logic is conversant at present only with things either certain, impossible, or entirely doubtful, none of which (fortunately) we have to reason on. Therefore the true logic for this world is the calculus of probabilities, which takes account of the magnitude of the probability which is, or ought to be, in a reasonable mans mind.
> <p align="right">----James Clerk Maxwell (1850)</p>

View File

@@ -1,9 +1,30 @@
'''
Random_Picker 用Python实现的随机点名器
Copyright (C) 2022 海Cha
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
'''
import xlrd as excel
from tkinter import *
import tkinter.messagebox as msgbox
import random
import sys
import winsound
import webbrowser
version = "v1.2.2"
filename = "./data/names.xls"
configname = "./data/config.data"
@@ -12,8 +33,25 @@ procname = "./assets/proc.wav"
iconname = "./assets/点名器.ico"
gui_size = "650x200"
protection_override = False
up_percent = 30
down_persent = 40
elim_rows = 1
percent_override = True
elim_id = []
up_id = []
down_id = []
sound = True
students = []
classes = []
subjects = []
filter = []
last_choice = ""
gui = Tk()
gui.withdraw()
@@ -22,6 +60,28 @@ gui.geometry(gui_size)
gui.resizable(0,0)
gui.configure(bg = "white")
try:
if len(sys.argv) > 1:
for arg in sys.argv[1:]:
if arg == "--licence":
if msgbox.askokcancel('许可证信息', '点名器 ' + version + ' Copyright (C) 2022 海Cha\n本程序是开源程序,受开源协议 GNU General Public Licence v3.0 (GPL v3) 保护\n基于GPL v3协议本程序没有任何质量保证。\n这是一个自由软件,欢迎再次分发。\n点击「确认」将会由系统默认浏览器打开LICENCE文件\n出现此对话框的原因是由于您在运行本软件时传入了 --licence 参数,欲启动主程序,请移除该参数。'):
webbrowser.open_new_tab('https://www.gnu.org/licenses/gpl-3.0.html')
assert False
if arg == "--version":
msgbox.showinfo('版本信息', '点名器 ' + version + ' Copyright (C) 2022 海Cha\n出现此对话框的原因是由于您在运行本软件时传入了 --version 参数,欲启动主程序,请移除该参数。')
assert False
if arg == "--help":
msgbox.showinfo('帮助信息','----- 点名器 ' + version + ' -----\n--licence 显示许可证信息\n--version 显示版本信息\n--path 显示程序运行路径\n--help 显示此信息\n欲打开主程序GUI则无需传参\n出现此对话框的原因是由于您在运行本软件时传入了 --help 参数,欲启动主程序,请移除该参数。')
assert False
if arg == "--path":
msgbox.showinfo('路径信息','点名器 ' + version + ' Copyright (C) 2022 海Cha\n当前程序运行在 ' + sys.argv[0] + ' 路径上\n出现此对话框的原因是由于您在运行本软件时传入了 --path 参数,欲启动主程序,请移除该参数。')
assert False
if arg.find("--") != -1:
msgbox.showerror('传参错误','无法识别参数 ' + arg + ' 请调整您的启动参数\n传入 --help以查看帮助信息\n出现此对话框的原因是由于您在运行本软件时传入了 ' + arg + ' 参数,欲启动主程序,请移除该参数。')
assert False
except AssertionError:
sys.exit()
try:
file = open(iconname)
file.close()
@@ -53,12 +113,6 @@ class Student(object):
self.subject = subject
self.name = name
protection_override = False
up_percent = 30
down_persent = 40
elim_rows = 1
percent_override = True
try:
with excel.open_workbook(filename) as excel_data:
table = excel_data.sheets()[0]
@@ -76,10 +130,6 @@ 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)
@@ -102,15 +152,6 @@ 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):