From 4951bd743ef7e2a5198615573167301c9603b72f Mon Sep 17 00:00:00 2001 From: Ogi Moore Date: Mon, 22 Mar 2021 11:17:12 -0700 Subject: [PATCH] Replace main stanza with PyQt6 compatable variant (#1645) * Replace main stanza with PyQt6 compatable variant * Use fn.mkQApp instead * remove needless comments --- examples/Arrow.py | 5 +---- examples/BarGraphItem.py | 5 +---- examples/CLIexample.py | 6 +----- examples/ColorButton.py | 5 +---- examples/ConsoleWidget.py | 5 +---- examples/CustomGraphItem.py | 5 +---- examples/DataSlicing.py | 5 +---- examples/DataTreeWidget.py | 5 +---- examples/DateAxisItem.py | 5 +---- examples/DateAxisItem_QtDesigner.py | 5 +---- examples/DiffTreeWidget.py | 5 +---- examples/Draw.py | 5 +---- examples/ErrorBarItem.py | 5 +---- examples/ExampleApp.py | 5 ++--- examples/FillBetweenItem.py | 5 +---- examples/Flowchart.py | 7 +------ examples/FlowchartCustomNode.py | 7 +------ examples/GLBarGraphItem.py | 6 +----- examples/GLImageItem.py | 5 +---- examples/GLIsosurface.py | 7 +------ examples/GLLinePlotItem.py | 7 +------ examples/GLMeshItem.py | 10 +--------- examples/GLScatterPlotItem.py | 6 +----- examples/GLSurfacePlot.py | 5 +---- examples/GLViewWidget.py | 5 +---- examples/GLVolumeItem.py | 5 +---- examples/GLshaders.py | 7 +------ examples/GradientEditor.py | 6 +----- examples/GradientWidget.py | 6 +----- examples/GraphItem.py | 8 +------- examples/GraphicsLayout.py | 7 +------ examples/GraphicsScene.py | 6 +----- examples/HistogramLUT.py | 6 +----- examples/ImageItem.py | 5 +---- examples/ImageView.py | 5 +---- examples/InfiniteLine.py | 6 +----- examples/JoystickButton.py | 8 +------- examples/Legend.py | 5 +---- examples/LogPlotTest.py | 5 +---- examples/MouseSelection.py | 5 +---- examples/MultiPlotSpeedTest.py | 5 +---- examples/MultiPlotWidget.py | 5 +---- examples/MultiplePlotAxes.py | 5 +---- examples/NonUniformImage.py | 6 +----- examples/PColorMeshItem.py | 5 +---- examples/PanningPlot.py | 5 +---- examples/PlotAutoRange.py | 7 +------ examples/PlotSpeedTest.py | 7 +------ examples/PlotWidget.py | 5 +---- examples/Plotting.py | 5 +---- examples/ROIExamples.py | 12 +----------- examples/ROItypes.py | 7 +------ examples/RemoteGraphicsView.py | 6 +----- examples/RemoteSpeedTest.py | 7 +------ examples/ScaleBar.py | 5 +---- examples/ScatterPlot.py | 6 +----- examples/ScatterPlotSpeedTest.py | 7 +------ examples/ScatterPlotWidget.py | 6 +----- examples/SimplePlot.py | 5 +---- examples/SpinBox.py | 5 +---- examples/Symbols.py | 5 +---- examples/TableWidget.py | 6 +----- examples/TreeWidget.py | 5 +---- examples/VideoSpeedTest.py | 7 +------ examples/ViewBox.py | 5 +---- examples/ViewBoxFeatures.py | 7 +------ examples/ViewLimits.py | 6 +----- examples/beeswarm.py | 5 +---- examples/colorMaps.py | 5 +---- examples/contextMenu.py | 5 +---- examples/crosshair.py | 5 +---- examples/customGraphicsItem.py | 5 +---- examples/customPlot.py | 5 +---- examples/designerExample.py | 6 +----- examples/dockarea.py | 5 +---- examples/fractal.py | 7 +------ examples/hdf5.py | 12 +----------- examples/histogram.py | 5 +---- examples/imageAnalysis.py | 6 +----- examples/infiniteline_performance.py | 6 +----- examples/isocurve.py | 5 +---- examples/linkedViews.py | 6 +----- examples/logAxis.py | 6 +----- examples/multiplePlotSpeedTest.py | 5 +---- examples/multiprocess.py | 6 ------ examples/optics_demos.py | 9 +-------- examples/parametertree.py | 6 +----- examples/relativity/relativity.py | 9 ++------- examples/relativity_demo.py | 5 +---- examples/scrollingPlots.py | 7 +------ examples/template.py | 5 +---- examples/test_ExampleApp.py | 6 ++---- examples/text.py | 7 +------ examples/verlet_chain_demo.py | 6 +----- pyqtgraph/widgets/JoystickButton.py | 7 ++----- 95 files changed, 98 insertions(+), 467 deletions(-) diff --git a/examples/Arrow.py b/examples/Arrow.py index bd0b6b07..7f5a5c97 100644 --- a/examples/Arrow.py +++ b/examples/Arrow.py @@ -50,8 +50,5 @@ p2.addItem(a) anim = a.makeAnimation(loop=-1) anim.start() -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/BarGraphItem.py b/examples/BarGraphItem.py index 6caa8862..a5b0a0c2 100644 --- a/examples/BarGraphItem.py +++ b/examples/BarGraphItem.py @@ -34,8 +34,5 @@ class BarGraph(pg.BarGraphItem): bg = BarGraph(x=x, y=y1*0.3+2, height=0.4+y1*0.2, width=0.8) win.addItem(bg) -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/CLIexample.py b/examples/CLIexample.py index f32cf81c..02bb989b 100644 --- a/examples/CLIexample.py +++ b/examples/CLIexample.py @@ -18,9 +18,5 @@ pg.plot(data, title="Simplest possible plotting example") data = np.random.normal(size=(500,500)) pg.image(data, title="Simplest possible image example") - -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if sys.flags.interactive != 1 or not hasattr(QtCore, 'PYQT_VERSION'): - pg.QtGui.QApplication.exec_() + pg.mkQApp().exec_() diff --git a/examples/ColorButton.py b/examples/ColorButton.py index e9df9750..c9621f54 100644 --- a/examples/ColorButton.py +++ b/examples/ColorButton.py @@ -26,8 +26,5 @@ def done(btn): btn.sigColorChanging.connect(change) btn.sigColorChanged.connect(done) -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/ConsoleWidget.py b/examples/ConsoleWidget.py index 8234269d..ab390a9c 100644 --- a/examples/ConsoleWidget.py +++ b/examples/ConsoleWidget.py @@ -29,8 +29,5 @@ c = pyqtgraph.console.ConsoleWidget(namespace=namespace, text=text) c.show() c.setWindowTitle('pyqtgraph example: ConsoleWidget') -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/CustomGraphItem.py b/examples/CustomGraphItem.py index 8e494c3a..ff40f571 100644 --- a/examples/CustomGraphItem.py +++ b/examples/CustomGraphItem.py @@ -129,8 +129,5 @@ g.setData(pos=pos, adj=adj, pen=lines, size=1, symbol=symbols, pxMode=False, tex -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/DataSlicing.py b/examples/DataSlicing.py index 8bd1e04d..610dd194 100644 --- a/examples/DataSlicing.py +++ b/examples/DataSlicing.py @@ -57,8 +57,5 @@ imv1.setLevels(-0.003, 0.003) update() -## Start Qt event loop unless running in interactive mode. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/DataTreeWidget.py b/examples/DataTreeWidget.py index 47a5f32b..e129f137 100644 --- a/examples/DataTreeWidget.py +++ b/examples/DataTreeWidget.py @@ -42,8 +42,5 @@ tree.setWindowTitle('pyqtgraph example: DataTreeWidget') tree.resize(600,600) -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() \ No newline at end of file + pg.mkQApp().exec_() diff --git a/examples/DateAxisItem.py b/examples/DateAxisItem.py index d789308d..86be0176 100644 --- a/examples/DateAxisItem.py +++ b/examples/DateAxisItem.py @@ -26,8 +26,5 @@ w.plot(now-(2*np.pi/x)**2*100*np.pi*1e7, np.sin(x), symbol='o') w.setWindowTitle('pyqtgraph example: DateAxisItem') w.show() -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - app.exec_() + app.exec_() diff --git a/examples/DateAxisItem_QtDesigner.py b/examples/DateAxisItem_QtDesigner.py index d92a7503..a7dc46a3 100644 --- a/examples/DateAxisItem_QtDesigner.py +++ b/examples/DateAxisItem_QtDesigner.py @@ -42,8 +42,5 @@ window = ExampleApp() window.setWindowTitle('pyqtgraph example: DateAxisItem_QtDesigner') window.show() -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - app.exec_() + app.exec_() diff --git a/examples/DiffTreeWidget.py b/examples/DiffTreeWidget.py index 780e1eaf..0c7fcd78 100644 --- a/examples/DiffTreeWidget.py +++ b/examples/DiffTreeWidget.py @@ -45,8 +45,5 @@ tree.setWindowTitle('pyqtgraph example: DiffTreeWidget') tree.resize(1000, 800) -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() \ No newline at end of file + pg.mkQApp().exec_() diff --git a/examples/Draw.py b/examples/Draw.py index 1401c398..22ddf7e9 100644 --- a/examples/Draw.py +++ b/examples/Draw.py @@ -42,8 +42,5 @@ kern = np.array([ img.setDrawKernel(kern, mask=kern, center=(1,1), mode='add') img.setLevels([0, 10]) -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/ErrorBarItem.py b/examples/ErrorBarItem.py index cd576d51..5748f913 100644 --- a/examples/ErrorBarItem.py +++ b/examples/ErrorBarItem.py @@ -26,8 +26,5 @@ err = pg.ErrorBarItem(x=x, y=y, top=top, bottom=bottom, beam=0.5) plt.addItem(err) plt.plot(x, y, symbol='o', pen={'color': 0.8, 'width': 2}) -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/ExampleApp.py b/examples/ExampleApp.py index c54d79b2..3e72d24d 100644 --- a/examples/ExampleApp.py +++ b/examples/ExampleApp.py @@ -393,7 +393,6 @@ def main(): app = pg.mkQApp() loader = ExampleLoader() app.exec_() -# or condition so pytest runs ExampleApp as part of test suite + if __name__ == '__main__': - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - main() + main() diff --git a/examples/FillBetweenItem.py b/examples/FillBetweenItem.py index fc91ee32..c53276bb 100644 --- a/examples/FillBetweenItem.py +++ b/examples/FillBetweenItem.py @@ -45,8 +45,5 @@ timer.timeout.connect(update) timer.start(30) -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/Flowchart.py b/examples/Flowchart.py index 45e833ce..f9167872 100644 --- a/examples/Flowchart.py +++ b/examples/Flowchart.py @@ -75,10 +75,5 @@ fc.connectTerminals(fc['dataIn'], pw1Node['In']) fc.connectTerminals(fNode['Out'], pw2Node['In']) fc.connectTerminals(fNode['Out'], fc['dataOut']) - - -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/FlowchartCustomNode.py b/examples/FlowchartCustomNode.py index dc1fd55f..48927224 100644 --- a/examples/FlowchartCustomNode.py +++ b/examples/FlowchartCustomNode.py @@ -150,10 +150,5 @@ fc.connectTerminals(fc['dataIn'], v1Node['data']) fc.connectTerminals(fNode['dataOut'], v2Node['data']) fc.connectTerminals(fNode['dataOut'], fc['dataOut']) - - -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/GLBarGraphItem.py b/examples/GLBarGraphItem.py index e593d54a..84a44a48 100644 --- a/examples/GLBarGraphItem.py +++ b/examples/GLBarGraphItem.py @@ -39,9 +39,5 @@ size[...,2] = np.random.normal(size=(10,10)) bg = gl.GLBarGraphItem(pos, size) w.addItem(bg) - -## Start Qt event loop unless running in interactive mode. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/GLImageItem.py b/examples/GLImageItem.py index 6a31c09a..f5663df4 100644 --- a/examples/GLImageItem.py +++ b/examples/GLImageItem.py @@ -50,8 +50,5 @@ w.addItem(v3) ax = gl.GLAxisItem() w.addItem(ax) -## Start Qt event loop unless running in interactive mode. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/GLIsosurface.py b/examples/GLIsosurface.py index 0beeea66..16045a78 100644 --- a/examples/GLIsosurface.py +++ b/examples/GLIsosurface.py @@ -66,10 +66,5 @@ m2.setGLOptions('additive') w.addItem(m2) m2.translate(-25, -25, -50) - - -## Start Qt event loop unless running in interactive mode. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/GLLinePlotItem.py b/examples/GLLinePlotItem.py index 0d07b153..b375c1c1 100644 --- a/examples/GLLinePlotItem.py +++ b/examples/GLLinePlotItem.py @@ -43,10 +43,5 @@ for i in range(n): plt = gl.GLLinePlotItem(pos=pts, color=pg.glColor((i,n*1.3)), width=(i+1)/10., antialias=True) w.addItem(plt) - - -## Start Qt event loop unless running in interactive mode. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/GLMeshItem.py b/examples/GLMeshItem.py index 692f8f8f..16a647b4 100644 --- a/examples/GLMeshItem.py +++ b/examples/GLMeshItem.py @@ -117,13 +117,5 @@ m6.rotate(0., 0, 1, 1) w.addItem(m5) w.addItem(m6) - - - - - -## Start Qt event loop unless running in interactive mode. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/GLScatterPlotItem.py b/examples/GLScatterPlotItem.py index b52e17b5..c279eadf 100644 --- a/examples/GLScatterPlotItem.py +++ b/examples/GLScatterPlotItem.py @@ -106,9 +106,5 @@ t = QtCore.QTimer() t.timeout.connect(update) t.start(50) - -## Start Qt event loop unless running in interactive mode. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/GLSurfacePlot.py b/examples/GLSurfacePlot.py index cac8d5fe..0cee2adc 100644 --- a/examples/GLSurfacePlot.py +++ b/examples/GLSurfacePlot.py @@ -92,8 +92,5 @@ timer = QtCore.QTimer() timer.timeout.connect(update) timer.start(30) -## Start Qt event loop unless running in interactive mode. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/GLViewWidget.py b/examples/GLViewWidget.py index d06a6ed8..dec4f89a 100644 --- a/examples/GLViewWidget.py +++ b/examples/GLViewWidget.py @@ -27,8 +27,5 @@ ax2.setParentItem(b) b.translate(1,1,1) -## Start Qt event loop unless running in interactive mode. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/GLVolumeItem.py b/examples/GLVolumeItem.py index 628ee971..5d7e6601 100644 --- a/examples/GLVolumeItem.py +++ b/examples/GLVolumeItem.py @@ -63,8 +63,5 @@ w.addItem(v) ax = gl.GLAxisItem() w.addItem(ax) -## Start Qt event loop unless running in interactive mode. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/GLshaders.py b/examples/GLshaders.py index 86719c6d..4e1acc51 100644 --- a/examples/GLshaders.py +++ b/examples/GLshaders.py @@ -101,10 +101,5 @@ w.addItem(m6) #w.addItem(m2) #m2.translate(-25, -25, -50) - - -## Start Qt event loop unless running in interactive mode. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/GradientEditor.py b/examples/GradientEditor.py index ad8c8eee..e334f501 100644 --- a/examples/GradientEditor.py +++ b/examples/GradientEditor.py @@ -20,9 +20,5 @@ mw.show() ge = pg.GradientEditorItem() mw.setCentralItem(ge) - -## Start Qt event loop unless running in interactive mode. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/GradientWidget.py b/examples/GradientWidget.py index 623171b2..1ae53bc4 100644 --- a/examples/GradientWidget.py +++ b/examples/GradientWidget.py @@ -47,12 +47,8 @@ l.addWidget(w3, 2, 1) l.addWidget(w4, 1, 0) l.addWidget(label, 1, 1) - -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/GraphItem.py b/examples/GraphItem.py index 094b84bd..8e4e5c99 100644 --- a/examples/GraphItem.py +++ b/examples/GraphItem.py @@ -57,11 +57,5 @@ lines = np.array([ ## Update the graph g.setData(pos=pos, adj=adj, pen=lines, size=1, symbol=symbols, pxMode=False) - - - -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/GraphicsLayout.py b/examples/GraphicsLayout.py index 74d61c10..8edea2e6 100644 --- a/examples/GraphicsLayout.py +++ b/examples/GraphicsLayout.py @@ -78,10 +78,5 @@ p2.plot([1,3,2,4,3,5]) p4.plot([1,3,2,4,3,5]) p5.plot([1,3,2,4,3,5]) - - -## Start Qt event loop unless running in interactive mode. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/GraphicsScene.py b/examples/GraphicsScene.py index 69be5b53..3caf87c6 100644 --- a/examples/GraphicsScene.py +++ b/examples/GraphicsScene.py @@ -58,9 +58,5 @@ vb.addItem(prox) g = pg.GridItem() vb.addItem(g) - -## Start Qt event loop unless running in interactive mode. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/HistogramLUT.py b/examples/HistogramLUT.py index 4c9ef4cf..159b321f 100644 --- a/examples/HistogramLUT.py +++ b/examples/HistogramLUT.py @@ -54,9 +54,5 @@ vb.autoRange() w.setImageItem(img) - -## Start Qt event loop unless running in interactive mode. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/ImageItem.py b/examples/ImageItem.py index 49141084..29994826 100644 --- a/examples/ImageItem.py +++ b/examples/ImageItem.py @@ -58,8 +58,5 @@ def updateData(): timer.timeout.connect(updateData) updateData() -## Start Qt event loop unless running in interactive mode. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/ImageView.py b/examples/ImageView.py index 56ee2d0f..8c776a97 100644 --- a/examples/ImageView.py +++ b/examples/ImageView.py @@ -63,8 +63,5 @@ imv.setColorMap(cmap) imv.ui.roiBtn.setChecked(True) imv.roiClicked() -## Start Qt event loop unless running in interactive mode. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/InfiniteLine.py b/examples/InfiniteLine.py index d90ae143..d9ef8a9a 100644 --- a/examples/InfiniteLine.py +++ b/examples/InfiniteLine.py @@ -37,9 +37,5 @@ lr = pg.LinearRegionItem(values=[70, 80]) p1.addItem(lr) label = pg.InfLineLabel(lr.lines[1], "region 1", position=0.95, rotateAxis=(1,0), anchor=(1, 1)) - -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/JoystickButton.py b/examples/JoystickButton.py index c6965900..8288ad8f 100644 --- a/examples/JoystickButton.py +++ b/examples/JoystickButton.py @@ -46,11 +46,5 @@ timer = QtCore.QTimer() timer.timeout.connect(update) timer.start(30) - - - -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/Legend.py b/examples/Legend.py index f3683cd0..73cecf5e 100644 --- a/examples/Legend.py +++ b/examples/Legend.py @@ -39,8 +39,5 @@ legend.addItem(c1, 'curve1') legend.addItem(c2, 'curve2') legend.addItem(s1, 'scatter') -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/LogPlotTest.py b/examples/LogPlotTest.py index 1e6bf669..eb34bcea 100644 --- a/examples/LogPlotTest.py +++ b/examples/LogPlotTest.py @@ -30,8 +30,5 @@ p5.setLabel('bottom', "Y Axis", units='s') p5.setLogMode(x=True, y=False) -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/MouseSelection.py b/examples/MouseSelection.py index 3a573751..a964932b 100644 --- a/examples/MouseSelection.py +++ b/examples/MouseSelection.py @@ -30,8 +30,5 @@ for c in curves: win.addItem(c) c.sigClicked.connect(plotClicked) -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/MultiPlotSpeedTest.py b/examples/MultiPlotSpeedTest.py index e8f7ee85..bcdd1d83 100644 --- a/examples/MultiPlotSpeedTest.py +++ b/examples/MultiPlotSpeedTest.py @@ -62,8 +62,5 @@ timer = QtCore.QTimer() timer.timeout.connect(update) timer.start(0) -## Start Qt event loop unless running in interactive mode. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/MultiPlotWidget.py b/examples/MultiPlotWidget.py index 4802a046..f8670785 100644 --- a/examples/MultiPlotWidget.py +++ b/examples/MultiPlotWidget.py @@ -32,9 +32,6 @@ ma = MetaArray(data, info=[ ]) pw.plot(ma, pen='y') -## Start Qt event loop unless running in interactive mode. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/MultiplePlotAxes.py b/examples/MultiplePlotAxes.py index 75e0c680..7215cbf3 100644 --- a/examples/MultiplePlotAxes.py +++ b/examples/MultiplePlotAxes.py @@ -60,8 +60,5 @@ p1.plot([1,2,4,8,16,32]) p2.addItem(pg.PlotCurveItem([10,20,40,80,40,20], pen='b')) p3.addItem(pg.PlotCurveItem([3200,1600,800,400,200,100], pen='r')) -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/NonUniformImage.py b/examples/NonUniformImage.py index 9d13cc0b..2048c900 100644 --- a/examples/NonUniformImage.py +++ b/examples/NonUniformImage.py @@ -78,9 +78,5 @@ p.setLabel(axis='left', text='Torque [Nm]') p.axes['bottom']['item'].setZValue(1000) p.axes['left']['item'].setZValue(1000) - -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/PColorMeshItem.py b/examples/PColorMeshItem.py index 44604c8e..fbf920e5 100644 --- a/examples/PColorMeshItem.py +++ b/examples/PColorMeshItem.py @@ -83,8 +83,5 @@ def updateData(): timer.timeout.connect(updateData) updateData() -## Start Qt event loop unless running in interactive mode. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/PanningPlot.py b/examples/PanningPlot.py index 874bf330..161fd1f1 100644 --- a/examples/PanningPlot.py +++ b/examples/PanningPlot.py @@ -30,8 +30,5 @@ timer = QtCore.QTimer() timer.timeout.connect(update) timer.start(50) -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/PlotAutoRange.py b/examples/PlotAutoRange.py index a15f2e3f..c6b6077b 100644 --- a/examples/PlotAutoRange.py +++ b/examples/PlotAutoRange.py @@ -40,10 +40,5 @@ timer = QtCore.QTimer() timer.timeout.connect(update) timer.start(50) - -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() - + pg.mkQApp().exec_() diff --git a/examples/PlotSpeedTest.py b/examples/PlotSpeedTest.py index f5d630b4..90d8f7ee 100644 --- a/examples/PlotSpeedTest.py +++ b/examples/PlotSpeedTest.py @@ -48,10 +48,5 @@ timer = QtCore.QTimer() timer.timeout.connect(update) timer.start(0) - - -## Start Qt event loop unless running in interactive mode. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/PlotWidget.py b/examples/PlotWidget.py index a3f77b6d..ea8e3feb 100644 --- a/examples/PlotWidget.py +++ b/examples/PlotWidget.py @@ -86,8 +86,5 @@ line = pg.InfiniteLine(angle=90, movable=True) pw3.addItem(line) line.setBounds([0,200]) -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/Plotting.py b/examples/Plotting.py index c3831c0a..ea831110 100644 --- a/examples/Plotting.py +++ b/examples/Plotting.py @@ -95,8 +95,5 @@ lr.sigRegionChanged.connect(updatePlot) p9.sigXRangeChanged.connect(updateRegion) updatePlot() -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/ROIExamples.py b/examples/ROIExamples.py index abea9220..23721f0f 100644 --- a/examples/ROIExamples.py +++ b/examples/ROIExamples.py @@ -157,15 +157,5 @@ def remove(): v4.removeItem(r4) r4.sigRemoveRequested.connect(remove) - - - - - - - -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/ROItypes.py b/examples/ROItypes.py index 6d01667e..b65e544f 100644 --- a/examples/ROItypes.py +++ b/examples/ROItypes.py @@ -118,10 +118,5 @@ t = QtCore.QTimer() t.timeout.connect(updateImage) t.start(50) - - -## Start Qt event loop unless running in interactive mode. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/RemoteGraphicsView.py b/examples/RemoteGraphicsView.py index 2b74a8c6..5810f222 100644 --- a/examples/RemoteGraphicsView.py +++ b/examples/RemoteGraphicsView.py @@ -26,9 +26,5 @@ plt = v.pg.PlotItem() v.setCentralItem(plt) plt.plot([1,4,2,3,6,2,3,4,2,3], pen='g') - -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/RemoteSpeedTest.py b/examples/RemoteSpeedTest.py index 8d8dd210..cd62e173 100644 --- a/examples/RemoteSpeedTest.py +++ b/examples/RemoteSpeedTest.py @@ -72,10 +72,5 @@ timer = QtCore.QTimer() timer.timeout.connect(update) timer.start(0) - - -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/ScaleBar.py b/examples/ScaleBar.py index 94110a5d..7c7e0cd4 100644 --- a/examples/ScaleBar.py +++ b/examples/ScaleBar.py @@ -24,8 +24,5 @@ scale = pg.ScaleBar(size=0.1) scale.setParentItem(vb) scale.anchor((1, 1), (1, 1), offset=(-20, -20)) -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/ScatterPlot.py b/examples/ScatterPlot.py index 070f21c5..1e3e9409 100644 --- a/examples/ScatterPlot.py +++ b/examples/ScatterPlot.py @@ -134,9 +134,5 @@ s4.addPoints( w4.addItem(s4) s4.sigClicked.connect(clicked) - -## Start Qt event loop unless running in interactive mode. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/ScatterPlotSpeedTest.py b/examples/ScatterPlotSpeedTest.py index e0edefca..4c7f89c7 100644 --- a/examples/ScatterPlotSpeedTest.py +++ b/examples/ScatterPlotSpeedTest.py @@ -128,10 +128,5 @@ param.child('paused').sigValueChanged.connect(lambda _, v: timer.stop() if v els timer.timeout.connect(update) timer.start(0) - -# Start Qt event loop unless running in interactive mode. if __name__ == '__main__': - import sys - - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/ScatterPlotWidget.py b/examples/ScatterPlotWidget.py index f3766d56..b2d95340 100644 --- a/examples/ScatterPlotWidget.py +++ b/examples/ScatterPlotWidget.py @@ -62,9 +62,5 @@ spw.setFields([ spw.setData(data) spw.show() - -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/SimplePlot.py b/examples/SimplePlot.py index 03ee2204..8a190689 100644 --- a/examples/SimplePlot.py +++ b/examples/SimplePlot.py @@ -5,8 +5,5 @@ import pyqtgraph.exporters import numpy as np plt = pg.plot(np.random.normal(size=100), title="Simplest possible plotting example") -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if sys.flags.interactive != 1 or not hasattr(pg.QtCore, 'PYQT_VERSION'): - pg.QtGui.QApplication.exec_() + pg.mkQApp().exec_() diff --git a/examples/SpinBox.py b/examples/SpinBox.py index 88366cdf..e7bff2e4 100644 --- a/examples/SpinBox.py +++ b/examples/SpinBox.py @@ -128,8 +128,5 @@ layout.addWidget(changedLabel, 2, 1) #s.editingFinished.disconnect() -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/Symbols.py b/examples/Symbols.py index 3a683e6d..9eaf7371 100755 --- a/examples/Symbols.py +++ b/examples/Symbols.py @@ -35,8 +35,5 @@ plot.plot([13, 14, 15, 16, 17], pen=(187, 26, 95), symbolBrush=(187, 26, 95), sy plot.plot([14, 15, 16, 17, 18], pen=(248, 187, 208), symbolBrush=(248, 187, 208), symbolPen='w', symbol='arrow_right', symbolSize=22, name="symbol='arrow_right'") plot.setXRange(-2, 4) -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/TableWidget.py b/examples/TableWidget.py index 0fb1aae4..8bc86e34 100644 --- a/examples/TableWidget.py +++ b/examples/TableWidget.py @@ -26,9 +26,5 @@ data = np.array([ w.setData(data) - -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/TreeWidget.py b/examples/TreeWidget.py index 56940316..feea83a7 100644 --- a/examples/TreeWidget.py +++ b/examples/TreeWidget.py @@ -48,8 +48,5 @@ i2.addChild(i22) b1 = QtGui.QPushButton("Button") w.setItemWidget(i1, 1, b1) -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/VideoSpeedTest.py b/examples/VideoSpeedTest.py index c8c05d8e..c036b896 100644 --- a/examples/VideoSpeedTest.py +++ b/examples/VideoSpeedTest.py @@ -272,10 +272,5 @@ timer = QtCore.QTimer() timer.timeout.connect(update) timer.start(0) - - -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/ViewBox.py b/examples/ViewBox.py index f9dbac43..eca55ef5 100644 --- a/examples/ViewBox.py +++ b/examples/ViewBox.py @@ -93,8 +93,5 @@ t = QtCore.QTimer() t.timeout.connect(updateData) t.start(50) -## Start Qt event loop unless running in interactive mode. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/ViewBoxFeatures.py b/examples/ViewBoxFeatures.py index 5757924b..239b13f2 100644 --- a/examples/ViewBoxFeatures.py +++ b/examples/ViewBoxFeatures.py @@ -81,10 +81,5 @@ v6.setAutoVisible(x=False, y=True) l6 = pg.PlotDataItem(y) v6.addItem(l6) - - -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/ViewLimits.py b/examples/ViewLimits.py index c8f0dd21..4f2e85fc 100644 --- a/examples/ViewLimits.py +++ b/examples/ViewLimits.py @@ -7,9 +7,5 @@ import numpy as np plt = pg.plot(np.random.normal(size=100), title="View limit example") plt.centralWidget.vb.setLimits(xMin=-20, xMax=120, minXRange=5, maxXRange=100) - -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if sys.flags.interactive != 1 or not hasattr(QtCore, 'PYQT_VERSION'): - pg.QtGui.QApplication.exec_() + pg.mkQApp().exec_() diff --git a/examples/beeswarm.py b/examples/beeswarm.py index 48ee4236..3f119eb2 100644 --- a/examples/beeswarm.py +++ b/examples/beeswarm.py @@ -31,8 +31,5 @@ err = pg.ErrorBarItem(x=np.arange(4), y=data.mean(axis=1), height=data.std(axis= win.addItem(err) -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/colorMaps.py b/examples/colorMaps.py index fb648a66..174e2f89 100644 --- a/examples/colorMaps.py +++ b/examples/colorMaps.py @@ -96,8 +96,5 @@ for map_name in list_of_maps: lw.setFixedHeight(num_bars * (height+5) ) -## Start Qt event loop unless running in interactive mode. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/contextMenu.py b/examples/contextMenu.py index 904b9030..adc6c7b7 100644 --- a/examples/contextMenu.py +++ b/examples/contextMenu.py @@ -135,8 +135,5 @@ box2.setParentItem(box1) box2.setPos(5, 5) box2.setScale(0.2) -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/crosshair.py b/examples/crosshair.py index 150ed53d..15102adb 100644 --- a/examples/crosshair.py +++ b/examples/crosshair.py @@ -80,8 +80,5 @@ proxy = pg.SignalProxy(p1.scene().sigMouseMoved, rateLimit=60, slot=mouseMoved) #p1.scene().sigMouseMoved.connect(mouseMoved) -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/customGraphicsItem.py b/examples/customGraphicsItem.py index 9723b83a..bc006a23 100644 --- a/examples/customGraphicsItem.py +++ b/examples/customGraphicsItem.py @@ -54,8 +54,5 @@ plt = pg.plot() plt.addItem(item) plt.setWindowTitle('pyqtgraph example: customGraphicsItem') -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/customPlot.py b/examples/customPlot.py index 007ec691..9a4d9f6e 100644 --- a/examples/customPlot.py +++ b/examples/customPlot.py @@ -91,8 +91,5 @@ pw.setWindowTitle('pyqtgraph example: customPlot') r = pg.PolyLineROI([(0,0), (10, 10)]) pw.addItem(r) -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/designerExample.py b/examples/designerExample.py index 812eff6b..2c33bddd 100644 --- a/examples/designerExample.py +++ b/examples/designerExample.py @@ -38,9 +38,5 @@ class MainWindow(TemplateBaseClass): win = MainWindow() - -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/dockarea.py b/examples/dockarea.py index f87a8da3..a678ee02 100644 --- a/examples/dockarea.py +++ b/examples/dockarea.py @@ -111,8 +111,5 @@ win.show() -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/fractal.py b/examples/fractal.py index 3f008141..55491080 100644 --- a/examples/fractal.py +++ b/examples/fractal.py @@ -106,10 +106,5 @@ depthSpin.valueChanged.connect(update) # Initialize update() - -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() - \ No newline at end of file + pg.mkQApp().exec_() diff --git a/examples/hdf5.py b/examples/hdf5.py index 3cd5de29..338a44ff 100644 --- a/examples/hdf5.py +++ b/examples/hdf5.py @@ -141,15 +141,5 @@ curve = HDF5Plot() curve.setHDF5(f['data']) plt.addItem(curve) - -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - - - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() - - - - + pg.mkQApp().exec_() diff --git a/examples/histogram.py b/examples/histogram.py index 53d4fdad..d91631d2 100644 --- a/examples/histogram.py +++ b/examples/histogram.py @@ -29,8 +29,5 @@ y = pg.pseudoScatter(vals, spacing=0.15) #plt2.plot(vals, y, pen=None, symbol='o', symbolSize=5) plt2.plot(vals, y, pen=None, symbol='o', symbolSize=5, symbolPen=(255,255,255,200), symbolBrush=(0,0,255,150)) -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/imageAnalysis.py b/examples/imageAnalysis.py index d6febb14..0a821420 100644 --- a/examples/imageAnalysis.py +++ b/examples/imageAnalysis.py @@ -113,9 +113,5 @@ def imageHoverEvent(event): # but it works for a very simple use like this. img.hoverEvent = imageHoverEvent - -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/infiniteline_performance.py b/examples/infiniteline_performance.py index 9682080e..86d62b62 100644 --- a/examples/infiniteline_performance.py +++ b/examples/infiniteline_performance.py @@ -44,9 +44,5 @@ timer = QtCore.QTimer() timer.timeout.connect(update) timer.start(0) - -# Start Qt event loop unless running in interactive mode. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() \ No newline at end of file + pg.mkQApp().exec_() diff --git a/examples/isocurve.py b/examples/isocurve.py index 1ed30591..767107f5 100644 --- a/examples/isocurve.py +++ b/examples/isocurve.py @@ -53,8 +53,5 @@ timer = QtCore.QTimer() timer.timeout.connect(update) timer.start(50) -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/linkedViews.py b/examples/linkedViews.py index 0a387ddf..794ef092 100644 --- a/examples/linkedViews.py +++ b/examples/linkedViews.py @@ -40,10 +40,6 @@ p3.setXLink(p1) p3.setLabel('left', "Label to test offset") #QtGui.QApplication.processEvents() - -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/logAxis.py b/examples/logAxis.py index 9a66f114..5d1e179e 100644 --- a/examples/logAxis.py +++ b/examples/logAxis.py @@ -34,9 +34,5 @@ p3.plot(x, y) #p.getAxis('bottom').setLogMode(True) - -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/multiplePlotSpeedTest.py b/examples/multiplePlotSpeedTest.py index 07df7522..4bc39ed9 100644 --- a/examples/multiplePlotSpeedTest.py +++ b/examples/multiplePlotSpeedTest.py @@ -86,8 +86,5 @@ else: plt.autoRange() -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/multiprocess.py b/examples/multiprocess.py index 2e32b041..9c163e9f 100644 --- a/examples/multiprocess.py +++ b/examples/multiprocess.py @@ -51,9 +51,3 @@ d1 = proc.transfer(np.random.normal(size=1000)) d2 = proc.transfer(np.random.normal(size=1000)) rpg = proc._import('pyqtgraph') plt = rpg.plot(d1+d2) - - -## Start Qt event loop unless running in interactive mode or using pyside. -#import sys -#if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - #QtGui.QApplication.instance().exec_() diff --git a/examples/optics_demos.py b/examples/optics_demos.py index 1f173621..40211af4 100644 --- a/examples/optics_demos.py +++ b/examples/optics_demos.py @@ -159,12 +159,5 @@ timer = QtCore.QTimer() timer.timeout.connect(update) timer.start(40) - - - - -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/parametertree.py b/examples/parametertree.py index fdd1bdae..518ff3e7 100644 --- a/examples/parametertree.py +++ b/examples/parametertree.py @@ -178,9 +178,5 @@ win.show() s = p.saveState() p.restoreState(s) - -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/relativity/relativity.py b/examples/relativity/relativity.py index 64a67119..c255fb00 100644 --- a/examples/relativity/relativity.py +++ b/examples/relativity/relativity.py @@ -750,7 +750,7 @@ class ClockItem(pg.ItemGroup): #pass if __name__ == '__main__': - pg.mkQApp() + app = pg.mkQApp() #import pyqtgraph.console #cw = pyqtgraph.console.ConsoleWidget() #cw.show() @@ -759,10 +759,5 @@ if __name__ == '__main__': win.setWindowTitle("Relativity!") win.show() win.resize(1100,700) - - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() - - - #win.params.param('Objects').restoreState(state, removeChildren=False) + app.exec_() diff --git a/examples/relativity_demo.py b/examples/relativity_demo.py index 24a1f476..f278a26a 100644 --- a/examples/relativity_demo.py +++ b/examples/relativity_demo.py @@ -16,8 +16,5 @@ win.resize(1100,700) win.show() win.loadPreset(None, 'Twin Paradox (grid)') -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(pg.QtCore, 'PYQT_VERSION'): - pg.QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/scrollingPlots.py b/examples/scrollingPlots.py index d370aa46..def2594e 100644 --- a/examples/scrollingPlots.py +++ b/examples/scrollingPlots.py @@ -109,10 +109,5 @@ timer = pg.QtCore.QTimer() timer.timeout.connect(update) timer.start(50) - - -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/template.py b/examples/template.py index d39c6fb8..a462ac91 100644 --- a/examples/template.py +++ b/examples/template.py @@ -15,8 +15,5 @@ app = mkQApp() # win.setWindowTitle('pyqtgraph example: ____') -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/test_ExampleApp.py b/examples/test_ExampleApp.py index 7a1696d5..3162ffcf 100644 --- a/examples/test_ExampleApp.py +++ b/examples/test_ExampleApp.py @@ -7,7 +7,5 @@ from examples.ExampleApp import ExampleLoader loader = ExampleLoader() -if __name__ == "__main__": - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() \ No newline at end of file +if __name__ == '__main__': + pg.mkQApp().exec_() diff --git a/examples/text.py b/examples/text.py index bf9bd6b9..50c87159 100644 --- a/examples/text.py +++ b/examples/text.py @@ -52,10 +52,5 @@ timer = QtCore.QTimer() timer.timeout.connect(update) timer.start(10) - - -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/examples/verlet_chain_demo.py b/examples/verlet_chain_demo.py index 1197344d..d8aac5ca 100644 --- a/examples/verlet_chain_demo.py +++ b/examples/verlet_chain_demo.py @@ -118,9 +118,5 @@ timer = pg.QtCore.QTimer() timer.timeout.connect(update) timer.start(16) - -## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': - import sys - if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): - QtGui.QApplication.instance().exec_() + pg.mkQApp().exec_() diff --git a/pyqtgraph/widgets/JoystickButton.py b/pyqtgraph/widgets/JoystickButton.py index 88955934..4e4a335f 100644 --- a/pyqtgraph/widgets/JoystickButton.py +++ b/pyqtgraph/widgets/JoystickButton.py @@ -84,7 +84,7 @@ class JoystickButton(QtGui.QPushButton): if __name__ == '__main__': - app = QtGui.QApplication([]) + app = pg.mkQApp() w = QtGui.QMainWindow() b = JoystickButton() w.setCentralWidget(b) @@ -96,8 +96,5 @@ if __name__ == '__main__': b.sigStateChanged.connect(fn) - ## Start Qt event loop unless running in interactive mode. - import sys - if sys.flags.interactive != 1: - app.exec_() + app.exec_() \ No newline at end of file