From e09a397ebcf244638e98371e015d324dea439d2d Mon Sep 17 00:00:00 2001 From: KIU Shueng Chuan Date: Mon, 22 Feb 2021 18:03:06 +0800 Subject: [PATCH 1/5] modify environment to choose binding the Example App allows the user to choose a binding and a graphics system to use to execute an example. issue 1: setGraphicsSystem is obsolete and the method no longer exists. thus selecting a graphics system causes an error. issue 2: the choice of binding to use is passed as an extra command line argument to be parsed by initExample. this is problematic for examples that use argparse, such as VideoSpeedTest.py issue 3: if the user has set PYQTGRAPH_QT_LIB, that takes precedence over the choice made in the Example App. this patch fixes the above 3 issues by setting PYQTGRAPH_QT_LIB in the child process' environment and removing the old parsing of the command line arguments --- examples/ExampleApp.py | 18 ++++++++++-------- examples/VideoSpeedTest.py | 3 +++ examples/initExample.py | 19 +------------------ 3 files changed, 14 insertions(+), 26 deletions(-) diff --git a/examples/ExampleApp.py b/examples/ExampleApp.py index 458daf76..c54d79b2 100644 --- a/examples/ExampleApp.py +++ b/examples/ExampleApp.py @@ -344,18 +344,15 @@ class ExampleLoader(QtGui.QMainWindow): def loadFile(self, edited=False): - extra = [] qtLib = str(self.ui.qtLibCombo.currentText()) - gfxSys = str(self.ui.graphicsSystemCombo.currentText()) + env = None if qtLib != 'default': - extra.append(qtLib.lower()) - elif gfxSys != 'default': - extra.append(gfxSys) + env = dict(os.environ, PYQTGRAPH_QT_LIB=qtLib) if edited: path = os.path.abspath(os.path.dirname(__file__)) - proc = subprocess.Popen([sys.executable, '-'] + extra, stdin=subprocess.PIPE, cwd=path) + proc = subprocess.Popen([sys.executable, '-'], stdin=subprocess.PIPE, cwd=path, env=env) code = str(self.ui.codeView.toPlainText()).encode('UTF-8') proc.stdin.write(code) proc.stdin.close() @@ -364,9 +361,14 @@ class ExampleLoader(QtGui.QMainWindow): if fn is None: return if sys.platform.startswith('win'): - os.spawnl(os.P_NOWAIT, sys.executable, '"'+sys.executable+'"', '"' + fn + '"', *extra) + args = [os.P_NOWAIT, sys.executable, '"'+sys.executable+'"', '"' + fn + '"'] else: - os.spawnl(os.P_NOWAIT, sys.executable, sys.executable, fn, *extra) + args = [os.P_NOWAIT, sys.executable, sys.executable, fn] + if env is None: + os.spawnl(*args) + else: + args.append(env) + os.spawnle(*args) def showFile(self): fn = self.currentFile() diff --git a/examples/VideoSpeedTest.py b/examples/VideoSpeedTest.py index d7ae7ed7..ecae3b30 100644 --- a/examples/VideoSpeedTest.py +++ b/examples/VideoSpeedTest.py @@ -6,6 +6,9 @@ it is being scaled and/or converted by lookup table, and whether OpenGL is used by the view widget """ +## Add path to library (just for examples; you do not need this) +import initExample + import argparse import sys diff --git a/examples/initExample.py b/examples/initExample.py index 97f46108..9b868803 100644 --- a/examples/initExample.py +++ b/examples/initExample.py @@ -20,25 +20,8 @@ if not hasattr(sys, 'frozen'): sys.path.remove(p) sys.path.insert(0, p) -## should force example to use PySide instead of PyQt -for module in ['PyQt5', 'PySide2', 'PySide6', 'PyQt6']: - if module.lower() in sys.argv: - QtGui = importlib.import_module(module + '.QtGui') - break -else: - from pyqtgraph.Qt import QtGui - import pyqtgraph as pg - -## Force use of a specific graphics system -use_gs = 'default' -for gs in ['raster', 'native', 'opengl']: - if gs in sys.argv: - use_gs = gs - QtGui.QApplication.setGraphicsSystem(gs) - break - -print("Using %s (%s graphics system)" % (pg.Qt.QT_LIB, use_gs)) +print("Using", pg.Qt.QT_LIB) ## Enable fault handling to give more helpful error messages on crash. ## Only available in python 3.3+ From 61616ffad943221ab42c52bff3ce55a31c3f229a Mon Sep 17 00:00:00 2001 From: KIU Shueng Chuan Date: Mon, 22 Feb 2021 18:23:01 +0800 Subject: [PATCH 2/5] remove calls to setGraphicsSystem in fact all are no-ops --- examples/PlotAutoRange.py | 1 - examples/PlotWidget.py | 1 - examples/Plotting.py | 1 - examples/VideoSpeedTest.py | 1 - examples/linkedViews.py | 1 - examples/test_examples.py | 8 ++------ pyqtgraph/__init__.py | 4 +--- 7 files changed, 3 insertions(+), 14 deletions(-) diff --git a/examples/PlotAutoRange.py b/examples/PlotAutoRange.py index 35ff72b6..a15f2e3f 100644 --- a/examples/PlotAutoRange.py +++ b/examples/PlotAutoRange.py @@ -11,7 +11,6 @@ from pyqtgraph.Qt import QtGui, QtCore import numpy as np import pyqtgraph as pg -#QtGui.QApplication.setGraphicsSystem('raster') app = pg.mkQApp("Plot Auto Range Example") #mw = QtGui.QMainWindow() #mw.resize(800,800) diff --git a/examples/PlotWidget.py b/examples/PlotWidget.py index 38bbc73c..a3f77b6d 100644 --- a/examples/PlotWidget.py +++ b/examples/PlotWidget.py @@ -12,7 +12,6 @@ from pyqtgraph.Qt import QtGui, QtCore import numpy as np import pyqtgraph as pg -#QtGui.QApplication.setGraphicsSystem('raster') app = pg.mkQApp() mw = QtGui.QMainWindow() mw.setWindowTitle('pyqtgraph example: PlotWidget') diff --git a/examples/Plotting.py b/examples/Plotting.py index c3cf8b37..c3831c0a 100644 --- a/examples/Plotting.py +++ b/examples/Plotting.py @@ -12,7 +12,6 @@ from pyqtgraph.Qt import QtGui, QtCore import numpy as np import pyqtgraph as pg -#QtGui.QApplication.setGraphicsSystem('raster') app = pg.mkQApp("Plotting Example") #mw = QtGui.QMainWindow() #mw.resize(800,800) diff --git a/examples/VideoSpeedTest.py b/examples/VideoSpeedTest.py index ecae3b30..a6c20cb7 100644 --- a/examples/VideoSpeedTest.py +++ b/examples/VideoSpeedTest.py @@ -40,7 +40,6 @@ parser.add_argument('--lut-alpha', default=False, action='store_true', help="Use parser.add_argument('--size', default='512x512', type=lambda s: tuple([int(x) for x in s.split('x')]), help="WxH image dimensions default='512x512'") args = parser.parse_args(sys.argv[1:]) -#QtGui.QApplication.setGraphicsSystem('raster') app = pg.mkQApp("Video Speed Test Example") win = QtGui.QMainWindow() diff --git a/examples/linkedViews.py b/examples/linkedViews.py index 49d68b6e..0a387ddf 100644 --- a/examples/linkedViews.py +++ b/examples/linkedViews.py @@ -12,7 +12,6 @@ from pyqtgraph.Qt import QtGui, QtCore import numpy as np import pyqtgraph as pg -#QtGui.QApplication.setGraphicsSystem('raster') app = pg.mkQApp("Linked Views Example") #mw = QtGui.QMainWindow() #mw.resize(800,800) diff --git a/examples/test_examples.py b/examples/test_examples.py index 2a1c450a..ba1037ad 100644 --- a/examples/test_examples.py +++ b/examples/test_examples.py @@ -199,7 +199,7 @@ conditionalExamples = { ) ] ) -def testExamples(frontend, f, graphicsSystem=None): +def testExamples(frontend, f): # runExampleFile(f[0], f[1], sys.executable, frontend) name, file = f @@ -210,15 +210,11 @@ def testExamples(frontend, f, graphicsSystem=None): sys.stdout.flush() import1 = "import %s" % frontend if frontend != '' else '' import2 = os.path.splitext(os.path.split(fn)[1])[0] - graphicsSystem = ( - '' if graphicsSystem is None else "pg.QtGui.QApplication.setGraphicsSystem('%s')" % graphicsSystem - ) code = """ try: %s import initExample import pyqtgraph as pg - %s import %s import sys print("test complete") @@ -231,7 +227,7 @@ except: print("test failed") raise -""" % (import1, graphicsSystem, import2) +""" % (import1, import2) if sys.platform.startswith('win'): process = subprocess.Popen([sys.executable], stdin=subprocess.PIPE, diff --git a/pyqtgraph/__init__.py b/pyqtgraph/__init__.py index 49b918d9..71a8662c 100644 --- a/pyqtgraph/__init__.py +++ b/pyqtgraph/__init__.py @@ -37,9 +37,7 @@ if 'linux' in sys.platform: ## linux has numerous bugs in opengl implementation elif 'darwin' in sys.platform: ## openGL can have a major impact on mac, but also has serious bugs useOpenGL = False if QtGui.QApplication.instance() is not None: - print('Warning: QApplication was created before pyqtgraph was imported; there may be problems (to avoid bugs, call QApplication.setGraphicsSystem("raster") before the QApplication is created).') - if QtGui.QApplication.setGraphicsSystem: - QtGui.QApplication.setGraphicsSystem('raster') ## work around a variety of bugs in the native graphics system + print('Warning: QApplication was created before pyqtgraph was imported; there may be problems.') else: useOpenGL = False ## on windows there's a more even performance / bugginess tradeoff. From a657dea0842a25ba8af6c73a67f2ea312f410424 Mon Sep 17 00:00:00 2001 From: KIU Shueng Chuan Date: Mon, 22 Feb 2021 18:42:59 +0800 Subject: [PATCH 3/5] remove graphics system combobox --- examples/exampleLoaderTemplate.ui | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/examples/exampleLoaderTemplate.ui b/examples/exampleLoaderTemplate.ui index 9d60ad4a..67a725ea 100644 --- a/examples/exampleLoaderTemplate.ui +++ b/examples/exampleLoaderTemplate.ui @@ -33,30 +33,6 @@ - - - - - default - - - - - native - - - - - raster - - - - - opengl - - - - @@ -86,13 +62,6 @@ - - - - Graphics System: - - - From fbd1e89950c7ef222ac0737f2e8e7c9da6787542 Mon Sep 17 00:00:00 2001 From: KIU Shueng Chuan Date: Mon, 22 Feb 2021 18:43:27 +0800 Subject: [PATCH 4/5] regenerate templates --- examples/exampleLoaderTemplate_pyqt5.py | 20 +-- examples/exampleLoaderTemplate_pyqt6.py | 17 +-- examples/exampleLoaderTemplate_pyside2.py | 146 ++++++++-------------- examples/exampleLoaderTemplate_pyside6.py | 20 --- 4 files changed, 53 insertions(+), 150 deletions(-) diff --git a/examples/exampleLoaderTemplate_pyqt5.py b/examples/exampleLoaderTemplate_pyqt5.py index 22c0d2c4..c39b55ab 100644 --- a/examples/exampleLoaderTemplate_pyqt5.py +++ b/examples/exampleLoaderTemplate_pyqt5.py @@ -2,10 +2,9 @@ # Form implementation generated from reading ui file 'exampleLoaderTemplate.ui' # -# Created by: PyQt5 UI code generator 5.15.2 +# Created by: PyQt5 UI code generator 5.12.3 # -# WARNING: Any manual changes made to this file will be lost when pyuic5 is -# run again. Do not edit this file unless you know what you are doing. +# WARNING! All changes made in this file will be lost! from PyQt5 import QtCore, QtGui, QtWidgets @@ -30,13 +29,6 @@ class Ui_Form(object): self.exampleTree.headerItem().setText(0, "1") self.exampleTree.header().setVisible(False) self.gridLayout.addWidget(self.exampleTree, 0, 0, 1, 2) - self.graphicsSystemCombo = QtWidgets.QComboBox(self.widget) - self.graphicsSystemCombo.setObjectName("graphicsSystemCombo") - self.graphicsSystemCombo.addItem("") - self.graphicsSystemCombo.addItem("") - self.graphicsSystemCombo.addItem("") - self.graphicsSystemCombo.addItem("") - self.gridLayout.addWidget(self.graphicsSystemCombo, 2, 1, 1, 1) self.qtLibCombo = QtWidgets.QComboBox(self.widget) self.qtLibCombo.setObjectName("qtLibCombo") self.qtLibCombo.addItem("") @@ -45,9 +37,6 @@ class Ui_Form(object): self.qtLibCombo.addItem("") self.qtLibCombo.addItem("") self.gridLayout.addWidget(self.qtLibCombo, 1, 1, 1, 1) - self.label_2 = QtWidgets.QLabel(self.widget) - self.label_2.setObjectName("label_2") - self.gridLayout.addWidget(self.label_2, 2, 0, 1, 1) self.label = QtWidgets.QLabel(self.widget) self.label.setObjectName("label") self.gridLayout.addWidget(self.label, 1, 0, 1, 1) @@ -81,15 +70,10 @@ class Ui_Form(object): def retranslateUi(self, Form): _translate = QtCore.QCoreApplication.translate Form.setWindowTitle(_translate("Form", "PyQtGraph")) - self.graphicsSystemCombo.setItemText(0, _translate("Form", "default")) - self.graphicsSystemCombo.setItemText(1, _translate("Form", "native")) - self.graphicsSystemCombo.setItemText(2, _translate("Form", "raster")) - self.graphicsSystemCombo.setItemText(3, _translate("Form", "opengl")) self.qtLibCombo.setItemText(0, _translate("Form", "default")) self.qtLibCombo.setItemText(1, _translate("Form", "PyQt5")) self.qtLibCombo.setItemText(2, _translate("Form", "PySide2")) self.qtLibCombo.setItemText(3, _translate("Form", "PySide6")) self.qtLibCombo.setItemText(4, _translate("Form", "PyQt6")) - self.label_2.setText(_translate("Form", "Graphics System:")) self.label.setText(_translate("Form", "Qt Library:")) self.loadBtn.setText(_translate("Form", "Run Example")) diff --git a/examples/exampleLoaderTemplate_pyqt6.py b/examples/exampleLoaderTemplate_pyqt6.py index f0b38e53..46ea2947 100644 --- a/examples/exampleLoaderTemplate_pyqt6.py +++ b/examples/exampleLoaderTemplate_pyqt6.py @@ -1,6 +1,6 @@ # Form implementation generated from reading ui file 'exampleLoaderTemplate.ui' # -# Created by: PyQt6 UI code generator 6.0.0 +# Created by: PyQt6 UI code generator 6.0.1 # # WARNING: Any manual changes made to this file will be lost when pyuic6 is # run again. Do not edit this file unless you know what you are doing. @@ -28,13 +28,6 @@ class Ui_Form(object): self.exampleTree.headerItem().setText(0, "1") self.exampleTree.header().setVisible(False) self.gridLayout.addWidget(self.exampleTree, 0, 0, 1, 2) - self.graphicsSystemCombo = QtWidgets.QComboBox(self.widget) - self.graphicsSystemCombo.setObjectName("graphicsSystemCombo") - self.graphicsSystemCombo.addItem("") - self.graphicsSystemCombo.addItem("") - self.graphicsSystemCombo.addItem("") - self.graphicsSystemCombo.addItem("") - self.gridLayout.addWidget(self.graphicsSystemCombo, 2, 1, 1, 1) self.qtLibCombo = QtWidgets.QComboBox(self.widget) self.qtLibCombo.setObjectName("qtLibCombo") self.qtLibCombo.addItem("") @@ -43,9 +36,6 @@ class Ui_Form(object): self.qtLibCombo.addItem("") self.qtLibCombo.addItem("") self.gridLayout.addWidget(self.qtLibCombo, 1, 1, 1, 1) - self.label_2 = QtWidgets.QLabel(self.widget) - self.label_2.setObjectName("label_2") - self.gridLayout.addWidget(self.label_2, 2, 0, 1, 1) self.label = QtWidgets.QLabel(self.widget) self.label.setObjectName("label") self.gridLayout.addWidget(self.label, 1, 0, 1, 1) @@ -79,15 +69,10 @@ class Ui_Form(object): def retranslateUi(self, Form): _translate = QtCore.QCoreApplication.translate Form.setWindowTitle(_translate("Form", "PyQtGraph")) - self.graphicsSystemCombo.setItemText(0, _translate("Form", "default")) - self.graphicsSystemCombo.setItemText(1, _translate("Form", "native")) - self.graphicsSystemCombo.setItemText(2, _translate("Form", "raster")) - self.graphicsSystemCombo.setItemText(3, _translate("Form", "opengl")) self.qtLibCombo.setItemText(0, _translate("Form", "default")) self.qtLibCombo.setItemText(1, _translate("Form", "PyQt5")) self.qtLibCombo.setItemText(2, _translate("Form", "PySide2")) self.qtLibCombo.setItemText(3, _translate("Form", "PySide6")) self.qtLibCombo.setItemText(4, _translate("Form", "PyQt6")) - self.label_2.setText(_translate("Form", "Graphics System:")) self.label.setText(_translate("Form", "Qt Library:")) self.loadBtn.setText(_translate("Form", "Run Example")) diff --git a/examples/exampleLoaderTemplate_pyside2.py b/examples/exampleLoaderTemplate_pyside2.py index a3880681..ac803862 100644 --- a/examples/exampleLoaderTemplate_pyside2.py +++ b/examples/exampleLoaderTemplate_pyside2.py @@ -1,125 +1,79 @@ # -*- coding: utf-8 -*- -################################################################################ -## Form generated from reading UI file 'exampleLoaderTemplate.ui' -## -## Created by: Qt User Interface Compiler version 5.15.2 -## -## WARNING! All changes made in this file will be lost when recompiling UI file! -################################################################################ - -from PySide2.QtCore import * -from PySide2.QtGui import * -from PySide2.QtWidgets import * +# Form implementation generated from reading ui file 'exampleLoaderTemplate.ui', +# licensing of 'exampleLoaderTemplate.ui' applies. +# +# Created: Mon Feb 22 18:33:36 2021 +# by: pyside2-uic running on PySide2 5.12.6 +# +# WARNING! All changes made in this file will be lost! +from PySide2 import QtCore, QtGui, QtWidgets class Ui_Form(object): def setupUi(self, Form): - if not Form.objectName(): - Form.setObjectName(u"Form") + Form.setObjectName("Form") Form.resize(846, 552) - self.gridLayout_2 = QGridLayout(Form) - self.gridLayout_2.setObjectName(u"gridLayout_2") - self.splitter = QSplitter(Form) - self.splitter.setObjectName(u"splitter") - self.splitter.setOrientation(Qt.Horizontal) - self.widget = QWidget(self.splitter) - self.widget.setObjectName(u"widget") - self.gridLayout = QGridLayout(self.widget) - self.gridLayout.setObjectName(u"gridLayout") + self.gridLayout_2 = QtWidgets.QGridLayout(Form) + self.gridLayout_2.setObjectName("gridLayout_2") + self.splitter = QtWidgets.QSplitter(Form) + self.splitter.setOrientation(QtCore.Qt.Horizontal) + self.splitter.setObjectName("splitter") + self.widget = QtWidgets.QWidget(self.splitter) + self.widget.setObjectName("widget") + self.gridLayout = QtWidgets.QGridLayout(self.widget) self.gridLayout.setContentsMargins(0, 0, 0, 0) - self.exampleTree = QTreeWidget(self.widget) - __qtreewidgetitem = QTreeWidgetItem() - __qtreewidgetitem.setText(0, u"1"); - self.exampleTree.setHeaderItem(__qtreewidgetitem) - self.exampleTree.setObjectName(u"exampleTree") + self.gridLayout.setObjectName("gridLayout") + self.exampleTree = QtWidgets.QTreeWidget(self.widget) + self.exampleTree.setObjectName("exampleTree") + self.exampleTree.headerItem().setText(0, "1") self.exampleTree.header().setVisible(False) - self.gridLayout.addWidget(self.exampleTree, 0, 0, 1, 2) - - self.graphicsSystemCombo = QComboBox(self.widget) - self.graphicsSystemCombo.addItem("") - self.graphicsSystemCombo.addItem("") - self.graphicsSystemCombo.addItem("") - self.graphicsSystemCombo.addItem("") - self.graphicsSystemCombo.setObjectName(u"graphicsSystemCombo") - - self.gridLayout.addWidget(self.graphicsSystemCombo, 2, 1, 1, 1) - - self.qtLibCombo = QComboBox(self.widget) + self.qtLibCombo = QtWidgets.QComboBox(self.widget) + self.qtLibCombo.setObjectName("qtLibCombo") self.qtLibCombo.addItem("") self.qtLibCombo.addItem("") self.qtLibCombo.addItem("") self.qtLibCombo.addItem("") self.qtLibCombo.addItem("") - self.qtLibCombo.setObjectName(u"qtLibCombo") - self.gridLayout.addWidget(self.qtLibCombo, 1, 1, 1, 1) - - self.label_2 = QLabel(self.widget) - self.label_2.setObjectName(u"label_2") - - self.gridLayout.addWidget(self.label_2, 2, 0, 1, 1) - - self.label = QLabel(self.widget) - self.label.setObjectName(u"label") - + self.label = QtWidgets.QLabel(self.widget) + self.label.setObjectName("label") self.gridLayout.addWidget(self.label, 1, 0, 1, 1) - - self.loadBtn = QPushButton(self.widget) - self.loadBtn.setObjectName(u"loadBtn") - + self.loadBtn = QtWidgets.QPushButton(self.widget) + self.loadBtn.setObjectName("loadBtn") self.gridLayout.addWidget(self.loadBtn, 3, 1, 1, 1) - - self.splitter.addWidget(self.widget) - self.widget1 = QWidget(self.splitter) - self.widget1.setObjectName(u"widget1") - self.verticalLayout = QVBoxLayout(self.widget1) - self.verticalLayout.setObjectName(u"verticalLayout") + self.widget1 = QtWidgets.QWidget(self.splitter) + self.widget1.setObjectName("widget1") + self.verticalLayout = QtWidgets.QVBoxLayout(self.widget1) self.verticalLayout.setContentsMargins(0, 0, 0, 0) - self.loadedFileLabel = QLabel(self.widget1) - self.loadedFileLabel.setObjectName(u"loadedFileLabel") - font = QFont() + self.verticalLayout.setObjectName("verticalLayout") + self.loadedFileLabel = QtWidgets.QLabel(self.widget1) + font = QtGui.QFont() font.setBold(True) self.loadedFileLabel.setFont(font) - self.loadedFileLabel.setAlignment(Qt.AlignCenter) - + self.loadedFileLabel.setText("") + self.loadedFileLabel.setAlignment(QtCore.Qt.AlignCenter) + self.loadedFileLabel.setObjectName("loadedFileLabel") self.verticalLayout.addWidget(self.loadedFileLabel) - - self.codeView = QPlainTextEdit(self.widget1) - self.codeView.setObjectName(u"codeView") - font1 = QFont() - font1.setFamily(u"Courier New") - self.codeView.setFont(font1) - + self.codeView = QtWidgets.QPlainTextEdit(self.widget1) + font = QtGui.QFont() + font.setFamily("Courier New") + self.codeView.setFont(font) + self.codeView.setObjectName("codeView") self.verticalLayout.addWidget(self.codeView) - - self.splitter.addWidget(self.widget1) - self.gridLayout_2.addWidget(self.splitter, 0, 0, 1, 1) - self.retranslateUi(Form) - - QMetaObject.connectSlotsByName(Form) - # setupUi + QtCore.QMetaObject.connectSlotsByName(Form) def retranslateUi(self, Form): - Form.setWindowTitle(QCoreApplication.translate("Form", u"PyQtGraph", None)) - self.graphicsSystemCombo.setItemText(0, QCoreApplication.translate("Form", u"default", None)) - self.graphicsSystemCombo.setItemText(1, QCoreApplication.translate("Form", u"native", None)) - self.graphicsSystemCombo.setItemText(2, QCoreApplication.translate("Form", u"raster", None)) - self.graphicsSystemCombo.setItemText(3, QCoreApplication.translate("Form", u"opengl", None)) - - self.qtLibCombo.setItemText(0, QCoreApplication.translate("Form", u"default", None)) - self.qtLibCombo.setItemText(1, QCoreApplication.translate("Form", u"PyQt5", None)) - self.qtLibCombo.setItemText(2, QCoreApplication.translate("Form", u"PySide2", None)) - self.qtLibCombo.setItemText(3, QCoreApplication.translate("Form", u"PySide6", None)) - self.qtLibCombo.setItemText(4, QCoreApplication.translate("Form", u"PyQt6", None)) - - self.label_2.setText(QCoreApplication.translate("Form", u"Graphics System:", None)) - self.label.setText(QCoreApplication.translate("Form", u"Qt Library:", None)) - self.loadBtn.setText(QCoreApplication.translate("Form", u"Run Example", None)) - self.loadedFileLabel.setText("") - # retranslateUi + Form.setWindowTitle(QtWidgets.QApplication.translate("Form", "PyQtGraph", None, -1)) + self.qtLibCombo.setItemText(0, QtWidgets.QApplication.translate("Form", "default", None, -1)) + self.qtLibCombo.setItemText(1, QtWidgets.QApplication.translate("Form", "PyQt5", None, -1)) + self.qtLibCombo.setItemText(2, QtWidgets.QApplication.translate("Form", "PySide2", None, -1)) + self.qtLibCombo.setItemText(3, QtWidgets.QApplication.translate("Form", "PySide6", None, -1)) + self.qtLibCombo.setItemText(4, QtWidgets.QApplication.translate("Form", "PyQt6", None, -1)) + self.label.setText(QtWidgets.QApplication.translate("Form", "Qt Library:", None, -1)) + self.loadBtn.setText(QtWidgets.QApplication.translate("Form", "Run Example", None, -1)) diff --git a/examples/exampleLoaderTemplate_pyside6.py b/examples/exampleLoaderTemplate_pyside6.py index 5a24c659..2087abb4 100644 --- a/examples/exampleLoaderTemplate_pyside6.py +++ b/examples/exampleLoaderTemplate_pyside6.py @@ -37,15 +37,6 @@ class Ui_Form(object): self.gridLayout.addWidget(self.exampleTree, 0, 0, 1, 2) - self.graphicsSystemCombo = QComboBox(self.widget) - self.graphicsSystemCombo.addItem("") - self.graphicsSystemCombo.addItem("") - self.graphicsSystemCombo.addItem("") - self.graphicsSystemCombo.addItem("") - self.graphicsSystemCombo.setObjectName(u"graphicsSystemCombo") - - self.gridLayout.addWidget(self.graphicsSystemCombo, 2, 1, 1, 1) - self.qtLibCombo = QComboBox(self.widget) self.qtLibCombo.addItem("") self.qtLibCombo.addItem("") @@ -56,11 +47,6 @@ class Ui_Form(object): self.gridLayout.addWidget(self.qtLibCombo, 1, 1, 1, 1) - self.label_2 = QLabel(self.widget) - self.label_2.setObjectName(u"label_2") - - self.gridLayout.addWidget(self.label_2, 2, 0, 1, 1) - self.label = QLabel(self.widget) self.label.setObjectName(u"label") @@ -106,18 +92,12 @@ class Ui_Form(object): def retranslateUi(self, Form): Form.setWindowTitle(QCoreApplication.translate("Form", u"PyQtGraph", None)) - self.graphicsSystemCombo.setItemText(0, QCoreApplication.translate("Form", u"default", None)) - self.graphicsSystemCombo.setItemText(1, QCoreApplication.translate("Form", u"native", None)) - self.graphicsSystemCombo.setItemText(2, QCoreApplication.translate("Form", u"raster", None)) - self.graphicsSystemCombo.setItemText(3, QCoreApplication.translate("Form", u"opengl", None)) - self.qtLibCombo.setItemText(0, QCoreApplication.translate("Form", u"default", None)) self.qtLibCombo.setItemText(1, QCoreApplication.translate("Form", u"PyQt5", None)) self.qtLibCombo.setItemText(2, QCoreApplication.translate("Form", u"PySide2", None)) self.qtLibCombo.setItemText(3, QCoreApplication.translate("Form", u"PySide6", None)) self.qtLibCombo.setItemText(4, QCoreApplication.translate("Form", u"PyQt6", None)) - self.label_2.setText(QCoreApplication.translate("Form", u"Graphics System:", None)) self.label.setText(QCoreApplication.translate("Form", u"Qt Library:", None)) self.loadBtn.setText(QCoreApplication.translate("Form", u"Run Example", None)) self.loadedFileLabel.setText("") From d8e826e37903d79834f7f2680d5bda6e4083f7d1 Mon Sep 17 00:00:00 2001 From: KIU Shueng Chuan Date: Mon, 22 Feb 2021 16:13:53 +0800 Subject: [PATCH 5/5] disable opengl vsync for benchmarking --- examples/VideoSpeedTest.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/examples/VideoSpeedTest.py b/examples/VideoSpeedTest.py index a6c20cb7..c8c05d8e 100644 --- a/examples/VideoSpeedTest.py +++ b/examples/VideoSpeedTest.py @@ -29,6 +29,11 @@ except ImportError: cp = None _has_cupy = False +try: + from pyqtgraph.widgets.RawImageWidget import RawImageGLWidget +except ImportError: + RawImageGLWidget = None + parser = argparse.ArgumentParser(description="Benchmark for testing video performance") parser.add_argument('--cuda', default=False, action='store_true', help="Use CUDA to process on the GPU", dest="cuda") parser.add_argument('--dtype', default='uint8', choices=['uint8', 'uint16', 'float'], help="Image dtype (uint8, uint16, or float)") @@ -40,6 +45,12 @@ parser.add_argument('--lut-alpha', default=False, action='store_true', help="Use parser.add_argument('--size', default='512x512', type=lambda s: tuple([int(x) for x in s.split('x')]), help="WxH image dimensions default='512x512'") args = parser.parse_args(sys.argv[1:]) +if RawImageGLWidget is not None: + # don't limit frame rate to vsync + sfmt = QtGui.QSurfaceFormat() + sfmt.setSwapInterval(0) + QtGui.QSurfaceFormat.setDefaultFormat(sfmt) + app = pg.mkQApp("Video Speed Test Example") win = QtGui.QMainWindow() @@ -48,10 +59,7 @@ ui = ui_template.Ui_MainWindow() ui.setupUi(win) win.show() -try: - from pyqtgraph.widgets.RawImageWidget import RawImageGLWidget -except ImportError: - RawImageGLWidget = None +if RawImageGLWidget is None: ui.rawGLRadio.setEnabled(False) ui.rawGLRadio.setText(ui.rawGLRadio.text() + " (OpenGL not available)") else: