This repository has been archived by the owner on Jul 10, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathTest_MetroProgressBar.py
76 lines (65 loc) · 2.63 KB
/
Test_MetroProgressBar.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2015年10月6日
@author: Irony."[讽刺]
@email: [email protected]
@description: Test_MetroProgressCircleBar
'''
from __future__ import unicode_literals
# 解决2.x到3.x的字符串问题
from os.path import dirname, abspath
import sys
# 父级目录
sys.path.insert(0, dirname(dirname(abspath(sys.argv[0]))))
sys.path.insert(0, dirname(dirname(abspath(__file__))))
from PyQt5.QtCore import QSize, QEasingCurve
from PyQt5.QtWidgets import QApplication, QMainWindow, QScrollArea, QWidget, \
QGridLayout, QLabel, QVBoxLayout
from uilib.widgets.MetroProgress import MetroProgressBar
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: [email protected]"
__Copyright__ = "Copyright (c) 2015 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
class TestMetroProgressBar(QMainWindow):
def __init__(self, parent = None):
super(TestMetroProgressBar, self).__init__(parent)
self.setObjectName("Test_MetroProgressCircleBar")
self.resize(QSize(800, 600))
self.mpbs = [] # 所有的进度条
self.initView()
self.setStyleSheet("QScrollArea,QWidget{background-color: rgb(0, 170, 255);}")
def closeEvent(self, event):
for mpb in self.mpbs: # @UnusedVariable
mpb.stop() # 调用停止动画
super(TestMetroProgressBar, self).closeEvent(event)
def initView(self):
'''创建界面'''
scrollArea = QScrollArea(self) # 滚动区域
scrollArea.setWidgetResizable(True)
self.setCentralWidget(scrollArea)
scrollWidget = QWidget()
scrollArea.setWidget(scrollWidget)
gridLayout = QGridLayout(scrollWidget) # 网格布局
# 从QEasingCurve获取所有的type
curve_types = [(n, c) for n, c in QEasingCurve.__dict__.items()
if isinstance(c, QEasingCurve.Type)]
curve_types.sort(key = lambda ct: ct[1])
i = 0
for curve_name, curve_type in curve_types:
index = curve_type % 4
widget = QWidget()
widget.setObjectName("_BorderWidget")
widget.setStyleSheet("QWidget#_BorderWidget{border: 1px solid black;}")
name = QLabel("QEasingCurve." + curve_name, widget)
mpb = MetroProgressBar(widget, curve_type)
layout = QVBoxLayout(widget)
layout.addWidget(name)
layout.addWidget(mpb)
gridLayout.addWidget(widget, i, index, 1, 1)
if index == 3:
i += 1
if __name__ == "__main__":
app = QApplication(sys.argv)
window = TestMetroProgressBar()
window.show()
sys.exit(app.exec_())