MCPcopy Index your code
hub / github.com/PyQt5/PyQt / MetroCircleProgress

Class MetroCircleProgress

QProgressBar/MetroCircleProgress.py:52–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50
51
52class MetroCircleProgress(QWidget):
53 Radius = 5 # 半径
54 Color = QColor(24, 189, 155) # 圆圈颜色
55 BackgroundColor = QColor(Qt.transparent) # 背景颜色
56
57 def __init__(self, *args, radius=5, color=QColor(24, 189, 155),
58 backgroundColor=QColor(Qt.transparent), **kwargs):
59 super(MetroCircleProgress, self).__init__(*args, **kwargs)
60 self.Radius = radius
61 self.Color = color
62 self.BackgroundColor = backgroundColor
63 self._items = []
64 self._initAnimations()
65
66 @pyqtProperty(int)
67 def radius(self) -> int:
68 return self.Radius
69
70 @radius.setter
71 def radius(self, radius: int):
72 if self.Radius != radius:
73 self.Radius = radius
74 self.update()
75
76 @pyqtProperty(QColor)
77 def color(self) -> QColor:
78 return self.Color
79
80 @color.setter
81 def color(self, color: QColor):
82 if self.Color != color:
83 self.Color = color
84 self.update()
85
86 @pyqtProperty(QColor)
87 def backgroundColor(self) -> QColor:
88 return self.BackgroundColor
89
90 @backgroundColor.setter
91 def backgroundColor(self, backgroundColor: QColor):
92 if self.BackgroundColor != backgroundColor:
93 self.BackgroundColor = backgroundColor
94 self.update()
95
96 def paintEvent(self, event):
97 super(MetroCircleProgress, self).paintEvent(event)
98 painter = QPainter(self)
99 painter.setRenderHint(QPainter.Antialiasing)
100 painter.fillRect(self.rect(), self.BackgroundColor)
101 painter.setPen(Qt.NoPen)
102
103 for item, _ in self._items:
104 painter.save()
105 color = self.Color.toRgb()
106 color.setAlphaF(item.opacity)
107 painter.setBrush(color)
108 # 5<= radius <=10
109 radius = qBound(self.Radius, self.Radius / 200 *

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected