From 3fab756a8a414b0958b5cd3227a9a9172c641aab Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Thu, 7 Nov 2024 09:55:03 +0100 Subject: [PATCH] Overload qt canvas.update() to request a draw --- wgpu/gui/_loop.py | 2 +- wgpu/gui/qt.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/wgpu/gui/_loop.py b/wgpu/gui/_loop.py index ccb17cfe..fd9ab08c 100644 --- a/wgpu/gui/_loop.py +++ b/wgpu/gui/_loop.py @@ -360,7 +360,7 @@ def _schedule_next_tick(self): return # Determine delay - if self._mode == "fastest": + if self._mode == "fastest" or self._max_fps <= 0: delay = 0 else: delay = 1 / self._max_fps diff --git a/wgpu/gui/qt.py b/wgpu/gui/qt.py index 046c29c6..aa2279c5 100644 --- a/wgpu/gui/qt.py +++ b/wgpu/gui/qt.py @@ -184,6 +184,10 @@ def paintEvent(self, event): # noqa: N802 - this is a Qt method # Methods that we add from wgpu (snake_case) + def update(self): + # Overload update() because that's how Qt devs are used to requesting a new draw + self.request_draw() + def _request_draw(self): # Ask Qt to do a paint event QtWidgets.QWidget.update(self) @@ -496,6 +500,10 @@ def closeEvent(self, event): # noqa: N802 # Methods that we add from wgpu (snake_case) + def update(self): + # Overload update() because that's how Qt devs are used to requesting a new draw + self.request_draw() + def _request_draw(self): self._subwidget._request_draw()