diff --git a/doc/api/next_api_changes/deprecations/18680-AL.rst b/doc/api/next_api_changes/deprecations/18680-AL.rst new file mode 100644 index 000000000000..ce9e44e10397 --- /dev/null +++ b/doc/api/next_api_changes/deprecations/18680-AL.rst @@ -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. diff --git a/lib/matplotlib/backends/backend_wx.py b/lib/matplotlib/backends/backend_wx.py index 0e11e3ecfe60..482442ace600 100644 --- a/lib/matplotlib/backends/backend_wx.py +++ b/lib/matplotlib/backends/backend_wx.py @@ -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 @@ -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: @@ -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) diff --git a/lib/matplotlib/backends/backend_wxagg.py b/lib/matplotlib/backends/backend_wxagg.py index 0899a20738b2..106578e7e14b 100644 --- a/lib/matplotlib/backends/backend_wxagg.py +++ b/lib/matplotlib/backends/backend_wxagg.py @@ -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 diff --git a/lib/matplotlib/backends/backend_wxcairo.py b/lib/matplotlib/backends/backend_wxcairo.py index 5fcd263685a2..6cb0b9d68414 100644 --- a/lib/matplotlib/backends/backend_wxcairo.py +++ b/lib/matplotlib/backends/backend_wxcairo.py @@ -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