Skip to content

Commit

Permalink
Overload qt canvas.update() to request a draw
Browse files Browse the repository at this point in the history
  • Loading branch information
almarklein committed Nov 7, 2024
1 parent 3de43de commit 3fab756
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion wgpu/gui/_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions wgpu/gui/qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit 3fab756

Please sign in to comment.