Skip to content

Commit 13ea995

Browse files
committed
wx backend API cleanups.
- Deprecate origin kwarg to wx gui_repaint(). It's really just a slightly obscure way to add a special-path for the (long deprecated) wx backend, which can be done more explicitly. - Deprecate unused NavigationToolbar2Wx.get_canvas.
1 parent 319f35b commit 13ea995

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
wx backend cleanups
2+
~~~~~~~~~~~~~~~~~~~
3+
The *origin* parameter to ``_FigureCanvasWxBase.gui_repaint`` is deprecated
4+
with no replacement; ``gui_repaint`` now automatically detects the case where
5+
it is used with the wx renderer.
6+
7+
The ``NavigationToolbar2Wx.get_canvas`` method is deprecated; copy its
8+
implementation (``return type(toolbar.canvas)(frame, -1, figure)``) if needed.

lib/matplotlib/backends/backend_wx.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,7 @@ def _get_imagesave_wildcards(self):
615615
wildcards = '|'.join(wildcards)
616616
return wildcards, extensions, filter_index
617617

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

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

lib/matplotlib/backends/backend_wxagg.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def draw(self, drawDC=None):
3030

3131
self.bitmap = _convert_agg_to_wx_bitmap(self.get_renderer(), None)
3232
self._isDrawn = True
33-
self.gui_repaint(drawDC=drawDC, origin='WXAgg')
33+
self.gui_repaint(drawDC=drawDC)
3434

3535
def blit(self, bbox=None):
3636
# docstring inherited

lib/matplotlib/backends/backend_wxcairo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def draw(self, drawDC=None):
3838
self.figure.draw(self._renderer)
3939
self.bitmap = wxcairo.BitmapFromImageSurface(surface)
4040
self._isDrawn = True
41-
self.gui_repaint(drawDC=drawDC, origin='WXCairo')
41+
self.gui_repaint(drawDC=drawDC)
4242

4343

4444
@_BackendWx.export

0 commit comments

Comments
 (0)