def atLogin(self): user = self.userEdit.text() password = self.passEdit.text() try: self.zxw = Zhixuewang(user, password) except UserOrPassError as e: self.loginErrLabel.show() else: self.loginErrLabel.hide() self.initExamList()
def check(self, Dialog_Login): user = str(self.textID.text()) pswd = str(self.textPassword.text()) try: zxw = Zhixuewang(user, pswd) except Exception as e: print("ERROR:" + str(e)) #TODO:Destroy this window self.form2 = QtWidgets.QMainWindow() self.m = mainWindow.Ui_MainWindow(zxw) self.m.setupUi(self.form2) self.form2.show()
class MainGUI(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): self.userLabel = QLabel("考号") self.userEdit = QLineEdit() self.passLabel = QLabel("密码") self.passEdit = QLineEdit() self.passEdit.setEchoMode(QLineEdit.Password) self.loginButton = QPushButton("登录") self.loginButton.clicked.connect(self.atLogin) self.loginErrLabel = QLabel("考号或密码错误") self.loginErrLabel.hide() self.loginLayout = QGridLayout() self.loginLayout.addWidget(self.userLabel, 1, 0) self.loginLayout.addWidget(self.userEdit, 1, 1) self.loginLayout.addWidget(self.passLabel, 2, 0) self.loginLayout.addWidget(self.passEdit, 2, 1) self.loginLayout.addWidget(self.loginButton, 3, 0) self.loginLayout.addWidget(self.loginErrLabel, 3, 1) self.authorInfo = QLabel("Origami404 @ github") self.githubUrl = QLabel("https://github.com/Origami404/CommandZhixue") self.sign = QLabel("考试快乐~ QwQ") self.infoLayout = QGridLayout() self.infoLayout.addWidget(self.authorInfo, 1, 0) self.infoLayout.addWidget(self.githubUrl, 2, 0) self.infoLayout.addWidget(self.sign, 3, 0) self.examLabel = QLabel("考试列表") self.examTable = QTableWidget(self) self.examTable.setColumnCount(1) self.examTable.setHorizontalHeaderLabels(['名称']) self.examTable.setEditTriggers(QTableWidget.NoEditTriggers) self.examTable.cellActivated.connect(self.atActivatedExam) self.examTable.horizontalHeader().setSectionResizeMode( QHeaderView.Stretch) self.scoreLabel = QLabel("自己成绩") self.scoreTable = QTableWidget(self) self.scoreTable.setColumnCount(3) self.scoreTable.setHorizontalHeaderLabels(['科目', '分数', '班级排名']) self.scoreTable.setEditTriggers(QTableWidget.NoEditTriggers) self.scoreTable.horizontalHeader().setSectionResizeMode( QHeaderView.Stretch) self.classScoreLabel = QLabel("本班成绩") self.classScoreInfoTable = QTableWidget(self) self.classScoreInfoTable.setColumnCount(4) self.classScoreInfoTable.setHorizontalHeaderLabels( ['科目', '平均分', '最高分', '最低分']) self.classScoreInfoTable.setEditTriggers(QTableWidget.NoEditTriggers) self.classScoreInfoTable.horizontalHeader().setSectionResizeMode( QHeaderView.Stretch) self.gradeScoreInfoLabel = QLabel("全级成绩") self.gradeScoreInfoTable = QTableWidget(self) self.gradeScoreInfoTable.setColumnCount(4) self.gradeScoreInfoTable.setHorizontalHeaderLabels( ['科目', '平均分', '最高分', '最低分']) self.gradeScoreInfoTable.setEditTriggers(QTableWidget.NoEditTriggers) self.gradeScoreInfoTable.horizontalHeader().setSectionResizeMode( QHeaderView.Stretch) self.guiLayout = QGridLayout() self.guiLayout.addLayout(self.loginLayout, 0, 0) self.guiLayout.addLayout(self.infoLayout, 0, 1) self.guiLayout.addWidget(self.examLabel, 1, 0) self.guiLayout.addWidget(self.examTable, 2, 0) self.guiLayout.addWidget(self.scoreLabel, 1, 1) self.guiLayout.addWidget(self.scoreTable, 2, 1) self.guiLayout.addWidget(self.classScoreLabel, 3, 0) self.guiLayout.addWidget(self.classScoreInfoTable, 4, 0) self.guiLayout.addWidget(self.gradeScoreInfoLabel, 3, 1) self.guiLayout.addWidget(self.gradeScoreInfoTable, 4, 1) self.setLayout(self.guiLayout) self.setStyleSheet(''' QLabel { font-size: 12px; font-family: 微软雅黑; } ''') def atLogin(self): user = self.userEdit.text() password = self.passEdit.text() try: self.zxw = Zhixuewang(user, password) except UserOrPassError as e: self.loginErrLabel.show() else: self.loginErrLabel.hide() self.initExamList() def initExamList(self): self.examList = self.zxw.get_exams() self.examTable.setRowCount(len(self.examList)) for i, exam in enumerate(self.examList): self.examTable.setItem(i, 0, QTableWidgetItem(str(exam.examName))) def atActivatedExam(self, row, column): subject = self.zxw.get_self_mark(self.examList[row]) self.scoreTable.setRowCount(len(subject)) self.classScoreInfoTable.setRowCount(len(subject)) self.gradeScoreInfoTable.setRowCount(len(subject)) for (i, score) in enumerate(subject): self.scoreTable.setItem(i, 0, QTableWidgetItem(score.subjectName)) self.scoreTable.setItem(i, 1, QTableWidgetItem(str(score.score))) self.scoreTable.setItem( i, 2, QTableWidgetItem(str(score.classRank.rank))) self.classScoreInfoTable.setItem( i, 0, QTableWidgetItem(score.subjectName)) self.classScoreInfoTable.setItem( i, 1, QTableWidgetItem(str(score.classRank.avgScore))) self.classScoreInfoTable.setItem( i, 2, QTableWidgetItem(str(score.classRank.highScore))) self.classScoreInfoTable.setItem( i, 3, QTableWidgetItem(str(score.classRank.lowScore))) self.gradeScoreInfoTable.setItem( i, 0, QTableWidgetItem(score.subjectName)) self.gradeScoreInfoTable.setItem( i, 1, QTableWidgetItem(str(score.gradeRank.avgScore))) self.gradeScoreInfoTable.setItem( i, 2, QTableWidgetItem(str(score.gradeRank.highScore))) self.gradeScoreInfoTable.setItem( i, 3, QTableWidgetItem(str(score.gradeRank.lowScore)))
def clear_screen(): os_version = platform.platform() if os_version[0] == 'W': os.system('cls') else: os.system('clear') print('Init finish. Wait for input.') zxw = None while zxw == None: print('Exec login subprogramme') user = input('User Name: ') password = getpass() try: zxw = Zhixuewang(user, password) except UserOrPassError as e: print('User name or password error.') print('Login successfully.') op = 1 exams = None while op != 2: is_vaild_exam_num = False choosen_examnum = -1 while not is_vaild_exam_num: clear_screen() if exams == None: exams = zxw.get_exams() for i, exam in enumerate(exams): print(f'{i}. {exam.examName}')
from zhixuewang import Zhixuewang username = input("请输入用户名:") password = input("请输入密码:") zxw = Zhixuewang(username=username, password=password) for examData in zxw.get_exams(): print(examData.examId) print(examData.examName) # print(response.json()) # # print("%s:" % grades.pop("examName")) # # # # # # for k, v in grades.items(): # # print("%s:\n\t分数:%s" % (k, v.score)) # # print("\t班级最高分:%s" % v.classRank.highScore) # # print("\t班级平均分:%s" % v.classRank.avgScore) # # print("\t班级排名:%s" % v.classRank.rank) # # print("\t年级平均分:%s" % v.gradeRank.avgScore) # # print("\t年级最高分:%s" % v.gradeRank.highScore) # # # #
from zhixuewang import Zhixuewang username = input("请输入用户名:") password = input("请输入密码:") zxw = Zhixuewang(username, password) for exam in zxw.get_exams(): print(exam.id) print(exam.name) # print(response.json()) # # print("%s:" % grades.pop("examName")) # # # # # # for k, v in grades.items(): # # print("%s:\n\t分数:%s" % (k, v.score)) # # print("\t班级最高分:%s" % v.classRank.highScore) # # print("\t班级平均分:%s" % v.classRank.avgScore) # # print("\t班级排名:%s" % v.classRank.rank) # # print("\t年级平均分:%s" % v.gradeRank.avgScore) # # print("\t年级最高分:%s" % v.gradeRank.highScore) # # # #
from zhixuewang import Zhixuewang import zhixuewang.exam user = input('user:'******'psword:') zxw = Zhixuewang(user, password) grades = zxw.get_self_grade() score = 0 #print(list(grades[0]))#['subjectName']) for grade in grades: if (grade.subjectName == '语文' or grade.subjectName == '数学' or grade.subjectName == '英语'): score += grade.score if (grade.subjectName == '政治' or grade.subjectName == '历史'): if (grade.score >= 85): score += 10 elif (grade.score >= 70): score += 8 elif (grade.score >= 60): score += 6 else: score += 4 if (grade.subjectName == '物理'): score += grade.score * 0.9 if (grade.subjectName == '化学'): score += grade.score * 0.6 print('科目:', grade.subjectName, '班级最高分:', grade.classRank.highScore, '年段最高分', grade.gradeRank.highScore) print('成绩:', grade.score) print('班级排名:', grade.classRank.rank) print('当前综合分为:', score)
from zhixuewang import Zhixuewang user = input('user:'******'psword:') zxw = Zhixuewang(user, password) def get_mark(subject): resScore = 0 subjectName = subject.subjectName score = subject.score if(subjectName == '语文' or subjectName == '数学' or subjectName == '英语'): resScore += score if(subjectName == '政治' or subjectName == '历史'): if(score >= 85): resScore = 10 elif(score >= 70): resScore += 8 elif(score >= 60): resScore += 6 else: resScore += 4 if(subjectName == '物理'): resScore += score*0.9 if(subjectName == '化学'): resScore += score*0.6 print('科目:', subjectName, '班级最高分:', subject.classRank.highScore, '年段最高分', subject.gradeRank.highScore) print('成绩:', score) print('班级排名:', subject.classRank.rank) return resScore