[Python] 纯文本查看 复制代码
from PySide6.QtCore import (QCoreApplication, QMetaObject, QRect,
QSize,QThread,Signal)
from PySide6.QtWidgets import (QApplication, QFormLayout, QFrame, QGridLayout,
QGroupBox, QHBoxLayout, QLabel,
QMainWindow, QMenuBar, QProgressBar, QSizePolicy,
QSpacerItem, QStackedWidget, QStatusBar, QVBoxLayout,
QWidget, QMessageBox)
import sys,requests,time,os,base64,pathlib,random,locale
from qfluentwidgets import (BodyLabel, ComboBox, LineEdit, ListWidget,
PushButton, TextEdit)
locale.setlocale(locale.LC_CTYPE, "Chinese")
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
if not MainWindow.objectName():
MainWindow.setObjectName(u"MainWindow")
MainWindow.resize(673, 472)
sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(MainWindow.sizePolicy().hasHeightForWidth())
MainWindow.setSizePolicy(sizePolicy)
MainWindow.setStyleSheet(u"")
self.centralwidget = QWidget(MainWindow)
self.centralwidget.setObjectName(u"centralwidget")
sizePolicy.setHeightForWidth(self.centralwidget.sizePolicy().hasHeightForWidth())
self.centralwidget.setSizePolicy(sizePolicy)
self.formLayout = QFormLayout(self.centralwidget)
self.formLayout.setObjectName(u"formLayout")
self.verticalLayout = QVBoxLayout()
self.verticalLayout.setObjectName(u"verticalLayout")
self.label = BodyLabel(self.centralwidget)
self.label.setObjectName(u"label")
sizePolicy1 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
sizePolicy1.setHorizontalStretch(0)
sizePolicy1.setVerticalStretch(0)
sizePolicy1.setHeightForWidth(self.label.sizePolicy().hasHeightForWidth())
self.label.setSizePolicy(sizePolicy1)
self.label.setMaximumSize(QSize(16777215, 16777215))
self.label.setStyleSheet(u"")
self.label.setScaledContents(False)
self.verticalLayout.addWidget(self.label)
self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
self.verticalLayout.addItem(self.verticalSpacer)
self.chafenButton = PushButton(self.centralwidget)
self.chafenButton.setObjectName(u"chafenButton")
sizePolicy1.setHeightForWidth(self.chafenButton.sizePolicy().hasHeightForWidth())
self.chafenButton.setSizePolicy(sizePolicy1)
self.chafenButton.setMinimumSize(QSize(0, 32))
self.chafenButton.setStyleSheet(u"")
self.verticalLayout.addWidget(self.chafenButton)
self.paihangbangButton = PushButton(self.centralwidget)
self.paihangbangButton.setObjectName(u"paihangbangButton")
sizePolicy1.setHeightForWidth(self.paihangbangButton.sizePolicy().hasHeightForWidth())
self.paihangbangButton.setSizePolicy(sizePolicy1)
self.paihangbangButton.setMinimumSize(QSize(0, 32))
self.paihangbangButton.setStyleSheet(u"")
self.verticalLayout.addWidget(self.paihangbangButton)
self.aboutButton = PushButton(self.centralwidget)
self.aboutButton.setObjectName(u"aboutButton")
sizePolicy1.setHeightForWidth(self.aboutButton.sizePolicy().hasHeightForWidth())
self.aboutButton.setSizePolicy(sizePolicy1)
self.aboutButton.setMinimumSize(QSize(0, 32))
self.aboutButton.setStyleSheet(u"")
self.verticalLayout.addWidget(self.aboutButton)
self.formLayout.setLayout(1, QFormLayout.LabelRole, self.verticalLayout)
self.stackedWidget = QStackedWidget(self.centralwidget)
self.stackedWidget.setObjectName(u"stackedWidget")
self.page = QWidget()
self.page.setObjectName(u"page")
self.verticalLayout_2 = QVBoxLayout(self.page)
self.verticalLayout_2.setObjectName(u"verticalLayout_2")
self.label_2 = QLabel(self.page)
self.label_2.setObjectName(u"label_2")
self.verticalLayout_2.addWidget(self.label_2)
self.verticalLayout_3 = QVBoxLayout()
self.verticalLayout_3.setObjectName(u"verticalLayout_3")
self.horizontalLayout = QHBoxLayout()
self.horizontalLayout.setObjectName(u"horizontalLayout")
self.label_3 = BodyLabel(self.page)
self.label_3.setObjectName(u"label_3")
sizePolicy2 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)
sizePolicy2.setHorizontalStretch(0)
sizePolicy2.setVerticalStretch(0)
sizePolicy2.setHeightForWidth(self.label_3.sizePolicy().hasHeightForWidth())
self.label_3.setSizePolicy(sizePolicy2)
self.horizontalLayout.addWidget(self.label_3)
self.chafen_usernameBox = LineEdit(self.page)
self.chafen_usernameBox.setObjectName(u"chafen_usernameBox")
sizePolicy3 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
sizePolicy3.setHorizontalStretch(0)
sizePolicy3.setVerticalStretch(0)
sizePolicy3.setHeightForWidth(self.chafen_usernameBox.sizePolicy().hasHeightForWidth())
self.chafen_usernameBox.setSizePolicy(sizePolicy3)
self.horizontalLayout.addWidget(self.chafen_usernameBox)
self.label_4 = BodyLabel(self.page)
self.label_4.setObjectName(u"label_4")
sizePolicy2.setHeightForWidth(self.label_4.sizePolicy().hasHeightForWidth())
self.label_4.setSizePolicy(sizePolicy2)
self.horizontalLayout.addWidget(self.label_4)
self.chafen_passwordBox = LineEdit(self.page)
self.chafen_passwordBox.setObjectName(u"chafen_passwordBox")
sizePolicy4 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
sizePolicy4.setHorizontalStretch(0)
sizePolicy4.setVerticalStretch(0)
sizePolicy4.setHeightForWidth(self.chafen_passwordBox.sizePolicy().hasHeightForWidth())
self.chafen_passwordBox.setSizePolicy(sizePolicy4)
self.horizontalLayout.addWidget(self.chafen_passwordBox)
self.login_ChafenButton = PushButton(self.page)
self.login_ChafenButton.setObjectName(u"login_ChafenButton")
sizePolicy5 = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
sizePolicy5.setHorizontalStretch(0)
sizePolicy5.setVerticalStretch(0)
sizePolicy5.setHeightForWidth(self.login_ChafenButton.sizePolicy().hasHeightForWidth())
self.login_ChafenButton.setSizePolicy(sizePolicy5)
self.horizontalLayout.addWidget(self.login_ChafenButton)
self.verticalLayout_3.addLayout(self.horizontalLayout)
self.horizontalLayout_3 = QHBoxLayout()
self.horizontalLayout_3.setObjectName(u"horizontalLayout_3")
self.listWidget = ListWidget(self.page)
self.listWidget.setObjectName(u"listWidget")
sizePolicy6 = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)
sizePolicy6.setHorizontalStretch(0)
sizePolicy6.setVerticalStretch(0)
sizePolicy6.setHeightForWidth(self.listWidget.sizePolicy().hasHeightForWidth())
self.listWidget.setSizePolicy(sizePolicy6)
self.listWidget.setMinimumSize(QSize(340, 0))
self.listWidget.setFrameShape(QFrame.StyledPanel)
self.horizontalLayout_3.addWidget(self.listWidget)
self.formLayout_2 = QFormLayout()
self.formLayout_2.setObjectName(u"formLayout_2")
self.label_5 = BodyLabel(self.page)
self.label_5.setObjectName(u"label_5")
sizePolicy1.setHeightForWidth(self.label_5.sizePolicy().hasHeightForWidth())
self.label_5.setSizePolicy(sizePolicy1)
self.label_5.setStyleSheet(u"font-size:16px")
self.formLayout_2.setWidget(1, QFormLayout.LabelRole, self.label_5)
self.scoreSumLabel = BodyLabel(self.page)
self.scoreSumLabel.setObjectName(u"scoreSumLabel")
sizePolicy1.setHeightForWidth(self.scoreSumLabel.sizePolicy().hasHeightForWidth())
self.scoreSumLabel.setSizePolicy(sizePolicy1)
self.scoreSumLabel.setStyleSheet(u"font-size:52px;")
self.formLayout_2.setWidget(1, QFormLayout.FieldRole, self.scoreSumLabel)
self.label_7 = BodyLabel(self.page)
self.label_7.setObjectName(u"label_7")
sizePolicy1.setHeightForWidth(self.label_7.sizePolicy().hasHeightForWidth())
self.label_7.setSizePolicy(sizePolicy1)
self.label_7.setStyleSheet(u"font-size:16px")
self.formLayout_2.setWidget(2, QFormLayout.LabelRole, self.label_7)
self.allScoresCombobox = ComboBox(self.page)
self.allScoresCombobox.setObjectName(u"allScoresCombobox")
sizePolicy1.setHeightForWidth(self.allScoresCombobox.sizePolicy().hasHeightForWidth())
self.allScoresCombobox.setSizePolicy(sizePolicy1)
self.formLayout_2.setWidget(2, QFormLayout.FieldRole, self.allScoresCombobox)
self.label_14 = BodyLabel(self.page)
self.label_14.setObjectName(u"label_14")
sizePolicy1.setHeightForWidth(self.label_14.sizePolicy().hasHeightForWidth())
self.label_14.setSizePolicy(sizePolicy1)
self.label_14.setStyleSheet(u"font-size:16px")
self.formLayout_2.setWidget(3, QFormLayout.LabelRole, self.label_14)
self.classRankLabel = BodyLabel(self.page)
self.classRankLabel.setObjectName(u"classRankLabel")
sizePolicy1.setHeightForWidth(self.classRankLabel.sizePolicy().hasHeightForWidth())
self.classRankLabel.setSizePolicy(sizePolicy1)
self.classRankLabel.setStyleSheet(u"font-size:16px")
self.formLayout_2.setWidget(3, QFormLayout.FieldRole, self.classRankLabel)
self.label_12 = BodyLabel(self.page)
self.label_12.setObjectName(u"label_12")
sizePolicy1.setHeightForWidth(self.label_12.sizePolicy().hasHeightForWidth())
self.label_12.setSizePolicy(sizePolicy1)
self.label_12.setStyleSheet(u"font-size:16px")
self.formLayout_2.setWidget(4, QFormLayout.LabelRole, self.label_12)
self.gradeRankLabel = BodyLabel(self.page)
self.gradeRankLabel.setObjectName(u"gradeRankLabel")
sizePolicy1.setHeightForWidth(self.gradeRankLabel.sizePolicy().hasHeightForWidth())
self.gradeRankLabel.setSizePolicy(sizePolicy1)
self.gradeRankLabel.setStyleSheet(u"font-size:16px")
self.formLayout_2.setWidget(4, QFormLayout.FieldRole, self.gradeRankLabel)
self.label_16 = BodyLabel(self.page)
self.label_16.setObjectName(u"label_16")
sizePolicy1.setHeightForWidth(self.label_16.sizePolicy().hasHeightForWidth())
self.label_16.setSizePolicy(sizePolicy1)
self.label_16.setStyleSheet(u"font-size:16px")
self.formLayout_2.setWidget(5, QFormLayout.LabelRole, self.label_16)
self.gradeStuNumLabel = BodyLabel(self.page)
self.gradeStuNumLabel.setObjectName(u"gradeStuNumLabel")
sizePolicy1.setHeightForWidth(self.gradeStuNumLabel.sizePolicy().hasHeightForWidth())
self.gradeStuNumLabel.setSizePolicy(sizePolicy1)
self.gradeStuNumLabel.setStyleSheet(u"font-size:16px")
self.formLayout_2.setWidget(5, QFormLayout.FieldRole, self.gradeStuNumLabel)
self.verticalSpacer_16 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
self.formLayout_2.setItem(6, QFormLayout.LabelRole, self.verticalSpacer_16)
self.verticalSpacer_17 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
self.formLayout_2.setItem(6, QFormLayout.FieldRole, self.verticalSpacer_17)
self.nameLabel = QLabel(self.page)
self.nameLabel.setObjectName(u"nameLabel")
self.nameLabel.setStyleSheet(u"font-size:18px")
self.formLayout_2.setWidget(0, QFormLayout.SpanningRole, self.nameLabel)
self.horizontalLayout_3.addLayout(self.formLayout_2)
self.verticalLayout_3.addLayout(self.horizontalLayout_3)
self.verticalLayout_2.addLayout(self.verticalLayout_3)
self.stackedWidget.addWidget(self.page)
self.page_2 = QWidget()
self.page_2.setObjectName(u"page_2")
self.gridLayout_2 = QGridLayout(self.page_2)
self.gridLayout_2.setObjectName(u"gridLayout_2")
self.verticalSpacer_2 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
self.gridLayout_2.addItem(self.verticalSpacer_2, 6, 0, 1, 1)
self.progressBar = QProgressBar(self.page_2)
self.progressBar.setObjectName(u"progressBar")
self.progressBar.setMaximum(100)
self.progressBar.setValue(99)
self.gridLayout_2.addWidget(self.progressBar, 7, 0, 1, 2)
self.phbTextBrowser = TextEdit(self.page_2)
self.phbTextBrowser.setObjectName(u"phbTextBrowser")
self.gridLayout_2.addWidget(self.phbTextBrowser, 4, 1, 3, 1)
self.label_8 = QLabel(self.page_2)
self.label_8.setObjectName(u"label_8")
self.gridLayout_2.addWidget(self.label_8, 2, 0, 1, 1)
self.groupBox = QGroupBox(self.page_2)
self.groupBox.setObjectName(u"groupBox")
sizePolicy7 = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred)
sizePolicy7.setHorizontalStretch(0)
sizePolicy7.setVerticalStretch(0)
sizePolicy7.setHeightForWidth(self.groupBox.sizePolicy().hasHeightForWidth())
self.groupBox.setSizePolicy(sizePolicy7)
self.groupBox.setMinimumSize(QSize(340, 0))
self.gridLayout = QGridLayout(self.groupBox)
self.gridLayout.setObjectName(u"gridLayout")
self.phb_RefreshButton = PushButton(self.groupBox)
self.phb_RefreshButton.setObjectName(u"phb_RefreshButton")
sizePolicy5.setHeightForWidth(self.phb_RefreshButton.sizePolicy().hasHeightForWidth())
self.phb_RefreshButton.setSizePolicy(sizePolicy5)
self.gridLayout.addWidget(self.phb_RefreshButton, 2, 0, 1, 1)
self.phb_OkButton = PushButton(self.groupBox)
self.phb_OkButton.setObjectName(u"phb_OkButton")
sizePolicy5.setHeightForWidth(self.phb_OkButton.sizePolicy().hasHeightForWidth())
self.phb_OkButton.setSizePolicy(sizePolicy5)
self.gridLayout.addWidget(self.phb_OkButton, 2, 1, 1, 1)
self.phb_ExamListCombobox = ComboBox(self.groupBox)
self.phb_ExamListCombobox.addItem("")
self.phb_ExamListCombobox.setObjectName(u"phb_ExamListCombobox")
sizePolicy3.setHeightForWidth(self.phb_ExamListCombobox.sizePolicy().hasHeightForWidth())
self.phb_ExamListCombobox.setSizePolicy(sizePolicy3)
self.gridLayout.addWidget(self.phb_ExamListCombobox, 1, 0, 1, 2)
self.gridLayout_2.addWidget(self.groupBox, 4, 0, 1, 1)
self.groupBox_2 = QGroupBox(self.page_2)
self.groupBox_2.setObjectName(u"groupBox_2")
sizePolicy7.setHeightForWidth(self.groupBox_2.sizePolicy().hasHeightForWidth())
self.groupBox_2.setSizePolicy(sizePolicy7)
self.groupBox_2.setMinimumSize(QSize(340, 0))
self.formLayout_4 = QFormLayout(self.groupBox_2)
self.formLayout_4.setObjectName(u"formLayout_4")
self.label_9 = BodyLabel(self.groupBox_2)
self.label_9.setObjectName(u"label_9")
self.formLayout_4.setWidget(0, QFormLayout.LabelRole, self.label_9)
self.phb_UserNameBox = LineEdit(self.groupBox_2)
self.phb_UserNameBox.setObjectName(u"phb_UserNameBox")
self.formLayout_4.setWidget(0, QFormLayout.FieldRole, self.phb_UserNameBox)
self.label_11 = BodyLabel(self.groupBox_2)
self.label_11.setObjectName(u"label_11")
self.formLayout_4.setWidget(1, QFormLayout.LabelRole, self.label_11)
self.phb_PasswordBox = LineEdit(self.groupBox_2)
self.phb_PasswordBox.setObjectName(u"phb_PasswordBox")
self.formLayout_4.setWidget(1, QFormLayout.FieldRole, self.phb_PasswordBox)
self.label_6 = BodyLabel(self.groupBox_2)
self.label_6.setObjectName(u"label_6")
self.formLayout_4.setWidget(3, QFormLayout.LabelRole, self.label_6)
self.phb_SubmitButton = PushButton(self.groupBox_2)
self.phb_SubmitButton.setObjectName(u"phb_SubmitButton")
self.formLayout_4.setWidget(2, QFormLayout.SpanningRole, self.phb_SubmitButton)
self.chafen_SubmitedNumLabel = BodyLabel(self.groupBox_2)
self.chafen_SubmitedNumLabel.setObjectName(u"chafen_SubmitedNumLabel")
self.formLayout_4.setWidget(3, QFormLayout.FieldRole, self.chafen_SubmitedNumLabel)
self.gridLayout_2.addWidget(self.groupBox_2, 5, 0, 1, 1)
self.textBrowser = TextEdit(self.page_2)
self.textBrowser.setObjectName(u"textBrowser")
sizePolicy8 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum)
sizePolicy8.setHorizontalStretch(0)
sizePolicy8.setVerticalStretch(0)
sizePolicy8.setHeightForWidth(self.textBrowser.sizePolicy().hasHeightForWidth())
self.textBrowser.setSizePolicy(sizePolicy8)
self.textBrowser.setMaximumSize(QSize(16777215, 100))
self.gridLayout_2.addWidget(self.textBrowser, 3, 0, 1, 2)
self.stackedWidget.addWidget(self.page_2)
self.page_3 = QWidget()
self.page_3.setObjectName(u"page_3")
self.horizontalLayout_4 = QHBoxLayout(self.page_3)
self.horizontalLayout_4.setObjectName(u"horizontalLayout_4")
self.textBrowser_3 = TextEdit(self.page_3)
self.textBrowser_3.setObjectName(u"textBrowser_3")
self.horizontalLayout_4.addWidget(self.textBrowser_3)
self.stackedWidget.addWidget(self.page_3)
self.formLayout.setWidget(1, QFormLayout.FieldRole, self.stackedWidget)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QMenuBar(MainWindow)
self.menubar.setObjectName(u"menubar")
self.menubar.setGeometry(QRect(0, 0, 673, 21))
MainWindow.setMenuBar(self.menubar)
self.statusbar = QStatusBar(MainWindow)
self.statusbar.setObjectName(u"statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
self.stackedWidget.setCurrentIndex(0)
QMetaObject.connectSlotsByName(MainWindow)
# setupUi
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"MainWindow", None))
self.label.setText(QCoreApplication.translate("MainWindow", u"<html><head/><body><p><span style=\" font-size:24pt;\">\u597d\u5206\u6570</span></p></body></html>", None))
self.chafenButton.setText(QCoreApplication.translate("MainWindow", u"\u67e5\u5206", None))
self.paihangbangButton.setText(QCoreApplication.translate("MainWindow", u"\u6392\u884c\u699c", None))
self.aboutButton.setText(QCoreApplication.translate("MainWindow", u"\u5173\u4e8e", None))
self.label_2.setText(QCoreApplication.translate("MainWindow", u"<html><head/><body><p><span style=\" font-size:16pt;\">\u67e5\u5206</span></p></body></html>", None))
self.label_3.setText(QCoreApplication.translate("MainWindow", u"\u8d26\u53f7:", None))
self.label_4.setText(QCoreApplication.translate("MainWindow", u"\u5bc6\u7801:", None))
self.login_ChafenButton.setText(QCoreApplication.translate("MainWindow", u"\u767b\u5f55", None))
self.label_5.setText(QCoreApplication.translate("MainWindow", u"\u603b\u5206:", None))
self.scoreSumLabel.setText("")
self.label_7.setText(QCoreApplication.translate("MainWindow", u"\u5404\u79d1\u6210\u7ee9:", None))
self.label_14.setText(QCoreApplication.translate("MainWindow", u"\u73ed\u7ea7\u6392\u540d:", None))
self.classRankLabel.setText("")
self.label_12.setText(QCoreApplication.translate("MainWindow", u"\u5e74\u7ea7\u6392\u540d:", None))
self.gradeRankLabel.setText("")
self.label_16.setText(QCoreApplication.translate("MainWindow", u"\u5e74\u7ea7\u8003\u8bd5\u4eba\u6570:", None))
self.gradeStuNumLabel.setText("")
self.nameLabel.setText("")
self.label_8.setText(QCoreApplication.translate("MainWindow", u"<html><head/><body><p><span style=\" font-size:16pt;\">\u6392\u884c\u699c</span></p></body></html>", None))
self.groupBox.setTitle(QCoreApplication.translate("MainWindow", u"\u9009\u62e9\u8003\u8bd5", None))
self.phb_RefreshButton.setText(QCoreApplication.translate("MainWindow", u"\u5237\u65b0", None))
self.phb_OkButton.setText(QCoreApplication.translate("MainWindow", u"\u786e\u5b9a", None))
self.phb_ExamListCombobox.setItemText(0, QCoreApplication.translate("MainWindow", u"(\u65e0)", None))
self.groupBox_2.setTitle(QCoreApplication.translate("MainWindow", u"\u8d21\u732e\u8d26\u53f7", None))
self.label_9.setText(QCoreApplication.translate("MainWindow", u"\u8d26\u53f7:", None))
self.label_11.setText(QCoreApplication.translate("MainWindow", u"\u5bc6\u7801:", None))
self.label_6.setText(QCoreApplication.translate("MainWindow", u"\u5df2\u8d21\u732e\u4eba\u6570:", None))
self.phb_SubmitButton.setText(QCoreApplication.translate("MainWindow", u"\u8d21\u732e", None))
self.chafen_SubmitedNumLabel.setText(QCoreApplication.translate("MainWindow", u"0", None))
self.textBrowser.setHtml(QCoreApplication.translate("MainWindow", u"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><meta charset=\"utf-8\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"hr { height: 1px; border-width: 0; }\n"
"li.unchecked::marker { content: \"\\2610\"; }\n"
"li.checked::marker { content: \"\\2612\"; }\n"
"</style></head><body style=\" font-family:'Microsoft YaHei UI'; font-size:9pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:16pt; font-weight:700;\">\u6e29\u99a8\u63d0\u793a</span><span style=\" font-size:16pt;\">:\u7531\u4e8e\u5b66\u6821</span><span style=\" font-size:16pt; font-weight:700; color:#ff0000;\">\u4e0d\u516c\u5f00</span><span style=\" font-size:16pt;\">\u6392\u540d\u4fe1\u606f\uff0c\u6240\u4ee5\u5efa\u8bae\u67e5\u770b\u6392\u884c\u699c\u7684\u4eba</span><span style=\" font-si"
"ze:16pt; font-weight:700; color:#ff0000;\">\u8d21\u732e\u81ea\u5df1\u7684\u597d\u5206\u6570\u8d26\u53f7</span><span style=\" font-size:16pt;\">\uff0c\u8d21\u732e\u8d8a\u591a\u6392\u884c\u699c\u8d8a\u5b8c\u5584\uff0c\u8c22\u8c22\u914d\u5408\uff01</span></p></body></html>", None))
self.textBrowser_3.setHtml(QCoreApplication.translate("MainWindow", u"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><meta charset=\"utf-8\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"hr { height: 1px; border-width: 0; }\n"
"li.unchecked::marker { content: \"\\2610\"; }\n"
"li.checked::marker { content: \"\\2612\"; }\n"
"</style></head><body style=\" font-family:'Microsoft YaHei UI'; font-size:9pt; font-weight:400; font-style:normal;\">\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:24pt;\">\u5173\u4e8e</span></p>\n"
"<p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">"
"<span style=\" font-size:14pt;\">\u597d\u5206\u6570 \uff0c\u966a\u4f34\u5b69\u5b50\u5b66\u4e60\u7684\u597d\u52a9\u624b</span></p>\n"
"<p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:14pt;\"><br /></p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Version 1.0 Build 2024.02</p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Copyright \u00a9 2024,nuz007 All right reserved</p>\n"
"<p align=\"center\" style=\" margin-top:22px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#ffffff;\"><span style=\" background-color:#ffffff;\">\u672c\u7a0b\u5e8f\u4e3a\u81ea\u7531\u8f6f\u4ef6\uff1a\u5728\u81ea\u7531\u8f6f\u4ef6\u57fa\u91d1\u4f1a\u53d1\u5e03\u7684 GN"
"U \u901a\u7528\u516c\u5171\u8bb8\u53ef\u8bc1\u7684\u7ea6\u675f\u4e0b\uff0c</span></p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" background-color:#ffffff;\">\u4f60\u53ef\u4ee5\u5bf9\u5176\u8fdb\u884c\u518d\u5206\u53d1\u53ca\u4fee\u6539\u3002\u8bb8\u53ef\u8bc1\u7248\u672c\u4e3a\u7b2c\u4e09\u7248\u6216\uff08\u4f60\u53ef\u9009\u7684\uff09\u540e\u7eed\u7248\u672c\u3002</span></p>\n"
"<p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" background-color:#ffffff;\">\u6211\u4eec\u5e0c\u671b\u53d1\u5e03\u7684\u8fd9\u6b3e\u7a0b\u5e8f\u6709\u7528\uff0c\u4f46\u5176\u4e0d\u5e26\u4efb\u4f55\u62c5\u4fdd\uff1b\u751a\u81f3\u4e0d\u9ed8\u8ba4\u4fdd"
"\u8bc1\u5b83\u6709\u7ecf\u6d4e</span></p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" background-color:#ffffff;\">\u4ef7\u503c\u548c\u9002\u5408\u7279\u5b9a\u7528\u9014\u3002\u8be6\u60c5\u53c2\u89c1 GNU \u901a\u7528\u516c\u5171\u8bb8\u53ef\u8bc1\u3002</span></p>\n"
"<p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" background-color:#ffffff;\">\u4f60\u7406\u5f53\u5df2\u6536\u5230\u4e00\u4efd GNU \u901a\u7528\u516c\u5171\u8bb8\u53ef\u8bc1\u7684\u526f\u672c\u3002\u5982\u679c\u4f60\u6ca1\u6709\u6536\u5230\u5b83\uff0c\u8bf7\u67e5\u9605 <http://www.gnu.org/licenses/>\u3002</span></p></body></html>", None))
# retranslateUi
chafen_examList=[]
phb_ExamList=[]
accountsLibPath=f"{str(pathlib.Path.home())}/.haofenshu/data/accounts"
phb_examId=""
headers={"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36 Edg/112.0.1722.39"}
def delenter(xn):
y=[]
for i in xn:
z=i.replace("\n","")
if z:y.append(z)
return y
def getscore(x,y,id):#x为邮箱,y为id
try:
session=requests.session()
session.post(
url="https://hfs-be.yunxiao.com/v2/users/sessions",
headers=headers,
data={"loginName":x,"password":str(base64.b64encode(y.encode("utf-8")))[2:-1],"roleType":1,"loginType":1,"rememberMe":2}#password为密码的base64
)
考试信息x=session.get(
url="https://hfs-be.yunxiao.com/v3/exam/list?start=-1",
headers=headers
).json()['data']['list']
姓名=session.get(
url="https://hfs-be.yunxiao.com/v2/user-center/user-snapshot",
headers=headers
).json()['data']['linkedStudent']['studentName']
for i in 考试信息x:
if i['examId']==id:考试信息=i
tmp = session.get(f"https://hfs-be.yunxiao.com/v3/exam/{id}/overview").json()['data']
tmp2=[]
for i in tmp['papers']:tmp2.append(f"{i['subject']}:{i['score']}")
tmp1=[姓名,tmp["score"],tmp2,tmp["classRank"],tmp["gradeRank"],tmp["gradeStuNum"]]
return tmp1
except:return False
def mklist(x):
tmp=""
for i in x:
tmp=tmp+f"<td>{i}</td>"
return tmp
class MainWindow(QMainWindow):
def __init__(self, parent=None):
global phb_examId,chafen_examList,phb_ExamList,accountsLibPath,headers
super().__init__(parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
if not(os.path.exists(f"{str(pathlib.Path.home())}/.haofenshu/data")):os.makedirs(f"{str(pathlib.Path.home())}/.haofenshu/data")
# 按钮
self.ui.chafenButton.clicked.connect(lambda: self.switchStackedWidget(0))
self.ui.paihangbangButton.clicked.connect(lambda: self.switchStackedWidget(1))
self.ui.aboutButton.clicked.connect(lambda: self.switchStackedWidget(2))
self.ui.login_ChafenButton.clicked.connect(self.login_ChaFen)
self.ui.listWidget.currentItemChanged.connect(self.get_Chafen)
self.ui.phb_SubmitButton.clicked.connect(self.phb_Submit)
self.ui.phb_RefreshButton.clicked.connect(self.phb_Refresh)
self.ui.phb_OkButton.clicked.connect(self.phb_Ok)
self.chafenUsername=""
self.chafenPassword=""
if os.path.exists(accountsLibPath):
with open(accountsLibPath) as g:submited=len(delenter(g.readlines()))
if submited<=0:self.ui.phb_RefreshButton.setDisabled(True)
else:
submited=0
self.ui.phb_RefreshButton.setDisabled(True)
self.ui.chafen_SubmitedNumLabel.setText(str(submited))
def switchStackedWidget(self,x):self.ui.stackedWidget.setCurrentIndex(x)# 切换页面
def getAllExam(self,username,password):
global phb_examId,chafen_examList,phb_ExamList,accountsLibPath,headers
session=requests.session()
session.post(
url="https://hfs-be.yunxiao.com/v2/users/sessions",
headers=headers,
data={"loginName":username,"password":str(base64.b64encode(password.encode("utf-8")))[2:-1],"roleType":1,"loginType":1,"rememberMe":2}#password为密码的base64
)
tmp=session.get(
url="https://hfs-be.yunxiao.com/v3/exam/list?start=-1",
headers=headers
).json()['data']['list']
姓名=session.get(
url="https://hfs-be.yunxiao.com/v2/user-center/user-snapshot",
headers=headers
).json()['data']['linkedStudent']['studentName']
n=[]
for i in tmp:
n.append((i['name'],i['examId'],time.strftime("%Y年%m月%d日",time.localtime(int(i['time'])/1000)),int(i['time'])))
return (n,姓名)
def login_ChaFen(self):
global phb_examId,chafen_examList,phb_ExamList,accountsLibPath,headers
self.ui.listWidget.clear()
self.ui.scoreSumLabel.setText("")
self.ui.classRankLabel.setText("")
self.ui.gradeRankLabel.setText("")
self.ui.gradeStuNumLabel.setText("")
self.ui.nameLabel.setText("")
self.ui.allScoresCombobox.clear()
try:chafen_examList=self.getAllExam(self.ui.chafen_usernameBox.text(),self.ui.chafen_passwordBox.text())
except:
QMessageBox.critical(self,"无效的用户密码或无互联网链接","无效的用户密码或无互联网链接",QMessageBox.Ok)
return
for i in chafen_examList[0]:
self.ui.listWidget.addItem(f"{i[0]},{i[2]}")
self.ui.nameLabel.setText(chafen_examList[1])
def get_Chafen(self):
global phb_examId,chafen_examList,phb_ExamList,accountsLibPath,headers
examId=chafen_examList[0][self.ui.listWidget.currentRow()][1]
examInfo=getscore(self.ui.chafen_usernameBox.text(),self.ui.chafen_passwordBox.text(),examId)
self.ui.scoreSumLabel.setText(str(examInfo[1]))
self.ui.allScoresCombobox.clear()
for i in examInfo[2]:
self.ui.allScoresCombobox.addItem(f"{i}")
self.ui.classRankLabel.setText(str(examInfo[3]))
self.ui.gradeRankLabel.setText(str(examInfo[4]))
self.ui.gradeStuNumLabel.setText(str(examInfo[5]))
########################################################################################
############# 排行榜 ####################################################################
########################################################################################
def phb_Submit(self):
global phb_examId,chafen_examList,phb_ExamList,accountsLibPath,headers
username=self.ui.phb_UserNameBox.text()
password=self.ui.phb_PasswordBox.text()
session=requests.session()
x=session.post(
url="https://hfs-be.yunxiao.com/v2/users/sessions",
headers=headers,
data={"loginName":username,"password":str(base64.b64encode(password.encode("utf-8")))[2:-1],"roleType":1,"loginType":1,"rememberMe":2}#password为密码的base64
).json()["msg"]
if x=="登录成功":
if os.path.exists(accountsLibPath):
with open(accountsLibPath)as x:
if f"{username}:::{password}\n" in x:
QMessageBox.critical(self,"该用户已贡献","该用户已贡献",QMessageBox.Ok)
return
with open(accountsLibPath,"a+") as x:
x.write(f"{username}:::{password}\n")
self.ui.chafen_SubmitedNumLabel.setText(str(int(self.ui.chafen_SubmitedNumLabel.text())+1))
self.ui.phb_RefreshButton.setDisabled(False)
QMessageBox.information(self,"贡献成功","贡献成功",QMessageBox.Ok)
else:QMessageBox.critical(self,"无效的用户密码或无互联网链接","无效的用户密码或无互联网链接",QMessageBox.Ok)
def phb_Refresh(self):
global phb_examId,chafen_examList,phb_ExamList,accountsLibPath,headers
with open(accountsLibPath,"r") as g:
accountslist=[]
for i in delenter(g.readlines()):
accountslist.append(i.split(":::"))
random.shuffle(accountslist)
account_5=accountslist[:5] if len(accountslist) > 8 else accountslist
exam_5=[]
tmp_exam=[]
for i in account_5:
tmp_exam=self.getAllExam(i[0],i[1])
QApplication.processEvents()
for j in tmp_exam[0]:exam_5.append(j)
phb_ExamList.clear()
print(exam_5)
phb_ExamList=list(set(exam_5))
phb_ExamList.sort(key=lambda x:x[3])
phb_ExamList.reverse()
self.ui.phb_ExamListCombobox.clear()
for i in phb_ExamList:self.ui.phb_ExamListCombobox.addItem(f"{i[0]},{i[2]}")
def phb_Ok(self):
global phb_examId,chafen_examList,phb_ExamList,accountsLibPath,headers
self.ui.phbTextBrowser.setHtml("")
phb_examId=phb_ExamList[self.ui.phb_ExamListCombobox.currentIndex()][1]
self.thread=phb_Ok_Thread()
self.thread.sinOut1.connect(self.phb_Ok1)
self.thread.sinOut2.connect(self.phb_Ok2)
self.thread.sinOut3.connect(self.phb_Ok3)
self.thread.start()
def phb_Ok1(self,x):
self.ui.phbTextBrowser.setHtml(x)
def phb_Ok2(self,x):
self.ui.progressBar.setMaximum(x)
self.ui.progressBar.setValue(0)
def phb_Ok3(self,x):
self.ui.progressBar.setValue(x)
class phb_Ok_Thread(QThread):
def __init__(self):super().__init__()
sinOut1=Signal(str)
sinOut2=Signal(int)
sinOut3=Signal(int)
def run(self):
with open(accountsLibPath,"r") as g:
accountslist=[]
for i in delenter(g.readlines()):
accountslist.append(i.split(":::"))
scorelist=[]
self.sinOut2.emit(len(accountslist))
value=0
for i in accountslist:
tmp=getscore(i[0],i[1],phb_examId)
value+=1
self.sinOut3.emit(value)
if str(type(tmp)) !="<class 'list'>":continue
tmp2=(tmp[4],tmp[0],tmp[1],tmp[2])
scorelist.append(tmp2)
scorelist.sort(key=lambda x:x[0])
score2list=[]
for i in scorelist:
score2list.append(f"<tr><td>{i[0]}</td><td>{i[1]}</td><td>{i[2]}</td>{mklist(i[3])}</tr>")
scoretxt='<style>td{font-size:14px;padding:6px}</style><table border="1" cellspacing="0"><thead><tr><td>排名</td><td>姓名</td><td>总分</td><td>单科</td></tr></thead><tbody>'+"".join(score2list)+"</tbody></table>"
self.sinOut1.emit(scoretxt)
if __name__ == "__main__":
app = QApplication(sys.argv)
widget = MainWindow()
widget.show()
sys.exit(app.exec())