From 6985be2a6fe2133c9229bafc439f013bc5825ec5 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 1 Mar 2020 17:46:01 +0100 Subject: [PATCH 1/2] replaced incompatible string construction --- pyqtgraph/exporters/ImageExporter.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pyqtgraph/exporters/ImageExporter.py b/pyqtgraph/exporters/ImageExporter.py index e600afc9..a8d235a8 100644 --- a/pyqtgraph/exporters/ImageExporter.py +++ b/pyqtgraph/exporters/ImageExporter.py @@ -47,10 +47,7 @@ class ImageExporter(Exporter): def export(self, fileName=None, toBytes=False, copy=False): if fileName is None and not toBytes and not copy: - if QT_LIB in ['PySide', 'PySide2']: - filter = ["*."+str(f, encoding='utf-8') for f in QtGui.QImageWriter.supportedImageFormats()] - else: - filter = ["*."+bytes(f).decode('utf-8') for f in QtGui.QImageWriter.supportedImageFormats()] + filter = ["*."+f.data().decode('utf-8') for f in QtGui.QImageWriter.supportedImageFormats()] preferred = ['*.png', '*.tif', '*.jpg'] for p in preferred[::-1]: if p in filter: From 3ba76475d484bd79af070f8354205fadf4f87437 Mon Sep 17 00:00:00 2001 From: Kenneth Lyons Date: Thu, 2 Apr 2020 22:55:33 -0700 Subject: [PATCH 2/2] Added ImageExporter test for py2-pyside fix --- pyqtgraph/exporters/tests/test_image.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 pyqtgraph/exporters/tests/test_image.py diff --git a/pyqtgraph/exporters/tests/test_image.py b/pyqtgraph/exporters/tests/test_image.py new file mode 100644 index 00000000..6f52eceb --- /dev/null +++ b/pyqtgraph/exporters/tests/test_image.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- +import pyqtgraph as pg +from pyqtgraph.exporters import ImageExporter + +app = pg.mkQApp() + + +def test_ImageExporter_filename_dialog(): + """Tests ImageExporter code path that opens a file dialog. Regression test + for pull request 1133.""" + p = pg.plot() + exp = ImageExporter(p.getPlotItem()) + exp.export()