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

Skip to content

Commit 2e7399e

Browse files
Daniel Hyamsmdboom
authored andcommitted
wx backend should not attempt to render jpeg/tiff if PIL is present.
If PIL is present, the wx backend needs to allow the base class to get the job done for print_jpeg and print_tiff, instead of trying to take over duties itself.
1 parent 9768142 commit 2e7399e

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

lib/matplotlib/backends/backend_wx.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ def bind(actor,event,action,id=None):
128128
FigureCanvasBase, FigureManagerBase, NavigationToolbar2, \
129129
cursors, TimerBase
130130
from matplotlib.backend_bases import ShowBase
131+
from matplotlib.backend_bases import _has_pil
131132

132133
from matplotlib._pylab_helpers import Gcf
133134
from matplotlib.artist import Artist
@@ -1137,19 +1138,21 @@ def print_figure(self, filename, *args, **kwargs):
11371138
def print_bmp(self, filename, *args, **kwargs):
11381139
return self._print_image(filename, wx.BITMAP_TYPE_BMP, *args, **kwargs)
11391140

1140-
def print_jpeg(self, filename, *args, **kwargs):
1141-
return self._print_image(filename, wx.BITMAP_TYPE_JPEG, *args, **kwargs)
1142-
print_jpg = print_jpeg
1141+
if not _has_pil:
1142+
def print_jpeg(self, filename, *args, **kwargs):
1143+
return self._print_image(filename, wx.BITMAP_TYPE_JPEG, *args, **kwargs)
1144+
print_jpg = print_jpeg
11431145

11441146
def print_pcx(self, filename, *args, **kwargs):
11451147
return self._print_image(filename, wx.BITMAP_TYPE_PCX, *args, **kwargs)
11461148

11471149
def print_png(self, filename, *args, **kwargs):
11481150
return self._print_image(filename, wx.BITMAP_TYPE_PNG, *args, **kwargs)
11491151

1150-
def print_tiff(self, filename, *args, **kwargs):
1151-
return self._print_image(filename, wx.BITMAP_TYPE_TIF, *args, **kwargs)
1152-
print_tif = print_tiff
1152+
if not _has_pil:
1153+
def print_tiff(self, filename, *args, **kwargs):
1154+
return self._print_image(filename, wx.BITMAP_TYPE_TIF, *args, **kwargs)
1155+
print_tif = print_tiff
11531156

11541157
def print_xpm(self, filename, *args, **kwargs):
11551158
return self._print_image(filename, wx.BITMAP_TYPE_XPM, *args, **kwargs)

0 commit comments

Comments
 (0)