Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix use-case where canvas misses requests for a new draw #10

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rendercanvas/_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
9 changes: 9 additions & 0 deletions rendercanvas/qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ def paintEngine(self): # noqa: N802 - this is a Qt method
def paintEvent(self, event): # noqa: N802 - this is a Qt method
self._draw_frame_and_present()

def update(self):
# Bypass Qt's mechanics and request a draw so that the scheduling mechanics work as intended.
# Eventually this will call _request_draw().
self.request_draw()

# Methods that we add for BaseRenderCanvas (snake_case)

def _request_draw(self):
Expand Down Expand Up @@ -490,6 +495,10 @@ def __init__(self, *, size=None, title=None, **kwargs):

# Qt methods

def update(self):
self._subwidget.request_draw()
super().update()

def closeEvent(self, event): # noqa: N802
self._subwidget._is_closed = True
self.submit_event({"event_type": "close"})
Expand Down