Commit 6b6c5441 authored by Zheng Yile's avatar Zheng Yile
Browse files

优化进度条的显示

parent ec1fccdf
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
from PyQt5.QtWidgets import QPushButton, QLabel, QProgressBar
Font = {
'main': QFont(),
......@@ -45,7 +45,6 @@ elif sys.platform == 'darwin':
Font['main'].setPointSize(13)
Font['status'].setFamily(".AppleSystemUIFont")
Font['status'].setPointSize(13)
NewPushButton = QPushButton
else:
Font['main'].setFamily("Microsoft YaHei")
Font['main'].setPointSize(13)
......@@ -283,10 +282,36 @@ class _NewPushButton(MyObject):
self.raise_()
super(_NewPushButton, self).LoadAnime()
class _NewProgressBar(QProgressBar):
def setValue(self, value):
QPropertyAnimation(self, b"value")
for x in self.Anime: self.Anime[x].stop()
self.Anime['progress'].setStartValue(self.value())
self.Anime['progress'].setEndValue(value)
if self.value() != value:
self.Anime['progress'].start()
def hide(self):
super(_NewProgressBar, self).hide()
for x in self.Anime: self.Anime[x].stop()
super(_NewProgressBar, self).setValue(0)
def __init__(self, *args, **kargs):
super(_NewProgressBar, self).__init__(*args, **kargs)
self.Anime = {
"progress": QPropertyAnimation(self, b"value")
}
self.Anime['progress'].setDuration(1500)
self.Anime['progress'].setEasingCurve(QEasingCurve.OutQuart)
if sys.platform == 'win32':
NewPushButton = _NewPushButton
NewProgressBar = _NewProgressBar
elif sys.platform == 'darwin':
NewPushButton = QPushButton
NewProgressBar = QProgressBar
else:
NewPushButton = _NewPushButton
NewProgressBar = _NewProgressBar
......@@ -78,7 +78,7 @@ def ClientLogin(username, password, InfoRecv = lambda: None, ErrorRecv = lambda:
threadClientLogin = _ClientLogin(username = username, password = password)
threadClientLogin.infoSignal.connect(InfoRecv)
threadClientLogin.errorSignal.connect(ErrorRecv)
uiLogin.progressBarLogin.setValue(75)
uiLogin.progressBarLogin.setValue(90)
threadClientLogin.start()
# 开始进行登录操作
......@@ -128,7 +128,6 @@ def Login(callback = None):
except Exception as e:
QMessageBox.critical(None, "未知错误", str(e), QMessageBox.Ok)
finally:
uiLogin.progressBarLogin.setValue(100)
uiLogin.progressBarLogin.hide()
uiLogin.pushButtonLoginGoRegister.show()
windowLogin.hide()
......
......@@ -64,7 +64,7 @@ class Ui_windowLogin(object):
self.pushButtonLogin = NewPushButton(self.frameLogin)
self.pushButtonLogin.setGeometry(QtCore.QRect(105, 190, 120, 32))
self.pushButtonLogin.setObjectName("pushButtonLogin")
self.progressBarLogin = QtWidgets.QProgressBar(self.frameLogin)
self.progressBarLogin = NewProgressBar(self.frameLogin)
self.progressBarLogin.setGeometry(QtCore.QRect(78, 240, 384, 12))
self.progressBarLogin.setProperty("value", 0)
self.progressBarLogin.setTextVisible(False)
......@@ -245,4 +245,4 @@ class Ui_windowLogin(object):
self.action.setText(_translate("windowLogin", "关于"))
self.actionsd.setText(_translate("windowLogin", "登陆"))
self.action_2.setText(_translate("windowLogin", "关于"))
from codiaclientgui.utils import NewPushButton
from codiaclientgui.utils import NewProgressBar, NewPushButton
......@@ -183,7 +183,7 @@
<string>登陆</string>
</property>
</widget>
<widget class="QProgressBar" name="progressBarLogin">
<widget class="NewProgressBar" name="progressBarLogin">
<property name="geometry">
<rect>
<x>78</x>
......@@ -640,6 +640,11 @@
<extends>QPushButton</extends>
<header location="global">codiaclientgui/utils</header>
</customwidget>
<customwidget>
<class>NewProgressBar</class>
<extends>QProgressBar</extends>
<header location="global">codiaclientgui/utils</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
......
......@@ -47,9 +47,9 @@ class Ui_windowMain(object):
self.labelPackPage.setGeometry(QtCore.QRect(50, 630, 120, 32))
self.labelPackPage.setAlignment(QtCore.Qt.AlignCenter)
self.labelPackPage.setObjectName("labelPackPage")
self.progressBarPack = QtWidgets.QProgressBar(self.framePack)
self.progressBarPack = NewProgressBar(self.framePack)
self.progressBarPack.setGeometry(QtCore.QRect(180, 9, 720, 12))
self.progressBarPack.setProperty("value", 20)
self.progressBarPack.setProperty("value", 0)
self.progressBarPack.setTextVisible(False)
self.progressBarPack.setObjectName("progressBarPack")
self.frameExercise = QtWidgets.QFrame(self.centralwidget)
......@@ -63,7 +63,7 @@ class Ui_windowMain(object):
self.pushButtonExerciseOK.setGeometry(QtCore.QRect(480, 630, 120, 32))
self.pushButtonExerciseOK.setObjectName("pushButtonExerciseOK")
self.pushButtonExerciseReturn = NewPushButton(self.frameExercise)
self.pushButtonExerciseReturn.setGeometry(QtCore.QRect(730, 630, 120, 32))
self.pushButtonExerciseReturn.setGeometry(QtCore.QRect(890, 630, 120, 32))
self.pushButtonExerciseReturn.setObjectName("pushButtonExerciseReturn")
self.listWidgetExercise = QtWidgets.QListWidget(self.frameExercise)
self.listWidgetExercise.setGeometry(QtCore.QRect(28, 170, 1024, 391))
......@@ -76,9 +76,9 @@ class Ui_windowMain(object):
self.labelDeadline.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter)
self.labelDeadline.setIndent(10)
self.labelDeadline.setObjectName("labelDeadline")
self.progressBarExercise = QtWidgets.QProgressBar(self.frameExercise)
self.progressBarExercise = NewProgressBar(self.frameExercise)
self.progressBarExercise.setGeometry(QtCore.QRect(180, 9, 720, 12))
self.progressBarExercise.setProperty("value", 20)
self.progressBarExercise.setProperty("value", 0)
self.progressBarExercise.setTextVisible(False)
self.progressBarExercise.setObjectName("progressBarExercise")
self.textEditExerciseDiscription = QtWidgets.QTextEdit(self.frameExercise)
......@@ -108,7 +108,7 @@ class Ui_windowMain(object):
self.pushButtonHistory.setGeometry(QtCore.QRect(50, 630, 120, 32))
self.pushButtonHistory.setObjectName("pushButtonHistory")
self.pushButtonQuestionReturn = NewPushButton(self.frameQuestion)
self.pushButtonQuestionReturn.setGeometry(QtCore.QRect(730, 630, 120, 32))
self.pushButtonQuestionReturn.setGeometry(QtCore.QRect(890, 630, 120, 32))
self.pushButtonQuestionReturn.setObjectName("pushButtonQuestionReturn")
self.labelQuestionStatus = QtWidgets.QLabel(self.frameQuestion)
self.labelQuestionStatus.setGeometry(QtCore.QRect(30, 0, 150, 30))
......@@ -140,7 +140,7 @@ class Ui_windowMain(object):
self.pushButtonSubmitCode.setGeometry(QtCore.QRect(480, 630, 120, 32))
self.pushButtonSubmitCode.setObjectName("pushButtonSubmitCode")
self.pushButtonSubmitBack = NewPushButton(self.frameSubmit)
self.pushButtonSubmitBack.setGeometry(QtCore.QRect(730, 630, 120, 32))
self.pushButtonSubmitBack.setGeometry(QtCore.QRect(890, 630, 120, 32))
self.pushButtonSubmitBack.setObjectName("pushButtonSubmitBack")
self.frameHistory = QtWidgets.QFrame(self.centralwidget)
self.frameHistory.setGeometry(QtCore.QRect(0, 0, 1080, 768))
......@@ -185,4 +185,4 @@ class Ui_windowMain(object):
self.labelSubmitStatus.setText(_translate("windowMain", "通过/尝试"))
self.pushButtonSubmitCode.setText(_translate("windowMain", "提交"))
self.pushButtonSubmitBack.setText(_translate("windowMain", "返回"))
from codiaclientgui.utils import NewPushButton
from codiaclientgui.utils import NewProgressBar, NewPushButton
......@@ -131,7 +131,7 @@
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QProgressBar" name="progressBarPack">
<widget class="NewProgressBar" name="progressBarPack">
<property name="geometry">
<rect>
<x>180</x>
......@@ -141,7 +141,7 @@
</rect>
</property>
<property name="value">
<number>20</number>
<number>0</number>
</property>
<property name="textVisible">
<bool>false</bool>
......@@ -191,7 +191,7 @@
<widget class="NewPushButton" name="pushButtonExerciseReturn">
<property name="geometry">
<rect>
<x>730</x>
<x>890</x>
<y>630</y>
<width>120</width>
<height>32</height>
......@@ -243,7 +243,7 @@
<number>10</number>
</property>
</widget>
<widget class="QProgressBar" name="progressBarExercise">
<widget class="NewProgressBar" name="progressBarExercise">
<property name="geometry">
<rect>
<x>180</x>
......@@ -253,7 +253,7 @@
</rect>
</property>
<property name="value">
<number>20</number>
<number>0</number>
</property>
<property name="textVisible">
<bool>false</bool>
......@@ -337,7 +337,7 @@
<widget class="NewPushButton" name="pushButtonQuestionReturn">
<property name="geometry">
<rect>
<x>730</x>
<x>890</x>
<y>630</y>
<width>120</width>
<height>32</height>
......@@ -461,7 +461,7 @@
<widget class="NewPushButton" name="pushButtonSubmitBack">
<property name="geometry">
<rect>
<x>730</x>
<x>890</x>
<y>630</y>
<width>120</width>
<height>32</height>
......@@ -512,6 +512,11 @@
<extends>QPushButton</extends>
<header location="global">codiaclientgui/utils</header>
</customwidget>
<customwidget>
<class>NewProgressBar</class>
<extends>QProgressBar</extends>
<header location="global">codiaclientgui/utils</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
......
Markdown is supported
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