Skip to content

wx backend API cleanups. #18680

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

Merged
merged 1 commit into from
Oct 13, 2020
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
8 changes: 8 additions & 0 deletions doc/api/next_api_changes/deprecations/18680-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
wx backend cleanups
~~~~~~~~~~~~~~~~~~~
The *origin* parameter to ``_FigureCanvasWxBase.gui_repaint`` is deprecated
with no replacement; ``gui_repaint`` now automatically detects the case where
it is used with the wx renderer.

The ``NavigationToolbar2Wx.get_canvas`` method is deprecated; directly
instantiate a canvas (``FigureCanvasWxAgg(frame, -1, figure)``) if needed.
5 changes: 4 additions & 1 deletion lib/matplotlib/backends/backend_wx.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@ def _get_imagesave_wildcards(self):
wildcards = '|'.join(wildcards)
return wildcards, extensions, filter_index

@cbook._delete_parameter("3.4", "origin")
def gui_repaint(self, drawDC=None, origin='WX'):
"""
Performs update of the displayed image on the GUI canvas, using the
Expand All @@ -632,7 +633,8 @@ def gui_repaint(self, drawDC=None, origin='WX'):
# For 'WX' backend on Windows, the bitmap can not be in use by another
# DC (see GraphicsContextWx._cache).
bmp = (self.bitmap.ConvertToImage().ConvertToBitmap()
if wx.Platform == '__WXMSW__' and origin == 'WX'
if wx.Platform == '__WXMSW__'
and isinstance(self.figure._cachedRenderer, RendererWx)
else self.bitmap)
drawDC.DrawBitmap(bmp, 0, 0)
if self._rubberband_rect is not None:
Expand Down Expand Up @@ -1174,6 +1176,7 @@ def _icon(name):
return wx.Bitmap.FromBufferRGBA(
image.shape[1], image.shape[0], image.tobytes())

@cbook.deprecated("3.4")
def get_canvas(self, frame, fig):
return type(self.canvas)(frame, -1, fig)

Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/backend_wxagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def draw(self, drawDC=None):

self.bitmap = _convert_agg_to_wx_bitmap(self.get_renderer(), None)
self._isDrawn = True
self.gui_repaint(drawDC=drawDC, origin='WXAgg')
self.gui_repaint(drawDC=drawDC)

def blit(self, bbox=None):
# docstring inherited
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/backend_wxcairo.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def draw(self, drawDC=None):
self.figure.draw(self._renderer)
self.bitmap = wxcairo.BitmapFromImageSurface(surface)
self._isDrawn = True
self.gui_repaint(drawDC=drawDC, origin='WXCairo')
self.gui_repaint(drawDC=drawDC)


@_BackendWx.export
Expand Down