2016-08-05 115 views
0

我正在创建一个GraphicsLayoutWidget,然后使用addPlot()向窗口小部件添加图。此小部件不显示在屏幕上,但用于通过以下方式导出图像:在pyqtgraph中导出窗口小部件的图像

exporter = pyqtgraph.exporters.ImageExporter(pwidget.scene()) 
    exporter.export(os.path.join(datadirtemp, str(typename) + '.png')) 

但是图像从未覆盖整个图。

而且,使用下面的项目没有帮助:

exporter.parameters()['width'] = pwidget.scene().sceneRect().width() 

我得到以下错误:

Cannot export image with size=0 (requested export size is 0x0) 

回答

1

您试图在初始化之前导出窗口。所以你需要做

QtGui.QApplication.processEvents()

出口之前。

请参阅链接: from pyqtgraph's forum