Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 30d8f61

Browse filesBrowse 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 e5404d8 commit 30d8f61
Copy full SHA for 30d8f61

File tree

Expand file treeCollapse file tree

4 files changed

+19
-12
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+19
-12
lines changed
+8Lines changed: 8 additions & 0 deletions
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

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_wx.py
+9-10Lines changed: 9 additions & 10 deletions
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
@@ -629,16 +630,13 @@ def gui_repaint(self, drawDC=None, origin='WX'):
629630
if not drawDC:
630631
# not called from OnPaint use a ClientDC
631632
drawDC = wx.ClientDC(self)
632-
633-
# following is for 'WX' backend on Windows
634-
# the bitmap can not be in use by another DC,
635-
# see GraphicsContextWx._cache
636-
if wx.Platform == '__WXMSW__' and origin == 'WX':
637-
img = self.bitmap.ConvertToImage()
638-
bmp = img.ConvertToBitmap()
639-
drawDC.DrawBitmap(bmp, 0, 0)
640-
else:
641-
drawDC.DrawBitmap(self.bitmap, 0, 0)
633+
# For the wx renderer on Windows, the bitmap cannot be in use by
634+
# another DC (see GraphicsContextWx._cache).
635+
bmp = (self.bitmap.ConvertToImage().ConvertToBitmap()
636+
if (wx.Platform == '__WXMSW__'
637+
and isinstance(self.figure._cachedRenderer, RendererWx))
638+
else self.bitmap)
639+
drawDC.DrawBitmap(bmp, 0, 0)
642640

643641
filetypes = {
644642
**FigureCanvasBase.filetypes,
@@ -1172,6 +1170,7 @@ def _icon(name):
11721170
return wx.Bitmap.FromBufferRGBA(
11731171
image.shape[1], image.shape[0], image.tobytes())
11741172

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

‎lib/matplotlib/backends/backend_wxagg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_wxagg.py
+1-1Lines changed: 1 addition & 1 deletion
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

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_wxcairo.py
+1-1Lines changed: 1 addition & 1 deletion
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.