diff --git a/examples/wx_app.py b/examples/wx_app.py index cc0a320..aa1c41c 100644 --- a/examples/wx_app.py +++ b/examples/wx_app.py @@ -19,9 +19,7 @@ def __init__(self): self.SetSize(640, 480) # Using present_method 'bitmap' because it reports "The surface texture is suboptimal" - self.canvas = RenderWidget( - self, update_mode="continuous", present_method="bitmap" - ) + self.canvas = RenderWidget(self, update_mode="continuous") self.button = wx.Button(self, -1, "Hello world") self.output = wx.StaticText(self) diff --git a/rendercanvas/qt.py b/rendercanvas/qt.py index f44d34c..4194ad1 100644 --- a/rendercanvas/qt.py +++ b/rendercanvas/qt.py @@ -352,10 +352,9 @@ def paintEvent(self, event): # noqa: N802 - this is a Qt method painter.drawImage(rect2, image, rect1) painter.end() - # 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() + def update(self): + # Bypass Qt's mechanics and request a draw, which will eventually call the native update() + self.request_draw() # %% Methods to implement RenderCanvas diff --git a/rendercanvas/wx.py b/rendercanvas/wx.py index ade75da..6b1e8ea 100644 --- a/rendercanvas/wx.py +++ b/rendercanvas/wx.py @@ -240,7 +240,7 @@ def __init__(self, *args, **kwargs): def _on_resize_done(self, *args): self._draw_lock = False - self.Refresh() + self.request_draw() def on_paint(self, event): dc = wx.PaintDC(self) @@ -252,6 +252,10 @@ def on_paint(self, event): event.Skip() del dc + def Refresh(self): # noqa: N802 + # Bypass wx mechanics and request a draw, which will eventually call the native Refresh() + self.request_draw() + def _get_surface_ids(self): if sys.platform.startswith("win") or sys.platform.startswith("darwin"): return { @@ -322,12 +326,12 @@ def _rc_request_paint(self): if self._draw_lock: return try: - self.Refresh() + wx.Window.Refresh(self) except Exception: pass # avoid errors when window no longer lives def _rc_force_paint(self): - self.Refresh() + wx.Window.Refresh(self) self.Update() if sys.platform == "darwin": wx.Yield() @@ -581,6 +585,10 @@ def __init__(self, parent=None, **kwargs): self.Show() self._final_canvas_init() + def Refresh(self): # noqa: N802 + self._subwidget.request_draw() + super().Refresh() + # Make available under a name that is the same for all gui backends RenderWidget = WxRenderWidget