aboutsummaryrefslogtreecommitdiffstats
path: root/examples/widgets/effects
diff options
context:
space:
mode:
authorChristian Tismer <[email protected]>2022-01-26 12:49:43 +0100
committerChristian Tismer <[email protected]>2022-01-26 16:47:13 +0000
commitb61f735acd8fa2e43a68d7d90f977d8f1506052a (patch)
tree9a5f4fb9debe1d7d51119ea9e169e58bc47bc62f /examples/widgets/effects
parentdc2046124f132ba0187d1bff97364448288b1cd6 (diff)
examples: Turn most QPainter instances into context managers
After the new context manager is in place, most of the examples benefit from moving QPainter into a `with` statement. The comments concerning PyPy could be removed, again. [ChangeLog][PySide6] The examples are updated to use the new context manager for QPainter. Task-number: PYSIDE-535 Change-Id: Idf7e1f734d549ed663383ffbb2416297ebb1e0c7 Reviewed-by: Christian Tismer <[email protected]>
Diffstat (limited to 'examples/widgets/effects')
-rw-r--r--examples/widgets/effects/lighting/lighting.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/examples/widgets/effects/lighting/lighting.py b/examples/widgets/effects/lighting/lighting.py
index ec8f945e1..be34464dd 100644
--- a/examples/widgets/effects/lighting/lighting.py
+++ b/examples/widgets/effects/lighting/lighting.py
@@ -89,11 +89,10 @@ class Lighting(QGraphicsView):
pixmap = QPixmap(60, 60)
pixmap.fill(Qt.transparent)
- painter = QPainter(pixmap)
- painter.setPen(Qt.NoPen)
- painter.setBrush(radial_grad)
- painter.drawEllipse(0, 0, 60, 60)
- painter.end()
+ with QPainter(pixmap) as painter:
+ painter.setPen(Qt.NoPen)
+ painter.setBrush(radial_grad)
+ painter.drawEllipse(0, 0, 60, 60)
self.m_lightSource = self.m_scene.addPixmap(pixmap)
self.m_lightSource.setZValue(2)