Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 04b047b

Browse files
committed
wx: Fix saving to a BytesIO.
In classic wx, there were multiple functions for overloaded C++ methods, but in phoenix there's just the one.
1 parent b65d1e7 commit 04b047b

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

lib/matplotlib/backends/backend_wx.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -883,14 +883,11 @@ def _print_image(self, filename, filetype, *args, **kwargs):
883883

884884
# Now that we have rendered into the bitmap, save it to the appropriate
885885
# file type and clean up.
886-
if isinstance(filename, str):
887-
if not image.SaveFile(filename, filetype):
888-
raise RuntimeError(f'Could not save figure to {filename}')
889-
elif cbook.is_writable_file_like(filename):
890-
if not isinstance(image, wx.Image):
891-
image = image.ConvertToImage()
892-
if not image.SaveStream(filename, filetype):
893-
raise RuntimeError(f'Could not save figure to {filename}')
886+
if (cbook.is_writable_file_like(filename) and
887+
not isinstance(image, wx.Image)):
888+
image = image.ConvertToImage()
889+
if not image.SaveFile(filename, filetype):
890+
raise RuntimeError(f'Could not save figure to {filename}')
894891

895892
# Restore everything to normal
896893
self.bitmap = origBitmap

0 commit comments

Comments
 (0)