Merge pull request #1151 from ixjlyons/imageexporter-tests

ImageExporter py2-pyside fix with test
This commit is contained in:
Ogi Moore 2020-04-03 09:46:45 -07:00 committed by GitHub
commit 7cbc703449
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 4 deletions

View File

@ -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:

View File

@ -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()