Commit 9bedc96c authored by Zheng Yile's avatar Zheng Yile
Browse files

增加提交时的多线程与进度条

parent 06080577
import sys
from PyQt5.QtCore import Qt, QPropertyAnimation, pyqtSignal, pyqtProperty, QEasingCurve
from PyQt5.QtGui import QFont, QPalette, QBrush, QColor, QPainterPath, QPainter, QPen
from PyQt5.QtWidgets import QPushButton, QLabel, QProgressBar
from PyQt5.QtWidgets import QPushButton, QLabel, QProgressBar, QListWidget
Font = {
'main': QFont(),
......@@ -323,16 +323,21 @@ class _NewProgressBar(QProgressBar):
self.Anime['progress'].setDuration(1500)
self.Anime['progress'].setEasingCurve(QEasingCurve.OutQuart)
class _NewListWidget(QListWidget):
def addItem(self, item):
item.setBackground(Color[['white', 'lightgray'][self.count() % 2]])
super(_NewListWidget, self).addItem(item)
def __init__(self, *args, **kargs):
super(_NewListWidget, self).__init__(*args, **kargs)
if sys.platform == 'win32':
NewPushButton = _NewPushButton
NewProgressBar = _NewProgressBar
elif sys.platform == 'darwin':
NewPushButton = QPushButton
NewProgressBar = QProgressBar
else:
NewPushButton = _NewPushButton
NewProgressBar = _NewProgressBar
NewProgressBar = _NewProgressBar
NewListWidget = _NewListWidget
def ErrorDisplay(error, _ErrorTranslate, knownErrorInfo: str = "错误", unknownErrorInfo: str = "未知错误"):
errorTranslate = _ErrorTranslate(error)
......
......@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'mainWindow.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
# Created by: PyQt5 UI code generator 5.15.2
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
......@@ -30,7 +30,7 @@ class Ui_windowMain(object):
self.framePack.setFrameShape(QtWidgets.QFrame.NoFrame)
self.framePack.setFrameShadow(QtWidgets.QFrame.Raised)
self.framePack.setObjectName("framePack")
self.listWidgetPack = QtWidgets.QListWidget(self.framePack)
self.listWidgetPack = NewListWidget(self.framePack)
self.listWidgetPack.setGeometry(QtCore.QRect(28, 30, 1024, 531))
self.listWidgetPack.setMaximumSize(QtCore.QSize(1280, 768))
self.listWidgetPack.setObjectName("listWidgetPack")
......@@ -65,7 +65,7 @@ class Ui_windowMain(object):
self.pushButtonExerciseReturn = NewPushButton(self.frameExercise)
self.pushButtonExerciseReturn.setGeometry(QtCore.QRect(890, 630, 120, 32))
self.pushButtonExerciseReturn.setObjectName("pushButtonExerciseReturn")
self.listWidgetExercise = QtWidgets.QListWidget(self.frameExercise)
self.listWidgetExercise = NewListWidget(self.frameExercise)
self.listWidgetExercise.setGeometry(QtCore.QRect(28, 170, 1024, 391))
self.listWidgetExercise.setObjectName("listWidgetExercise")
self.pushButtonExerciseBegin = NewPushButton(self.frameExercise)
......@@ -136,13 +136,18 @@ class Ui_windowMain(object):
self.textEditSubmit.setGeometry(QtCore.QRect(28, 30, 1024, 531))
self.textEditSubmit.setTabStopWidth(40)
self.textEditSubmit.setObjectName("textEditSubmit")
self.progressBarSubmit = NewProgressBar(self.frameSubmit)
self.progressBarSubmit.setGeometry(QtCore.QRect(180, 9, 720, 12))
self.progressBarSubmit.setProperty("value", 0)
self.progressBarSubmit.setTextVisible(False)
self.progressBarSubmit.setObjectName("progressBarSubmit")
self.pushButtonSubmitCode = NewPushButton(self.frameSubmit)
self.pushButtonSubmitCode.setGeometry(QtCore.QRect(480, 630, 120, 32))
self.pushButtonSubmitCode.setObjectName("pushButtonSubmitCode")
self.pushButtonSubmitBack = NewPushButton(self.frameSubmit)
self.pushButtonSubmitBack.setGeometry(QtCore.QRect(890, 630, 120, 32))
self.pushButtonSubmitBack.setObjectName("pushButtonSubmitBack")
self.pushButtonReadFromFile = QtWidgets.QPushButton(self.frameSubmit)
self.pushButtonReadFromFile = NewPushButton(self.frameSubmit)
self.pushButtonReadFromFile.setGeometry(QtCore.QRect(690, 630, 120, 32))
self.pushButtonReadFromFile.setObjectName("pushButtonReadFromFile")
self.frameHistory = QtWidgets.QFrame(self.centralwidget)
......@@ -150,7 +155,7 @@ class Ui_windowMain(object):
self.frameHistory.setFrameShape(QtWidgets.QFrame.NoFrame)
self.frameHistory.setFrameShadow(QtWidgets.QFrame.Raised)
self.frameHistory.setObjectName("frameHistory")
self.listWidgetPackHistory = QtWidgets.QListWidget(self.frameHistory)
self.listWidgetPackHistory = NewListWidget(self.frameHistory)
self.listWidgetPackHistory.setGeometry(QtCore.QRect(28, 30, 1024, 531))
self.listWidgetPackHistory.setMaximumSize(QtCore.QSize(1280, 768))
self.listWidgetPackHistory.setObjectName("listWidgetPackHistory")
......@@ -167,7 +172,7 @@ class Ui_windowMain(object):
self.frameHistory.raise_()
windowMain.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(windowMain)
self.menubar.setGeometry(QtCore.QRect(0, 0, 1080, 24))
self.menubar.setGeometry(QtCore.QRect(0, 0, 1080, 26))
self.menubar.setObjectName("menubar")
windowMain.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(windowMain)
......@@ -201,4 +206,4 @@ class Ui_windowMain(object):
self.pushButtonReadFromFile.setText(_translate("windowMain", "从文件中读取"))
self.pushButtonSubmitCodeDetails.setText(_translate("windowMain", "详细信息"))
self.pushButtonHistoryBack.setText(_translate("windowMain", "返回"))
from codiaclientgui.utils import NewProgressBar, NewPushButton
from codiaclientgui.utils import NewListWidget, NewProgressBar, NewPushButton
......@@ -60,7 +60,7 @@
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<widget class="QListWidget" name="listWidgetPack">
<widget class="NewListWidget" name="listWidgetPack">
<property name="geometry">
<rect>
<x>28</x>
......@@ -201,7 +201,7 @@
<string>返回</string>
</property>
</widget>
<widget class="QListWidget" name="listWidgetExercise">
<widget class="NewListWidget" name="listWidgetExercise">
<property name="geometry">
<rect>
<x>28</x>
......@@ -445,6 +445,22 @@
<number>40</number>
</property>
</widget>
<widget class="NewProgressBar" name="progressBarSubmit">
<property name="geometry">
<rect>
<x>180</x>
<y>9</y>
<width>720</width>
<height>12</height>
</rect>
</property>
<property name="value">
<number>0</number>
</property>
<property name="textVisible">
<bool>false</bool>
</property>
</widget>
<widget class="NewPushButton" name="pushButtonSubmitCode">
<property name="geometry">
<rect>
......@@ -471,7 +487,7 @@
<string>返回</string>
</property>
</widget>
<widget class="QPushButton" name="pushButtonReadFromFile">
<widget class="NewPushButton" name="pushButtonReadFromFile">
<property name="geometry">
<rect>
<x>690</x>
......@@ -500,7 +516,7 @@
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<widget class="QListWidget" name="listWidgetPackHistory">
<widget class="NewListWidget" name="listWidgetPackHistory">
<property name="geometry">
<rect>
<x>28</x>
......@@ -555,7 +571,7 @@
<x>0</x>
<y>0</y>
<width>1080</width>
<height>24</height>
<height>26</height>
</rect>
</property>
</widget>
......@@ -572,6 +588,11 @@
<extends>QProgressBar</extends>
<header location="global">codiaclientgui/utils</header>
</customwidget>
<customwidget>
<class>NewListWidget</class>
<extends>QListWidget</extends>
<header location="global">codiaclientgui/utils</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment