MCPcopy Create free account
hub / github.com/PyQt5/PyQtClient / paintEvent

Method paintEvent

Widgets/Buttons/RubberBandButton.py:29–52  ·  view source on GitHub ↗
(self, event)

Source from the content-addressed store, hash-verified

27 self._bgcolor = QColor(Qt.green)
28
29 def paintEvent(self, event):
30 self._initAnimate()
31 painter = QStylePainter(self)
32 painter.setRenderHint(QPainter.Antialiasing, True)
33 painter.setRenderHint(QPainter.HighQualityAntialiasing, True)
34 painter.setRenderHint(QPainter.SmoothPixmapTransform, True)
35 painter.setBrush(QColor(self._bgcolor))
36 painter.setPen(QColor(self._bgcolor))
37 painter.drawEllipse(
38 QRectF((self.minimumWidth() - self._width) / 2,
39 (self.minimumHeight() - self._height) / 2, self._width,
40 self._height))
41 # 绘制本身的文字和图标
42 options = QStyleOptionButton()
43 options.initFrom(self)
44 size = options.rect.size()
45 size.transpose()
46 options.rect.setSize(size)
47 options.features = QStyleOptionButton.Flat
48 options.text = self.text()
49 options.icon = self.icon()
50 options.iconSize = self.iconSize()
51 painter.drawControl(QStyle.CE_PushButton, options)
52 event.accept()
53
54 def _initAnimate(self):
55 if hasattr(self, '_animate'):

Callers

nothing calls this directly

Calls 2

_initAnimateMethod · 0.95
sizeMethod · 0.45

Tested by

no test coverage detected