diff options
-rw-r--r-- | eitControl.py | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/eitControl.py b/eitControl.py index 668b58e..43050a1 100644 --- a/eitControl.py +++ b/eitControl.py @@ -1,7 +1,7 @@ from pyqtgraph.Qt import QtGui, QtCore import pyqtgraph as pg from pyqtgraph.dockarea import * -from pyqtgraph.exporters import ImageExporter +import pyqtgraph.exporters import platform import os @@ -159,13 +159,23 @@ class Experiment: png_file=csv_file.replace(".csv", ".png") print(f"Picture saved to {png_file}") - try: - ex = ImageExporter(self.channelGraph['adc0']) - ex.parameters()['width'] = 800 - ex.parameters()['height'] = 600 - ex.export(png_file) - except ZeroDivisionError: - print("Early version (0.10.0) of PyQtGraph has bug in exporter. The image file is not generated.") + plt = self.dataPlot.getPlotItem() + ex = pg.exporters.ImageExporter(plt) + if pg.__version__ == '0.10.0': + # Workaround for PyQtGraph version <= 0.10.0 + # see https://github.com/pyqtgraph/pyqtgraph/issues/538#issuecomment-361405356 + w= int(plt.width()) + h= int(plt.height()) + # the value in setValue need to be different from default + # otherwise it will not be taken + ex.parameters().param('width').setValue(w+1, blockSignal=ex.widthChanged) + ex.parameters().param('height').setValue(h+1, blockSignal=ex.heightChanged) + # now we set actual value + # ex.parameters()['width'] = w + ex.parameters().param('width').setValue(w, blockSignal=ex.widthChanged) + ex.parameters().param('height').setValue(h, blockSignal=ex.heightChanged) + # beware this is bad workaround!!! plot data is misplaced + ex.export(png_file) def onTic(self,swp=None): start = datetime.now() |