Skip to content
Open
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
4 changes: 1 addition & 3 deletions examples/wx_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 3 additions & 4 deletions rendercanvas/qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 11 additions & 3 deletions rendercanvas/wx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down
Loading