From 7c59584d3d2ce24c92b5fdd5296aa1470d1ad1c0 Mon Sep 17 00:00:00 2001 From: 13632530821 Date: Tue, 22 Nov 2022 16:53:45 +0800 Subject: [PATCH] =?UTF-8?q?v1.2.2=EF=BC=9A=E4=BC=A0=E5=8F=82=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E6=98=BE=E7=A4=BA=E8=BD=AF=E4=BB=B6=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=20=E5=8F=98=E9=87=8F=E5=A3=B0=E6=98=8E=E7=A7=BB=E8=87=B3?= =?UTF-8?q?=E5=A4=B4=E9=83=A8=20=E6=9B=B4=E6=96=B0README=20=E5=85=B3?= =?UTF-8?q?=E4=BA=8E=E8=BD=AF=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- README.md | 12 ++++++++- 点名器.pyw | 79 +++++++++++++++++++++++++++++++++++++++++------------- 3 files changed, 73 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index 310d4ee..77a402f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ Build32.bat bin/ bin32/ data/ -*.spec \ No newline at end of file +*.spec +.vscode/ \ No newline at end of file diff --git a/README.md b/README.md index 8f7008d..7d42df9 100644 --- a/README.md +++ b/README.md @@ -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)中检查是否有新版本,如果有,请删除本软件,并重新安装最新版本 + 如果仍未解决问题,请联系作者 +## 关于本软件 +本软件受`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 man’s mind. >

----James Clerk Maxwell (1850)

\ No newline at end of file diff --git a/点名器.pyw b/点名器.pyw index 2f3b008..948c7d7 100644 --- a/点名器.pyw +++ b/点名器.pyw @@ -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 . +''' + 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):