Skip to content

Avoid export bug by calling processEvents() before export #8

@campagnola

Description

@campagnola

If we try to export programatically from a widget that has just been created, the export fails because the widget has size 0. In this case, it would be better to catch the exception, call processEvents(), and then retry the export. Example:

import PySide
import pyqtgraph as pg
import numpy as np
data = np.random.normal(size=1000)
win = pg.GraphicsWindow(title="hi")
win.resize(800,800)
p1 = win.addPlot()
plt = p1.plot(data, title="Simplest possible plotting example")
# pg.QtGui.QApplication.processEvents() # <-- fixes the bug
exporter = pg.exporters.ImageExporter.ImageExporter(p1)
exporter.parameters()['width'] = 800
exporter.export("yay" + ".png")

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions