aboutsummaryrefslogtreecommitdiffstats
path: root/examples/widgets/tutorials/cannon/t8.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/widgets/tutorials/cannon/t8.py')
-rw-r--r--examples/widgets/tutorials/cannon/t8.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/examples/widgets/tutorials/cannon/t8.py b/examples/widgets/tutorials/cannon/t8.py
index b02a049cc..757015495 100644
--- a/examples/widgets/tutorials/cannon/t8.py
+++ b/examples/widgets/tutorials/cannon/t8.py
@@ -115,10 +115,8 @@ class CannonField(QWidget):
self.angle_changed.emit(self._current_angle)
def paintEvent(self, event):
- painter = QPainter(self)
- painter.drawText(200, 200, f"Angle = {self._current_angle}")
- # QPainter needs an explicit end() in PyPy. This will become a context manager in 6.3.
- painter.end()
+ with QPainter(self) as painter:
+ painter.drawText(200, 200, f"Angle = {self._current_angle}")
class MyWidget(QWidget):