How to enable console print of traceback in PyQtGraph

257 views Asked by At

Is there a preferred way in pyqtgraph to configure it to dump errors to the terminal?

In working with sample script https://github.com/pyqtgraph/pyqtgraph/blob/develop/examples/FlowchartCustomNode.py I tweaked it in a way that left a flaw in UnsharpMaskNode.process. There was no traceback so I tracked the error handling back to line 315 in https://github.com/pyqtgraph/pyqtgraph/blob/develop/pyqtgraph/flowchart/Node.py in UnsharpMaskNode parent class' Node.update method in where the error is swallowed by bare try/except. I uncommented a pyqtgraph developer's call to printExc in that except block which yes, prints, but I'd hoped to find find a constructor flag, a set method, a DEBUG const, anything to conditionally indicate that the traceback should tee to stderr.

For example, add a RuntimeError in method UnsharpMaskNode.process as shown below and execute the script. The exception will not be seen but in the GUI the corresponding ImageViewNode will present no image, implicitly indicating failure.

def process(self, dataIn, display=True):
    # CtrlNode has created self.ctrls, which is a dict containing {ctrlName: widget}
    sigma = self.ctrls['sigma'].value()
    strength = self.ctrls['strength'].value()
    raise RuntimeError('This will silently fail')
    output = dataIn - (strength * pg.gaussianFilter(dataIn, (sigma,sigma)))
    return {'dataOut': output}
0

There are 0 answers