From 42dbd7956a769b37e76a905c324c3b5453e5b7f3 Mon Sep 17 00:00:00 2001 From: Martin Fitzpatrick Date: Fri, 14 Feb 2014 10:29:33 +0100 Subject: [PATCH 01/11] Adding PyQt5 compatibility (broken) Adding compatibility for PyQt5 via a shim in Qt.py. This restructures the PyQt5 libraries to match the layout seen in PyQt4, allowing it to continue to be used as drop in replacement. This works up to the point of importing, however other API changes are broken - for example the deprectation of .scale() on GraphicsItems throws an error currently. --- pyqtgraph/Qt.py | 65 +++++++++++++++---- pyqtgraph/__init__.py | 3 +- .../PlotItem/plotConfigTemplate_pyqt.py | 2 +- .../ViewBox/axisCtrlTemplate_pyqt.py | 2 +- pyqtgraph/imageview/ImageViewTemplate_pyqt.py | 2 +- 5 files changed, 58 insertions(+), 16 deletions(-) diff --git a/pyqtgraph/Qt.py b/pyqtgraph/Qt.py index 410bfd83..4c15f670 100644 --- a/pyqtgraph/Qt.py +++ b/pyqtgraph/Qt.py @@ -11,25 +11,40 @@ This module exists to smooth out some of the differences between PySide and PyQt import sys, re +PYSIDE = 0 +PYQT4 = 1 +PYQT5 = 2 + +USE_QT_PY = None + ## Automatically determine whether to use PyQt or PySide. ## This is done by first checking to see whether one of the libraries ## is already imported. If not, then attempt to import PyQt4, then PySide. if 'PyQt4' in sys.modules: - USE_PYSIDE = False + USE_QT_PY = PYQT4 +if 'PyQt5' in sys.modules: + USE_QT_PY = PYQT5 elif 'PySide' in sys.modules: - USE_PYSIDE = True + USE_QT_PY = PYSIDE else: try: import PyQt4 - USE_PYSIDE = False + USE_QT_PY = PYQT4 except ImportError: try: - import PySide - USE_PYSIDE = True + import PyQt5 + USE_QT_PY = PYQT5 except ImportError: - raise Exception("PyQtGraph requires either PyQt4 or PySide; neither package could be imported.") + try: + import PySide + USE_QT_PY = PYSIDE + except: + pass -if USE_PYSIDE: +if USE_QT_PY == None: + raise Exception("PyQtGraph requires one of PyQt4, PyQt5 or PySide; none of these packages could be imported.") + +if USE_QT_PY == PYSIDE: from PySide import QtGui, QtCore, QtOpenGL, QtSvg import PySide VERSION_INFO = 'PySide ' + PySide.__version__ @@ -64,9 +79,9 @@ if USE_PYSIDE: base_class = eval('QtGui.%s'%widget_class) return form_class, base_class - - -else: + +elif USE_QT_PY == PYQT4: + from PyQt4 import QtGui, QtCore, uic try: from PyQt4 import QtSvg @@ -83,10 +98,36 @@ else: QtCore.Signal = QtCore.pyqtSignal VERSION_INFO = 'PyQt4 ' + QtCore.PYQT_VERSION_STR + ' Qt ' + QtCore.QT_VERSION_STR - +elif USE_QT_PY == PYQT5: + + # We're using PyQt5 which has a different structure so we're going to use a shim to + # recreate the Qt4 structure for Qt5 + from PyQt5 import QtGui, QtCore, QtWidgets, Qt, uic + try: + from PyQt5 import QtSvg + except ImportError: + pass + try: + from PyQt5 import QtOpenGL + except ImportError: + pass + + QtGui.QApplication = QtWidgets.QApplication + QtGui.QGraphicsScene = QtWidgets.QGraphicsScene + QtGui.QGraphicsObject = QtWidgets.QGraphicsObject + QtGui.QGraphicsWidget = QGraphicsWidget5 + QtGui.QApplication.setGraphicsSystem = None + QtCore.Signal = Qt.pyqtSignal + + # Import all QtWidgets objects into QtGui + for o in dir(QtWidgets): + if o.startswith('Q'): + setattr(QtGui, o, getattr(QtWidgets,o) ) + ## Make sure we have Qt >= 4.7 versionReq = [4, 7] -QtVersion = PySide.QtCore.__version__ if USE_PYSIDE else QtCore.QT_VERSION_STR +USE_PYSIDE = USE_QT_PY == PYSIDE # still needed internally elsewhere +QtVersion = PySide.QtCore.__version__ if USE_QT_PY == PYSIDE else QtCore.QT_VERSION_STR m = re.match(r'(\d+)\.(\d+).*', QtVersion) if m is not None and list(map(int, m.groups())) < versionReq: print(list(map(int, m.groups()))) diff --git a/pyqtgraph/__init__.py b/pyqtgraph/__init__.py index 588de0cd..f8951af7 100644 --- a/pyqtgraph/__init__.py +++ b/pyqtgraph/__init__.py @@ -41,7 +41,8 @@ elif 'darwin' in sys.platform: ## openGL can have a major impact on mac, but als 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).') - QtGui.QApplication.setGraphicsSystem('raster') ## work around a variety of bugs in the native graphics system + if QtGui.QApplication.setGraphicsSystem: + QtGui.QApplication.setGraphicsSystem('raster') ## work around a variety of bugs in the native graphics system else: useOpenGL = False ## on windows there's a more even performance / bugginess tradeoff. diff --git a/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate_pyqt.py b/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate_pyqt.py index e09c9978..a06519bf 100644 --- a/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate_pyqt.py +++ b/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate_pyqt.py @@ -7,7 +7,7 @@ # # WARNING! All changes made in this file will be lost! -from PyQt4 import QtCore, QtGui +from ...Qt import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 diff --git a/pyqtgraph/graphicsItems/ViewBox/axisCtrlTemplate_pyqt.py b/pyqtgraph/graphicsItems/ViewBox/axisCtrlTemplate_pyqt.py index d8ef1925..5d952741 100644 --- a/pyqtgraph/graphicsItems/ViewBox/axisCtrlTemplate_pyqt.py +++ b/pyqtgraph/graphicsItems/ViewBox/axisCtrlTemplate_pyqt.py @@ -7,7 +7,7 @@ # # WARNING! All changes made in this file will be lost! -from PyQt4 import QtCore, QtGui +from ...Qt import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 diff --git a/pyqtgraph/imageview/ImageViewTemplate_pyqt.py b/pyqtgraph/imageview/ImageViewTemplate_pyqt.py index 78156317..18b68e96 100644 --- a/pyqtgraph/imageview/ImageViewTemplate_pyqt.py +++ b/pyqtgraph/imageview/ImageViewTemplate_pyqt.py @@ -7,7 +7,7 @@ # # WARNING! All changes made in this file will be lost! -from PyQt4 import QtCore, QtGui +from ..Qt import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 From b244805bde2775742952562069749361479e257e Mon Sep 17 00:00:00 2001 From: Martin Fitzpatrick Date: Fri, 14 Feb 2014 10:57:05 +0100 Subject: [PATCH 02/11] Basic plot function works. --- pyqtgraph/Qt.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/pyqtgraph/Qt.py b/pyqtgraph/Qt.py index 4c15f670..5d137fb8 100644 --- a/pyqtgraph/Qt.py +++ b/pyqtgraph/Qt.py @@ -111,11 +111,26 @@ elif USE_QT_PY == PYQT5: from PyQt5 import QtOpenGL except ImportError: pass + + # Re-implement deprecated APIs + def scale(self, sx, sy): + self.setTransform(QtGui.QTransform.fromScale(sx, sy), True) + QtWidgets.QGraphicsItem.scale = scale + + def rotate(self, angle): + self.setRotation(self.rotation() + angle) + QtWidgets.QGraphicsItem.rotate = rotate + + + def setMargin(self, i): + self.setContentsMargins( i, i, i, i) + QtWidgets.QGridLayout.setMargin = setMargin QtGui.QApplication = QtWidgets.QApplication QtGui.QGraphicsScene = QtWidgets.QGraphicsScene QtGui.QGraphicsObject = QtWidgets.QGraphicsObject - QtGui.QGraphicsWidget = QGraphicsWidget5 + QtGui.QGraphicsWidget = QtWidgets.QGraphicsWidget + QtGui.QApplication.setGraphicsSystem = None QtCore.Signal = Qt.pyqtSignal From e0c22e27965bd6b44d7e07a175561d0b4b8ef164 Mon Sep 17 00:00:00 2001 From: Martin Fitzpatrick Date: Fri, 14 Feb 2014 11:05:10 +0100 Subject: [PATCH 03/11] Adding some additional deprectated APIs for Qt5. Example plots (mostly) working. This adds some remaining APIs that were deprecated in Qt5. These are easy to do as they're all documented, e.g. http://qt-project.org/doc/qt-5.0/qtwidgets/qgraphicsitem-compat.html Tested with most of the examples. Although I can't be sure as I don't know what the 'correct' output is, they look like they work. Some issues with interaction e.g. on the color bar plot. --- pyqtgraph/Qt.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pyqtgraph/Qt.py b/pyqtgraph/Qt.py index 5d137fb8..b7a479b7 100644 --- a/pyqtgraph/Qt.py +++ b/pyqtgraph/Qt.py @@ -121,10 +121,18 @@ elif USE_QT_PY == PYQT5: self.setRotation(self.rotation() + angle) QtWidgets.QGraphicsItem.rotate = rotate + def translate(self, dx, dy): + self.setTransform(QtGui.QTransform.fromTranslate(dx, dy), True) + QtWidgets.QGraphicsItem.translate = translate def setMargin(self, i): - self.setContentsMargins( i, i, i, i) + self.setContentsMargins(i, i, i, i) QtWidgets.QGridLayout.setMargin = setMargin + + def setResizeMode(self, mode): + self.setSectionResizeMode(mode) + QtWidgets.QHeaderView.setResizeMode = setResizeMode + QtGui.QApplication = QtWidgets.QApplication QtGui.QGraphicsScene = QtWidgets.QGraphicsScene From 0bb300b7f274b4dc548c773bc0df43a8f7a7846e Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Sat, 29 Mar 2014 06:57:13 -0400 Subject: [PATCH 04/11] Generated qt5 template files --- examples/initExample.py | 2 + .../exportDialogTemplate_pyqt5.py | 64 +++++++ pyqtgraph/Qt.py | 78 ++++---- pyqtgraph/canvas/CanvasTemplate_pyqt5.py | 96 ++++++++++ .../canvas/TransformGuiTemplate_pyqt5.py | 56 ++++++ pyqtgraph/console/template_pyqt5.py | 107 +++++++++++ .../flowchart/FlowchartCtrlTemplate_pyqt5.py | 67 +++++++ .../flowchart/FlowchartTemplate_pyqt5.py | 55 ++++++ pyqtgraph/graphicsItems/PlotItem/PlotItem.py | 10 +- .../PlotItem/plotConfigTemplate_pyqt.py | 2 +- .../PlotItem/plotConfigTemplate_pyqt5.py | 169 ++++++++++++++++++ .../graphicsItems/ViewBox/ViewBoxMenu.py | 12 +- .../ViewBox/axisCtrlTemplate_pyqt5.py | 89 +++++++++ .../imageview/ImageViewTemplate_pyqt5.py | 156 ++++++++++++++++ tools/rebuildUi.py | 9 +- 15 files changed, 923 insertions(+), 49 deletions(-) create mode 100644 pyqtgraph/GraphicsScene/exportDialogTemplate_pyqt5.py create mode 100644 pyqtgraph/canvas/CanvasTemplate_pyqt5.py create mode 100644 pyqtgraph/canvas/TransformGuiTemplate_pyqt5.py create mode 100644 pyqtgraph/console/template_pyqt5.py create mode 100644 pyqtgraph/flowchart/FlowchartCtrlTemplate_pyqt5.py create mode 100644 pyqtgraph/flowchart/FlowchartTemplate_pyqt5.py create mode 100644 pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate_pyqt5.py create mode 100644 pyqtgraph/graphicsItems/ViewBox/axisCtrlTemplate_pyqt5.py create mode 100644 pyqtgraph/imageview/ImageViewTemplate_pyqt5.py diff --git a/examples/initExample.py b/examples/initExample.py index b61b55cc..3dcb5ba2 100644 --- a/examples/initExample.py +++ b/examples/initExample.py @@ -24,6 +24,8 @@ if 'pyside' in sys.argv: from PySide import QtGui elif 'pyqt' in sys.argv: from PyQt4 import QtGui +elif 'pyqt5' in sys.argv: + from PyQt5 import QtGui else: from pyqtgraph.Qt import QtGui diff --git a/pyqtgraph/GraphicsScene/exportDialogTemplate_pyqt5.py b/pyqtgraph/GraphicsScene/exportDialogTemplate_pyqt5.py new file mode 100644 index 00000000..418fd0f0 --- /dev/null +++ b/pyqtgraph/GraphicsScene/exportDialogTemplate_pyqt5.py @@ -0,0 +1,64 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file './pyqtgraph/GraphicsScene/exportDialogTemplate.ui' +# +# Created: Wed Mar 26 15:09:29 2014 +# by: PyQt5 UI code generator 5.0.1 +# +# WARNING! All changes made in this file will be lost! + +from PyQt5 import QtCore, QtGui, QtWidgets + +class Ui_Form(object): + def setupUi(self, Form): + Form.setObjectName("Form") + Form.resize(241, 367) + self.gridLayout = QtWidgets.QGridLayout(Form) + self.gridLayout.setSpacing(0) + self.gridLayout.setObjectName("gridLayout") + self.label = QtWidgets.QLabel(Form) + self.label.setObjectName("label") + self.gridLayout.addWidget(self.label, 0, 0, 1, 3) + self.itemTree = QtWidgets.QTreeWidget(Form) + self.itemTree.setObjectName("itemTree") + self.itemTree.headerItem().setText(0, "1") + self.itemTree.header().setVisible(False) + self.gridLayout.addWidget(self.itemTree, 1, 0, 1, 3) + self.label_2 = QtWidgets.QLabel(Form) + self.label_2.setObjectName("label_2") + self.gridLayout.addWidget(self.label_2, 2, 0, 1, 3) + self.formatList = QtWidgets.QListWidget(Form) + self.formatList.setObjectName("formatList") + self.gridLayout.addWidget(self.formatList, 3, 0, 1, 3) + self.exportBtn = QtWidgets.QPushButton(Form) + self.exportBtn.setObjectName("exportBtn") + self.gridLayout.addWidget(self.exportBtn, 6, 1, 1, 1) + self.closeBtn = QtWidgets.QPushButton(Form) + self.closeBtn.setObjectName("closeBtn") + self.gridLayout.addWidget(self.closeBtn, 6, 2, 1, 1) + self.paramTree = ParameterTree(Form) + self.paramTree.setObjectName("paramTree") + self.paramTree.headerItem().setText(0, "1") + self.paramTree.header().setVisible(False) + self.gridLayout.addWidget(self.paramTree, 5, 0, 1, 3) + self.label_3 = QtWidgets.QLabel(Form) + self.label_3.setObjectName("label_3") + self.gridLayout.addWidget(self.label_3, 4, 0, 1, 3) + self.copyBtn = QtWidgets.QPushButton(Form) + self.copyBtn.setObjectName("copyBtn") + self.gridLayout.addWidget(self.copyBtn, 6, 0, 1, 1) + + self.retranslateUi(Form) + QtCore.QMetaObject.connectSlotsByName(Form) + + def retranslateUi(self, Form): + _translate = QtCore.QCoreApplication.translate + Form.setWindowTitle(_translate("Form", "Export")) + self.label.setText(_translate("Form", "Item to export:")) + self.label_2.setText(_translate("Form", "Export format")) + self.exportBtn.setText(_translate("Form", "Export")) + self.closeBtn.setText(_translate("Form", "Close")) + self.label_3.setText(_translate("Form", "Export options")) + self.copyBtn.setText(_translate("Form", "Copy")) + +from ..parametertree import ParameterTree diff --git a/pyqtgraph/Qt.py b/pyqtgraph/Qt.py index a175f616..edae4d99 100644 --- a/pyqtgraph/Qt.py +++ b/pyqtgraph/Qt.py @@ -11,40 +11,37 @@ This module exists to smooth out some of the differences between PySide and PyQt import sys, re -PYSIDE = 0 -PYQT4 = 1 -PYQT5 = 2 +PYSIDE = 'PySide' +PYQT4 = 'PyQt4' +PYQT5 = 'PyQt5' -USE_QT_PY = None +QT_LIB = None ## Automatically determine whether to use PyQt or PySide. ## This is done by first checking to see whether one of the libraries ## is already imported. If not, then attempt to import PyQt4, then PySide. -if 'PyQt4' in sys.modules: - USE_QT_PY = PYQT4 -if 'PyQt5' in sys.modules: - USE_QT_PY = PYQT5 -elif 'PySide' in sys.modules: - USE_QT_PY = PYSIDE -else: - try: - import PyQt4 - USE_QT_PY = PYQT4 - except ImportError: - try: - import PyQt5 - USE_QT_PY = PYQT5 - except ImportError: - try: - import PySide - USE_QT_PY = PYSIDE - except: - pass +libOrder = [PYQT4, PYSIDE, PYQT5] -if USE_QT_PY == None: +for lib in libOrder: + if lib in sys.modules: + QT_LIB = lib + break + +if QT_LIB is None: + for lib in libOrder: + try: + __import__(lib) + QT_LIB = lib + break + except ImportError: + pass + +print(QT_LIB) + +if QT_LIB == None: raise Exception("PyQtGraph requires one of PyQt4, PyQt5 or PySide; none of these packages could be imported.") -if USE_QT_PY == PYSIDE: +if QT_LIB == PYSIDE: from PySide import QtGui, QtCore, QtOpenGL, QtSvg import PySide try: @@ -97,7 +94,7 @@ if USE_QT_PY == PYSIDE: return form_class, base_class -elif USE_QT_PY == PYQT4: +elif QT_LIB == PYQT4: from PyQt4 import QtGui, QtCore, uic try: @@ -109,16 +106,9 @@ elif USE_QT_PY == PYQT4: except ImportError: pass - - import sip - def isQObjectAlive(obj): - return not sip.isdeleted(obj) - loadUiType = uic.loadUiType - - QtCore.Signal = QtCore.pyqtSignal VERSION_INFO = 'PyQt4 ' + QtCore.PYQT_VERSION_STR + ' Qt ' + QtCore.QT_VERSION_STR -elif USE_QT_PY == PYQT5: +elif QT_LIB == PYQT5: # We're using PyQt5 which has a different structure so we're going to use a shim to # recreate the Qt4 structure for Qt5 @@ -160,17 +150,29 @@ elif USE_QT_PY == PYQT5: QtGui.QGraphicsWidget = QtWidgets.QGraphicsWidget QtGui.QApplication.setGraphicsSystem = None - QtCore.Signal = Qt.pyqtSignal # Import all QtWidgets objects into QtGui for o in dir(QtWidgets): if o.startswith('Q'): setattr(QtGui, o, getattr(QtWidgets,o) ) + VERSION_INFO = 'PyQt5 ' + QtCore.PYQT_VERSION_STR + ' Qt ' + QtCore.QT_VERSION_STR + +# Common to PyQt4 and 5 +if QT_LIB.startswith('PyQt'): + import sip + def isQObjectAlive(obj): + return not sip.isdeleted(obj) + loadUiType = uic.loadUiType + + QtCore.Signal = QtCore.pyqtSignal + + + ## Make sure we have Qt >= 4.7 versionReq = [4, 7] -USE_PYSIDE = USE_QT_PY == PYSIDE # still needed internally elsewhere -QtVersion = PySide.QtCore.__version__ if USE_QT_PY == PYSIDE else QtCore.QT_VERSION_STR +USE_PYSIDE = QT_LIB == PYSIDE # for backward compatibility +QtVersion = PySide.QtCore.__version__ if QT_LIB == PYSIDE else QtCore.QT_VERSION_STR m = re.match(r'(\d+)\.(\d+).*', QtVersion) if m is not None and list(map(int, m.groups())) < versionReq: print(list(map(int, m.groups()))) diff --git a/pyqtgraph/canvas/CanvasTemplate_pyqt5.py b/pyqtgraph/canvas/CanvasTemplate_pyqt5.py new file mode 100644 index 00000000..13b0c83c --- /dev/null +++ b/pyqtgraph/canvas/CanvasTemplate_pyqt5.py @@ -0,0 +1,96 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file './pyqtgraph/canvas/CanvasTemplate.ui' +# +# Created: Wed Mar 26 15:09:28 2014 +# by: PyQt5 UI code generator 5.0.1 +# +# WARNING! All changes made in this file will be lost! + +from PyQt5 import QtCore, QtGui, QtWidgets + +class Ui_Form(object): + def setupUi(self, Form): + Form.setObjectName("Form") + Form.resize(490, 414) + self.gridLayout = QtWidgets.QGridLayout(Form) + self.gridLayout.setContentsMargins(0, 0, 0, 0) + self.gridLayout.setSpacing(0) + self.gridLayout.setObjectName("gridLayout") + self.splitter = QtWidgets.QSplitter(Form) + self.splitter.setOrientation(QtCore.Qt.Horizontal) + self.splitter.setObjectName("splitter") + self.view = GraphicsView(self.splitter) + self.view.setObjectName("view") + self.layoutWidget = QtWidgets.QWidget(self.splitter) + self.layoutWidget.setObjectName("layoutWidget") + self.gridLayout_2 = QtWidgets.QGridLayout(self.layoutWidget) + self.gridLayout_2.setContentsMargins(0, 0, 0, 0) + self.gridLayout_2.setObjectName("gridLayout_2") + self.storeSvgBtn = QtWidgets.QPushButton(self.layoutWidget) + self.storeSvgBtn.setObjectName("storeSvgBtn") + self.gridLayout_2.addWidget(self.storeSvgBtn, 1, 0, 1, 1) + self.storePngBtn = QtWidgets.QPushButton(self.layoutWidget) + self.storePngBtn.setObjectName("storePngBtn") + self.gridLayout_2.addWidget(self.storePngBtn, 1, 1, 1, 1) + self.autoRangeBtn = QtWidgets.QPushButton(self.layoutWidget) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(1) + sizePolicy.setHeightForWidth(self.autoRangeBtn.sizePolicy().hasHeightForWidth()) + self.autoRangeBtn.setSizePolicy(sizePolicy) + self.autoRangeBtn.setObjectName("autoRangeBtn") + self.gridLayout_2.addWidget(self.autoRangeBtn, 3, 0, 1, 2) + self.horizontalLayout = QtWidgets.QHBoxLayout() + self.horizontalLayout.setSpacing(0) + self.horizontalLayout.setObjectName("horizontalLayout") + self.redirectCheck = QtWidgets.QCheckBox(self.layoutWidget) + self.redirectCheck.setObjectName("redirectCheck") + self.horizontalLayout.addWidget(self.redirectCheck) + self.redirectCombo = CanvasCombo(self.layoutWidget) + self.redirectCombo.setObjectName("redirectCombo") + self.horizontalLayout.addWidget(self.redirectCombo) + self.gridLayout_2.addLayout(self.horizontalLayout, 6, 0, 1, 2) + self.itemList = TreeWidget(self.layoutWidget) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(100) + sizePolicy.setHeightForWidth(self.itemList.sizePolicy().hasHeightForWidth()) + self.itemList.setSizePolicy(sizePolicy) + self.itemList.setHeaderHidden(True) + self.itemList.setObjectName("itemList") + self.itemList.headerItem().setText(0, "1") + self.gridLayout_2.addWidget(self.itemList, 7, 0, 1, 2) + self.ctrlLayout = QtWidgets.QGridLayout() + self.ctrlLayout.setSpacing(0) + self.ctrlLayout.setObjectName("ctrlLayout") + self.gridLayout_2.addLayout(self.ctrlLayout, 11, 0, 1, 2) + self.resetTransformsBtn = QtWidgets.QPushButton(self.layoutWidget) + self.resetTransformsBtn.setObjectName("resetTransformsBtn") + self.gridLayout_2.addWidget(self.resetTransformsBtn, 8, 0, 1, 1) + self.mirrorSelectionBtn = QtWidgets.QPushButton(self.layoutWidget) + self.mirrorSelectionBtn.setObjectName("mirrorSelectionBtn") + self.gridLayout_2.addWidget(self.mirrorSelectionBtn, 4, 0, 1, 1) + self.reflectSelectionBtn = QtWidgets.QPushButton(self.layoutWidget) + self.reflectSelectionBtn.setObjectName("reflectSelectionBtn") + self.gridLayout_2.addWidget(self.reflectSelectionBtn, 4, 1, 1, 1) + self.gridLayout.addWidget(self.splitter, 0, 0, 1, 1) + + self.retranslateUi(Form) + QtCore.QMetaObject.connectSlotsByName(Form) + + def retranslateUi(self, Form): + _translate = QtCore.QCoreApplication.translate + Form.setWindowTitle(_translate("Form", "Form")) + self.storeSvgBtn.setText(_translate("Form", "Store SVG")) + self.storePngBtn.setText(_translate("Form", "Store PNG")) + self.autoRangeBtn.setText(_translate("Form", "Auto Range")) + self.redirectCheck.setToolTip(_translate("Form", "Check to display all local items in a remote canvas.")) + self.redirectCheck.setText(_translate("Form", "Redirect")) + self.resetTransformsBtn.setText(_translate("Form", "Reset Transforms")) + self.mirrorSelectionBtn.setText(_translate("Form", "Mirror Selection")) + self.reflectSelectionBtn.setText(_translate("Form", "MirrorXY")) + +from ..widgets.GraphicsView import GraphicsView +from ..widgets.TreeWidget import TreeWidget +from CanvasManager import CanvasCombo diff --git a/pyqtgraph/canvas/TransformGuiTemplate_pyqt5.py b/pyqtgraph/canvas/TransformGuiTemplate_pyqt5.py new file mode 100644 index 00000000..549f3008 --- /dev/null +++ b/pyqtgraph/canvas/TransformGuiTemplate_pyqt5.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file './pyqtgraph/canvas/TransformGuiTemplate.ui' +# +# Created: Wed Mar 26 15:09:28 2014 +# by: PyQt5 UI code generator 5.0.1 +# +# WARNING! All changes made in this file will be lost! + +from PyQt5 import QtCore, QtGui, QtWidgets + +class Ui_Form(object): + def setupUi(self, Form): + Form.setObjectName("Form") + Form.resize(224, 117) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(Form.sizePolicy().hasHeightForWidth()) + Form.setSizePolicy(sizePolicy) + self.verticalLayout = QtWidgets.QVBoxLayout(Form) + self.verticalLayout.setSpacing(1) + self.verticalLayout.setContentsMargins(0, 0, 0, 0) + self.verticalLayout.setObjectName("verticalLayout") + self.translateLabel = QtWidgets.QLabel(Form) + self.translateLabel.setObjectName("translateLabel") + self.verticalLayout.addWidget(self.translateLabel) + self.rotateLabel = QtWidgets.QLabel(Form) + self.rotateLabel.setObjectName("rotateLabel") + self.verticalLayout.addWidget(self.rotateLabel) + self.scaleLabel = QtWidgets.QLabel(Form) + self.scaleLabel.setObjectName("scaleLabel") + self.verticalLayout.addWidget(self.scaleLabel) + self.horizontalLayout = QtWidgets.QHBoxLayout() + self.horizontalLayout.setObjectName("horizontalLayout") + self.mirrorImageBtn = QtWidgets.QPushButton(Form) + self.mirrorImageBtn.setToolTip("") + self.mirrorImageBtn.setObjectName("mirrorImageBtn") + self.horizontalLayout.addWidget(self.mirrorImageBtn) + self.reflectImageBtn = QtWidgets.QPushButton(Form) + self.reflectImageBtn.setObjectName("reflectImageBtn") + self.horizontalLayout.addWidget(self.reflectImageBtn) + self.verticalLayout.addLayout(self.horizontalLayout) + + self.retranslateUi(Form) + QtCore.QMetaObject.connectSlotsByName(Form) + + def retranslateUi(self, Form): + _translate = QtCore.QCoreApplication.translate + Form.setWindowTitle(_translate("Form", "Form")) + self.translateLabel.setText(_translate("Form", "Translate:")) + self.rotateLabel.setText(_translate("Form", "Rotate:")) + self.scaleLabel.setText(_translate("Form", "Scale:")) + self.mirrorImageBtn.setText(_translate("Form", "Mirror")) + self.reflectImageBtn.setText(_translate("Form", "Reflect")) + diff --git a/pyqtgraph/console/template_pyqt5.py b/pyqtgraph/console/template_pyqt5.py new file mode 100644 index 00000000..1fbc5bed --- /dev/null +++ b/pyqtgraph/console/template_pyqt5.py @@ -0,0 +1,107 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file './pyqtgraph/console/template.ui' +# +# Created: Wed Mar 26 15:09:29 2014 +# by: PyQt5 UI code generator 5.0.1 +# +# WARNING! All changes made in this file will be lost! + +from PyQt5 import QtCore, QtGui, QtWidgets + +class Ui_Form(object): + def setupUi(self, Form): + Form.setObjectName("Form") + Form.resize(710, 497) + self.gridLayout = QtWidgets.QGridLayout(Form) + self.gridLayout.setContentsMargins(0, 0, 0, 0) + self.gridLayout.setSpacing(0) + self.gridLayout.setObjectName("gridLayout") + self.splitter = QtWidgets.QSplitter(Form) + self.splitter.setOrientation(QtCore.Qt.Vertical) + self.splitter.setObjectName("splitter") + self.layoutWidget = QtWidgets.QWidget(self.splitter) + self.layoutWidget.setObjectName("layoutWidget") + self.verticalLayout = QtWidgets.QVBoxLayout(self.layoutWidget) + self.verticalLayout.setContentsMargins(0, 0, 0, 0) + self.verticalLayout.setObjectName("verticalLayout") + self.output = QtWidgets.QPlainTextEdit(self.layoutWidget) + font = QtGui.QFont() + font.setFamily("Monospace") + self.output.setFont(font) + self.output.setReadOnly(True) + self.output.setObjectName("output") + self.verticalLayout.addWidget(self.output) + self.horizontalLayout = QtWidgets.QHBoxLayout() + self.horizontalLayout.setObjectName("horizontalLayout") + self.input = CmdInput(self.layoutWidget) + self.input.setObjectName("input") + self.horizontalLayout.addWidget(self.input) + self.historyBtn = QtWidgets.QPushButton(self.layoutWidget) + self.historyBtn.setCheckable(True) + self.historyBtn.setObjectName("historyBtn") + self.horizontalLayout.addWidget(self.historyBtn) + self.exceptionBtn = QtWidgets.QPushButton(self.layoutWidget) + self.exceptionBtn.setCheckable(True) + self.exceptionBtn.setObjectName("exceptionBtn") + self.horizontalLayout.addWidget(self.exceptionBtn) + self.verticalLayout.addLayout(self.horizontalLayout) + self.historyList = QtWidgets.QListWidget(self.splitter) + font = QtGui.QFont() + font.setFamily("Monospace") + self.historyList.setFont(font) + self.historyList.setObjectName("historyList") + self.exceptionGroup = QtWidgets.QGroupBox(self.splitter) + self.exceptionGroup.setObjectName("exceptionGroup") + self.gridLayout_2 = QtWidgets.QGridLayout(self.exceptionGroup) + self.gridLayout_2.setSpacing(0) + self.gridLayout_2.setContentsMargins(-1, 0, -1, 0) + self.gridLayout_2.setObjectName("gridLayout_2") + self.catchAllExceptionsBtn = QtWidgets.QPushButton(self.exceptionGroup) + self.catchAllExceptionsBtn.setCheckable(True) + self.catchAllExceptionsBtn.setObjectName("catchAllExceptionsBtn") + self.gridLayout_2.addWidget(self.catchAllExceptionsBtn, 0, 1, 1, 1) + self.catchNextExceptionBtn = QtWidgets.QPushButton(self.exceptionGroup) + self.catchNextExceptionBtn.setCheckable(True) + self.catchNextExceptionBtn.setObjectName("catchNextExceptionBtn") + self.gridLayout_2.addWidget(self.catchNextExceptionBtn, 0, 0, 1, 1) + self.onlyUncaughtCheck = QtWidgets.QCheckBox(self.exceptionGroup) + self.onlyUncaughtCheck.setChecked(True) + self.onlyUncaughtCheck.setObjectName("onlyUncaughtCheck") + self.gridLayout_2.addWidget(self.onlyUncaughtCheck, 0, 2, 1, 1) + self.exceptionStackList = QtWidgets.QListWidget(self.exceptionGroup) + self.exceptionStackList.setAlternatingRowColors(True) + self.exceptionStackList.setObjectName("exceptionStackList") + self.gridLayout_2.addWidget(self.exceptionStackList, 2, 0, 1, 5) + self.runSelectedFrameCheck = QtWidgets.QCheckBox(self.exceptionGroup) + self.runSelectedFrameCheck.setChecked(True) + self.runSelectedFrameCheck.setObjectName("runSelectedFrameCheck") + self.gridLayout_2.addWidget(self.runSelectedFrameCheck, 3, 0, 1, 5) + self.exceptionInfoLabel = QtWidgets.QLabel(self.exceptionGroup) + self.exceptionInfoLabel.setObjectName("exceptionInfoLabel") + self.gridLayout_2.addWidget(self.exceptionInfoLabel, 1, 0, 1, 5) + self.clearExceptionBtn = QtWidgets.QPushButton(self.exceptionGroup) + self.clearExceptionBtn.setEnabled(False) + self.clearExceptionBtn.setObjectName("clearExceptionBtn") + self.gridLayout_2.addWidget(self.clearExceptionBtn, 0, 4, 1, 1) + spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) + self.gridLayout_2.addItem(spacerItem, 0, 3, 1, 1) + self.gridLayout.addWidget(self.splitter, 0, 0, 1, 1) + + self.retranslateUi(Form) + QtCore.QMetaObject.connectSlotsByName(Form) + + def retranslateUi(self, Form): + _translate = QtCore.QCoreApplication.translate + Form.setWindowTitle(_translate("Form", "Console")) + self.historyBtn.setText(_translate("Form", "History..")) + self.exceptionBtn.setText(_translate("Form", "Exceptions..")) + self.exceptionGroup.setTitle(_translate("Form", "Exception Handling")) + self.catchAllExceptionsBtn.setText(_translate("Form", "Show All Exceptions")) + self.catchNextExceptionBtn.setText(_translate("Form", "Show Next Exception")) + self.onlyUncaughtCheck.setText(_translate("Form", "Only Uncaught Exceptions")) + self.runSelectedFrameCheck.setText(_translate("Form", "Run commands in selected stack frame")) + self.exceptionInfoLabel.setText(_translate("Form", "Exception Info")) + self.clearExceptionBtn.setText(_translate("Form", "Clear Exception")) + +from .CmdInput import CmdInput diff --git a/pyqtgraph/flowchart/FlowchartCtrlTemplate_pyqt5.py b/pyqtgraph/flowchart/FlowchartCtrlTemplate_pyqt5.py new file mode 100644 index 00000000..b661918d --- /dev/null +++ b/pyqtgraph/flowchart/FlowchartCtrlTemplate_pyqt5.py @@ -0,0 +1,67 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file './pyqtgraph/flowchart/FlowchartCtrlTemplate.ui' +# +# Created: Wed Mar 26 15:09:28 2014 +# by: PyQt5 UI code generator 5.0.1 +# +# WARNING! All changes made in this file will be lost! + +from PyQt5 import QtCore, QtGui, QtWidgets + +class Ui_Form(object): + def setupUi(self, Form): + Form.setObjectName("Form") + Form.resize(217, 499) + self.gridLayout = QtWidgets.QGridLayout(Form) + self.gridLayout.setContentsMargins(0, 0, 0, 0) + self.gridLayout.setVerticalSpacing(0) + self.gridLayout.setObjectName("gridLayout") + self.loadBtn = QtWidgets.QPushButton(Form) + self.loadBtn.setObjectName("loadBtn") + self.gridLayout.addWidget(self.loadBtn, 1, 0, 1, 1) + self.saveBtn = FeedbackButton(Form) + self.saveBtn.setObjectName("saveBtn") + self.gridLayout.addWidget(self.saveBtn, 1, 1, 1, 2) + self.saveAsBtn = FeedbackButton(Form) + self.saveAsBtn.setObjectName("saveAsBtn") + self.gridLayout.addWidget(self.saveAsBtn, 1, 3, 1, 1) + self.reloadBtn = FeedbackButton(Form) + self.reloadBtn.setCheckable(False) + self.reloadBtn.setFlat(False) + self.reloadBtn.setObjectName("reloadBtn") + self.gridLayout.addWidget(self.reloadBtn, 4, 0, 1, 2) + self.showChartBtn = QtWidgets.QPushButton(Form) + self.showChartBtn.setCheckable(True) + self.showChartBtn.setObjectName("showChartBtn") + self.gridLayout.addWidget(self.showChartBtn, 4, 2, 1, 2) + self.ctrlList = TreeWidget(Form) + self.ctrlList.setObjectName("ctrlList") + self.ctrlList.headerItem().setText(0, "1") + self.ctrlList.header().setVisible(False) + self.ctrlList.header().setStretchLastSection(False) + self.gridLayout.addWidget(self.ctrlList, 3, 0, 1, 4) + self.fileNameLabel = QtWidgets.QLabel(Form) + font = QtGui.QFont() + font.setBold(True) + font.setWeight(75) + self.fileNameLabel.setFont(font) + self.fileNameLabel.setText("") + self.fileNameLabel.setAlignment(QtCore.Qt.AlignCenter) + self.fileNameLabel.setObjectName("fileNameLabel") + self.gridLayout.addWidget(self.fileNameLabel, 0, 1, 1, 1) + + self.retranslateUi(Form) + QtCore.QMetaObject.connectSlotsByName(Form) + + def retranslateUi(self, Form): + _translate = QtCore.QCoreApplication.translate + Form.setWindowTitle(_translate("Form", "Form")) + self.loadBtn.setText(_translate("Form", "Load..")) + self.saveBtn.setText(_translate("Form", "Save")) + self.saveAsBtn.setText(_translate("Form", "As..")) + self.reloadBtn.setText(_translate("Form", "Reload Libs")) + self.showChartBtn.setText(_translate("Form", "Flowchart")) + +from ..widgets.FeedbackButton import FeedbackButton +from ..widgets.TreeWidget import TreeWidget diff --git a/pyqtgraph/flowchart/FlowchartTemplate_pyqt5.py b/pyqtgraph/flowchart/FlowchartTemplate_pyqt5.py new file mode 100644 index 00000000..ba754305 --- /dev/null +++ b/pyqtgraph/flowchart/FlowchartTemplate_pyqt5.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file './pyqtgraph/flowchart/FlowchartTemplate.ui' +# +# Created: Wed Mar 26 15:09:28 2014 +# by: PyQt5 UI code generator 5.0.1 +# +# WARNING! All changes made in this file will be lost! + +from PyQt5 import QtCore, QtGui, QtWidgets + +class Ui_Form(object): + def setupUi(self, Form): + Form.setObjectName("Form") + Form.resize(529, 329) + self.selInfoWidget = QtWidgets.QWidget(Form) + self.selInfoWidget.setGeometry(QtCore.QRect(260, 10, 264, 222)) + self.selInfoWidget.setObjectName("selInfoWidget") + self.gridLayout = QtWidgets.QGridLayout(self.selInfoWidget) + self.gridLayout.setContentsMargins(0, 0, 0, 0) + self.gridLayout.setObjectName("gridLayout") + self.selDescLabel = QtWidgets.QLabel(self.selInfoWidget) + self.selDescLabel.setText("") + self.selDescLabel.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) + self.selDescLabel.setWordWrap(True) + self.selDescLabel.setObjectName("selDescLabel") + self.gridLayout.addWidget(self.selDescLabel, 0, 0, 1, 1) + self.selNameLabel = QtWidgets.QLabel(self.selInfoWidget) + font = QtGui.QFont() + font.setBold(True) + font.setWeight(75) + self.selNameLabel.setFont(font) + self.selNameLabel.setText("") + self.selNameLabel.setObjectName("selNameLabel") + self.gridLayout.addWidget(self.selNameLabel, 0, 1, 1, 1) + self.selectedTree = DataTreeWidget(self.selInfoWidget) + self.selectedTree.setObjectName("selectedTree") + self.selectedTree.headerItem().setText(0, "1") + self.gridLayout.addWidget(self.selectedTree, 1, 0, 1, 2) + self.hoverText = QtWidgets.QTextEdit(Form) + self.hoverText.setGeometry(QtCore.QRect(0, 240, 521, 81)) + self.hoverText.setObjectName("hoverText") + self.view = FlowchartGraphicsView(Form) + self.view.setGeometry(QtCore.QRect(0, 0, 256, 192)) + self.view.setObjectName("view") + + self.retranslateUi(Form) + QtCore.QMetaObject.connectSlotsByName(Form) + + def retranslateUi(self, Form): + _translate = QtCore.QCoreApplication.translate + Form.setWindowTitle(_translate("Form", "Form")) + +from ..widgets.DataTreeWidget import DataTreeWidget +from ..flowchart.FlowchartGraphicsView import FlowchartGraphicsView diff --git a/pyqtgraph/graphicsItems/PlotItem/PlotItem.py b/pyqtgraph/graphicsItems/PlotItem/PlotItem.py index 847ff3ac..420f23d7 100644 --- a/pyqtgraph/graphicsItems/PlotItem/PlotItem.py +++ b/pyqtgraph/graphicsItems/PlotItem/PlotItem.py @@ -16,14 +16,16 @@ This class is very heavily featured: - Control panel with a huge feature set including averaging, decimation, display, power spectrum, svg/png export, plot linking, and more. """ -from ...Qt import QtGui, QtCore, QtSvg, USE_PYSIDE +from ...Qt import QtGui, QtCore, QtSvg, QT_LIB from ... import pixmaps import sys -if USE_PYSIDE: - from .plotConfigTemplate_pyside import * -else: +if QT_LIB == 'PyQt4': from .plotConfigTemplate_pyqt import * +elif QT_LIB == 'PySide': + from .plotConfigTemplate_pyside import * +elif QT_LIB == 'PyQt5': + from .plotConfigTemplate_pyqt5 import * from ... import functions as fn from ...widgets.FileDialog import FileDialog diff --git a/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate_pyqt.py b/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate_pyqt.py index a06519bf..e09c9978 100644 --- a/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate_pyqt.py +++ b/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate_pyqt.py @@ -7,7 +7,7 @@ # # WARNING! All changes made in this file will be lost! -from ...Qt import QtCore, QtGui +from PyQt4 import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 diff --git a/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate_pyqt5.py b/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate_pyqt5.py new file mode 100644 index 00000000..e9fdff24 --- /dev/null +++ b/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate_pyqt5.py @@ -0,0 +1,169 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file './pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate.ui' +# +# Created: Wed Mar 26 15:09:28 2014 +# by: PyQt5 UI code generator 5.0.1 +# +# WARNING! All changes made in this file will be lost! + +from PyQt5 import QtCore, QtGui, QtWidgets + +class Ui_Form(object): + def setupUi(self, Form): + Form.setObjectName("Form") + Form.resize(481, 840) + self.averageGroup = QtWidgets.QGroupBox(Form) + self.averageGroup.setGeometry(QtCore.QRect(0, 640, 242, 182)) + self.averageGroup.setCheckable(True) + self.averageGroup.setChecked(False) + self.averageGroup.setObjectName("averageGroup") + self.gridLayout_5 = QtWidgets.QGridLayout(self.averageGroup) + self.gridLayout_5.setContentsMargins(0, 0, 0, 0) + self.gridLayout_5.setSpacing(0) + self.gridLayout_5.setObjectName("gridLayout_5") + self.avgParamList = QtWidgets.QListWidget(self.averageGroup) + self.avgParamList.setObjectName("avgParamList") + self.gridLayout_5.addWidget(self.avgParamList, 0, 0, 1, 1) + self.decimateGroup = QtWidgets.QFrame(Form) + self.decimateGroup.setGeometry(QtCore.QRect(10, 140, 191, 171)) + self.decimateGroup.setObjectName("decimateGroup") + self.gridLayout_4 = QtWidgets.QGridLayout(self.decimateGroup) + self.gridLayout_4.setContentsMargins(0, 0, 0, 0) + self.gridLayout_4.setSpacing(0) + self.gridLayout_4.setObjectName("gridLayout_4") + self.clipToViewCheck = QtWidgets.QCheckBox(self.decimateGroup) + self.clipToViewCheck.setObjectName("clipToViewCheck") + self.gridLayout_4.addWidget(self.clipToViewCheck, 7, 0, 1, 3) + self.maxTracesCheck = QtWidgets.QCheckBox(self.decimateGroup) + self.maxTracesCheck.setObjectName("maxTracesCheck") + self.gridLayout_4.addWidget(self.maxTracesCheck, 8, 0, 1, 2) + self.downsampleCheck = QtWidgets.QCheckBox(self.decimateGroup) + self.downsampleCheck.setObjectName("downsampleCheck") + self.gridLayout_4.addWidget(self.downsampleCheck, 0, 0, 1, 3) + self.peakRadio = QtWidgets.QRadioButton(self.decimateGroup) + self.peakRadio.setChecked(True) + self.peakRadio.setObjectName("peakRadio") + self.gridLayout_4.addWidget(self.peakRadio, 6, 1, 1, 2) + self.maxTracesSpin = QtWidgets.QSpinBox(self.decimateGroup) + self.maxTracesSpin.setObjectName("maxTracesSpin") + self.gridLayout_4.addWidget(self.maxTracesSpin, 8, 2, 1, 1) + self.forgetTracesCheck = QtWidgets.QCheckBox(self.decimateGroup) + self.forgetTracesCheck.setObjectName("forgetTracesCheck") + self.gridLayout_4.addWidget(self.forgetTracesCheck, 9, 0, 1, 3) + self.meanRadio = QtWidgets.QRadioButton(self.decimateGroup) + self.meanRadio.setObjectName("meanRadio") + self.gridLayout_4.addWidget(self.meanRadio, 3, 1, 1, 2) + self.subsampleRadio = QtWidgets.QRadioButton(self.decimateGroup) + self.subsampleRadio.setObjectName("subsampleRadio") + self.gridLayout_4.addWidget(self.subsampleRadio, 2, 1, 1, 2) + self.autoDownsampleCheck = QtWidgets.QCheckBox(self.decimateGroup) + self.autoDownsampleCheck.setChecked(True) + self.autoDownsampleCheck.setObjectName("autoDownsampleCheck") + self.gridLayout_4.addWidget(self.autoDownsampleCheck, 1, 2, 1, 1) + spacerItem = QtWidgets.QSpacerItem(30, 20, QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Minimum) + self.gridLayout_4.addItem(spacerItem, 2, 0, 1, 1) + self.downsampleSpin = QtWidgets.QSpinBox(self.decimateGroup) + self.downsampleSpin.setMinimum(1) + self.downsampleSpin.setMaximum(100000) + self.downsampleSpin.setProperty("value", 1) + self.downsampleSpin.setObjectName("downsampleSpin") + self.gridLayout_4.addWidget(self.downsampleSpin, 1, 1, 1, 1) + self.transformGroup = QtWidgets.QFrame(Form) + self.transformGroup.setGeometry(QtCore.QRect(0, 0, 154, 79)) + self.transformGroup.setObjectName("transformGroup") + self.gridLayout = QtWidgets.QGridLayout(self.transformGroup) + self.gridLayout.setObjectName("gridLayout") + self.fftCheck = QtWidgets.QCheckBox(self.transformGroup) + self.fftCheck.setObjectName("fftCheck") + self.gridLayout.addWidget(self.fftCheck, 0, 0, 1, 1) + self.logXCheck = QtWidgets.QCheckBox(self.transformGroup) + self.logXCheck.setObjectName("logXCheck") + self.gridLayout.addWidget(self.logXCheck, 1, 0, 1, 1) + self.logYCheck = QtWidgets.QCheckBox(self.transformGroup) + self.logYCheck.setObjectName("logYCheck") + self.gridLayout.addWidget(self.logYCheck, 2, 0, 1, 1) + self.pointsGroup = QtWidgets.QGroupBox(Form) + self.pointsGroup.setGeometry(QtCore.QRect(10, 550, 234, 58)) + self.pointsGroup.setCheckable(True) + self.pointsGroup.setObjectName("pointsGroup") + self.verticalLayout_5 = QtWidgets.QVBoxLayout(self.pointsGroup) + self.verticalLayout_5.setObjectName("verticalLayout_5") + self.autoPointsCheck = QtWidgets.QCheckBox(self.pointsGroup) + self.autoPointsCheck.setChecked(True) + self.autoPointsCheck.setObjectName("autoPointsCheck") + self.verticalLayout_5.addWidget(self.autoPointsCheck) + self.gridGroup = QtWidgets.QFrame(Form) + self.gridGroup.setGeometry(QtCore.QRect(10, 460, 221, 81)) + self.gridGroup.setObjectName("gridGroup") + self.gridLayout_2 = QtWidgets.QGridLayout(self.gridGroup) + self.gridLayout_2.setObjectName("gridLayout_2") + self.xGridCheck = QtWidgets.QCheckBox(self.gridGroup) + self.xGridCheck.setObjectName("xGridCheck") + self.gridLayout_2.addWidget(self.xGridCheck, 0, 0, 1, 2) + self.yGridCheck = QtWidgets.QCheckBox(self.gridGroup) + self.yGridCheck.setObjectName("yGridCheck") + self.gridLayout_2.addWidget(self.yGridCheck, 1, 0, 1, 2) + self.gridAlphaSlider = QtWidgets.QSlider(self.gridGroup) + self.gridAlphaSlider.setMaximum(255) + self.gridAlphaSlider.setProperty("value", 128) + self.gridAlphaSlider.setOrientation(QtCore.Qt.Horizontal) + self.gridAlphaSlider.setObjectName("gridAlphaSlider") + self.gridLayout_2.addWidget(self.gridAlphaSlider, 2, 1, 1, 1) + self.label = QtWidgets.QLabel(self.gridGroup) + self.label.setObjectName("label") + self.gridLayout_2.addWidget(self.label, 2, 0, 1, 1) + self.alphaGroup = QtWidgets.QGroupBox(Form) + self.alphaGroup.setGeometry(QtCore.QRect(10, 390, 234, 60)) + self.alphaGroup.setCheckable(True) + self.alphaGroup.setObjectName("alphaGroup") + self.horizontalLayout = QtWidgets.QHBoxLayout(self.alphaGroup) + self.horizontalLayout.setObjectName("horizontalLayout") + self.autoAlphaCheck = QtWidgets.QCheckBox(self.alphaGroup) + self.autoAlphaCheck.setChecked(False) + self.autoAlphaCheck.setObjectName("autoAlphaCheck") + self.horizontalLayout.addWidget(self.autoAlphaCheck) + self.alphaSlider = QtWidgets.QSlider(self.alphaGroup) + self.alphaSlider.setMaximum(1000) + self.alphaSlider.setProperty("value", 1000) + self.alphaSlider.setOrientation(QtCore.Qt.Horizontal) + self.alphaSlider.setObjectName("alphaSlider") + self.horizontalLayout.addWidget(self.alphaSlider) + + self.retranslateUi(Form) + QtCore.QMetaObject.connectSlotsByName(Form) + + def retranslateUi(self, Form): + _translate = QtCore.QCoreApplication.translate + Form.setWindowTitle(_translate("Form", "Form")) + self.averageGroup.setToolTip(_translate("Form", "Display averages of the curves displayed in this plot. The parameter list allows you to choose parameters to average over (if any are available).")) + self.averageGroup.setTitle(_translate("Form", "Average")) + self.clipToViewCheck.setToolTip(_translate("Form", "Plot only the portion of each curve that is visible. This assumes X values are uniformly spaced.")) + self.clipToViewCheck.setText(_translate("Form", "Clip to View")) + self.maxTracesCheck.setToolTip(_translate("Form", "If multiple curves are displayed in this plot, check this box to limit the number of traces that are displayed.")) + self.maxTracesCheck.setText(_translate("Form", "Max Traces:")) + self.downsampleCheck.setText(_translate("Form", "Downsample")) + self.peakRadio.setToolTip(_translate("Form", "Downsample by drawing a saw wave that follows the min and max of the original data. This method produces the best visual representation of the data but is slower.")) + self.peakRadio.setText(_translate("Form", "Peak")) + self.maxTracesSpin.setToolTip(_translate("Form", "If multiple curves are displayed in this plot, check \"Max Traces\" and set this value to limit the number of traces that are displayed.")) + self.forgetTracesCheck.setToolTip(_translate("Form", "If MaxTraces is checked, remove curves from memory after they are hidden (saves memory, but traces can not be un-hidden).")) + self.forgetTracesCheck.setText(_translate("Form", "Forget hidden traces")) + self.meanRadio.setToolTip(_translate("Form", "Downsample by taking the mean of N samples.")) + self.meanRadio.setText(_translate("Form", "Mean")) + self.subsampleRadio.setToolTip(_translate("Form", "Downsample by taking the first of N samples. This method is fastest and least accurate.")) + self.subsampleRadio.setText(_translate("Form", "Subsample")) + self.autoDownsampleCheck.setToolTip(_translate("Form", "Automatically downsample data based on the visible range. This assumes X values are uniformly spaced.")) + self.autoDownsampleCheck.setText(_translate("Form", "Auto")) + self.downsampleSpin.setToolTip(_translate("Form", "Downsample data before plotting. (plot every Nth sample)")) + self.downsampleSpin.setSuffix(_translate("Form", "x")) + self.fftCheck.setText(_translate("Form", "Power Spectrum (FFT)")) + self.logXCheck.setText(_translate("Form", "Log X")) + self.logYCheck.setText(_translate("Form", "Log Y")) + self.pointsGroup.setTitle(_translate("Form", "Points")) + self.autoPointsCheck.setText(_translate("Form", "Auto")) + self.xGridCheck.setText(_translate("Form", "Show X Grid")) + self.yGridCheck.setText(_translate("Form", "Show Y Grid")) + self.label.setText(_translate("Form", "Opacity")) + self.alphaGroup.setTitle(_translate("Form", "Alpha")) + self.autoAlphaCheck.setText(_translate("Form", "Auto")) + diff --git a/pyqtgraph/graphicsItems/ViewBox/ViewBoxMenu.py b/pyqtgraph/graphicsItems/ViewBox/ViewBoxMenu.py index af142771..0ece67b6 100644 --- a/pyqtgraph/graphicsItems/ViewBox/ViewBoxMenu.py +++ b/pyqtgraph/graphicsItems/ViewBox/ViewBoxMenu.py @@ -1,12 +1,14 @@ -from ...Qt import QtCore, QtGui, USE_PYSIDE +from ...Qt import QtCore, QtGui, QT_LIB from ...python2_3 import asUnicode from ...WidgetGroup import WidgetGroup -if USE_PYSIDE: - from .axisCtrlTemplate_pyside import Ui_Form as AxisCtrlTemplate -else: +if QT_LIB == 'PyQt4': from .axisCtrlTemplate_pyqt import Ui_Form as AxisCtrlTemplate - +elif QT_LIB == 'PySide': + from .axisCtrlTemplate_pyside import Ui_Form as AxisCtrlTemplate +elif QT_LIB == 'PyQt5': + from .axisCtrlTemplate_pyqt5 import Ui_Form as AxisCtrlTemplate + import weakref class ViewBoxMenu(QtGui.QMenu): diff --git a/pyqtgraph/graphicsItems/ViewBox/axisCtrlTemplate_pyqt5.py b/pyqtgraph/graphicsItems/ViewBox/axisCtrlTemplate_pyqt5.py new file mode 100644 index 00000000..78da6eea --- /dev/null +++ b/pyqtgraph/graphicsItems/ViewBox/axisCtrlTemplate_pyqt5.py @@ -0,0 +1,89 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file './pyqtgraph/graphicsItems/ViewBox/axisCtrlTemplate.ui' +# +# Created: Wed Mar 26 15:09:28 2014 +# by: PyQt5 UI code generator 5.0.1 +# +# WARNING! All changes made in this file will be lost! + +from PyQt5 import QtCore, QtGui, QtWidgets + +class Ui_Form(object): + def setupUi(self, Form): + Form.setObjectName("Form") + Form.resize(186, 154) + Form.setMaximumSize(QtCore.QSize(200, 16777215)) + self.gridLayout = QtWidgets.QGridLayout(Form) + self.gridLayout.setContentsMargins(0, 0, 0, 0) + self.gridLayout.setSpacing(0) + self.gridLayout.setObjectName("gridLayout") + self.label = QtWidgets.QLabel(Form) + self.label.setObjectName("label") + self.gridLayout.addWidget(self.label, 7, 0, 1, 2) + self.linkCombo = QtWidgets.QComboBox(Form) + self.linkCombo.setSizeAdjustPolicy(QtWidgets.QComboBox.AdjustToContents) + self.linkCombo.setObjectName("linkCombo") + self.gridLayout.addWidget(self.linkCombo, 7, 2, 1, 2) + self.autoPercentSpin = QtWidgets.QSpinBox(Form) + self.autoPercentSpin.setEnabled(True) + self.autoPercentSpin.setMinimum(1) + self.autoPercentSpin.setMaximum(100) + self.autoPercentSpin.setSingleStep(1) + self.autoPercentSpin.setProperty("value", 100) + self.autoPercentSpin.setObjectName("autoPercentSpin") + self.gridLayout.addWidget(self.autoPercentSpin, 2, 2, 1, 2) + self.autoRadio = QtWidgets.QRadioButton(Form) + self.autoRadio.setChecked(True) + self.autoRadio.setObjectName("autoRadio") + self.gridLayout.addWidget(self.autoRadio, 2, 0, 1, 2) + self.manualRadio = QtWidgets.QRadioButton(Form) + self.manualRadio.setObjectName("manualRadio") + self.gridLayout.addWidget(self.manualRadio, 1, 0, 1, 2) + self.minText = QtWidgets.QLineEdit(Form) + self.minText.setObjectName("minText") + self.gridLayout.addWidget(self.minText, 1, 2, 1, 1) + self.maxText = QtWidgets.QLineEdit(Form) + self.maxText.setObjectName("maxText") + self.gridLayout.addWidget(self.maxText, 1, 3, 1, 1) + self.invertCheck = QtWidgets.QCheckBox(Form) + self.invertCheck.setObjectName("invertCheck") + self.gridLayout.addWidget(self.invertCheck, 5, 0, 1, 4) + self.mouseCheck = QtWidgets.QCheckBox(Form) + self.mouseCheck.setChecked(True) + self.mouseCheck.setObjectName("mouseCheck") + self.gridLayout.addWidget(self.mouseCheck, 6, 0, 1, 4) + self.visibleOnlyCheck = QtWidgets.QCheckBox(Form) + self.visibleOnlyCheck.setObjectName("visibleOnlyCheck") + self.gridLayout.addWidget(self.visibleOnlyCheck, 3, 2, 1, 2) + self.autoPanCheck = QtWidgets.QCheckBox(Form) + self.autoPanCheck.setObjectName("autoPanCheck") + self.gridLayout.addWidget(self.autoPanCheck, 4, 2, 1, 2) + + self.retranslateUi(Form) + QtCore.QMetaObject.connectSlotsByName(Form) + + def retranslateUi(self, Form): + _translate = QtCore.QCoreApplication.translate + Form.setWindowTitle(_translate("Form", "Form")) + self.label.setText(_translate("Form", "Link Axis:")) + self.linkCombo.setToolTip(_translate("Form", "

Links this axis with another view. When linked, both views will display the same data range.

")) + self.autoPercentSpin.setToolTip(_translate("Form", "

Percent of data to be visible when auto-scaling. It may be useful to decrease this value for data with spiky noise.

")) + self.autoPercentSpin.setSuffix(_translate("Form", "%")) + self.autoRadio.setToolTip(_translate("Form", "

Automatically resize this axis whenever the displayed data is changed.

")) + self.autoRadio.setText(_translate("Form", "Auto")) + self.manualRadio.setToolTip(_translate("Form", "

Set the range for this axis manually. This disables automatic scaling.

")) + self.manualRadio.setText(_translate("Form", "Manual")) + self.minText.setToolTip(_translate("Form", "

Minimum value to display for this axis.

")) + self.minText.setText(_translate("Form", "0")) + self.maxText.setToolTip(_translate("Form", "

Maximum value to display for this axis.

")) + self.maxText.setText(_translate("Form", "0")) + self.invertCheck.setToolTip(_translate("Form", "

Inverts the display of this axis. (+y points downward instead of upward)

")) + self.invertCheck.setText(_translate("Form", "Invert Axis")) + self.mouseCheck.setToolTip(_translate("Form", "

Enables mouse interaction (panning, scaling) for this axis.

")) + self.mouseCheck.setText(_translate("Form", "Mouse Enabled")) + self.visibleOnlyCheck.setToolTip(_translate("Form", "

When checked, the axis will only auto-scale to data that is visible along the orthogonal axis.

")) + self.visibleOnlyCheck.setText(_translate("Form", "Visible Data Only")) + self.autoPanCheck.setToolTip(_translate("Form", "

When checked, the axis will automatically pan to center on the current data, but the scale along this axis will not change.

")) + self.autoPanCheck.setText(_translate("Form", "Auto Pan Only")) + diff --git a/pyqtgraph/imageview/ImageViewTemplate_pyqt5.py b/pyqtgraph/imageview/ImageViewTemplate_pyqt5.py new file mode 100644 index 00000000..4b4009b6 --- /dev/null +++ b/pyqtgraph/imageview/ImageViewTemplate_pyqt5.py @@ -0,0 +1,156 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file './pyqtgraph/imageview/ImageViewTemplate.ui' +# +# Created: Wed Mar 26 15:09:28 2014 +# by: PyQt5 UI code generator 5.0.1 +# +# WARNING! All changes made in this file will be lost! + +from PyQt5 import QtCore, QtGui, QtWidgets + +class Ui_Form(object): + def setupUi(self, Form): + Form.setObjectName("Form") + Form.resize(726, 588) + self.gridLayout_3 = QtWidgets.QGridLayout(Form) + self.gridLayout_3.setContentsMargins(0, 0, 0, 0) + self.gridLayout_3.setSpacing(0) + self.gridLayout_3.setObjectName("gridLayout_3") + self.splitter = QtWidgets.QSplitter(Form) + self.splitter.setOrientation(QtCore.Qt.Vertical) + self.splitter.setObjectName("splitter") + self.layoutWidget = QtWidgets.QWidget(self.splitter) + self.layoutWidget.setObjectName("layoutWidget") + self.gridLayout = QtWidgets.QGridLayout(self.layoutWidget) + self.gridLayout.setSpacing(0) + self.gridLayout.setContentsMargins(0, 0, 0, 0) + self.gridLayout.setObjectName("gridLayout") + self.graphicsView = GraphicsView(self.layoutWidget) + self.graphicsView.setObjectName("graphicsView") + self.gridLayout.addWidget(self.graphicsView, 0, 0, 2, 1) + self.histogram = HistogramLUTWidget(self.layoutWidget) + self.histogram.setObjectName("histogram") + self.gridLayout.addWidget(self.histogram, 0, 1, 1, 2) + self.roiBtn = QtWidgets.QPushButton(self.layoutWidget) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(1) + sizePolicy.setHeightForWidth(self.roiBtn.sizePolicy().hasHeightForWidth()) + self.roiBtn.setSizePolicy(sizePolicy) + self.roiBtn.setCheckable(True) + self.roiBtn.setObjectName("roiBtn") + self.gridLayout.addWidget(self.roiBtn, 1, 1, 1, 1) + self.normBtn = QtWidgets.QPushButton(self.layoutWidget) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(1) + sizePolicy.setHeightForWidth(self.normBtn.sizePolicy().hasHeightForWidth()) + self.normBtn.setSizePolicy(sizePolicy) + self.normBtn.setCheckable(True) + self.normBtn.setObjectName("normBtn") + self.gridLayout.addWidget(self.normBtn, 1, 2, 1, 1) + self.roiPlot = PlotWidget(self.splitter) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.roiPlot.sizePolicy().hasHeightForWidth()) + self.roiPlot.setSizePolicy(sizePolicy) + self.roiPlot.setMinimumSize(QtCore.QSize(0, 40)) + self.roiPlot.setObjectName("roiPlot") + self.gridLayout_3.addWidget(self.splitter, 0, 0, 1, 1) + self.normGroup = QtWidgets.QGroupBox(Form) + self.normGroup.setObjectName("normGroup") + self.gridLayout_2 = QtWidgets.QGridLayout(self.normGroup) + self.gridLayout_2.setContentsMargins(0, 0, 0, 0) + self.gridLayout_2.setSpacing(0) + self.gridLayout_2.setObjectName("gridLayout_2") + self.normSubtractRadio = QtWidgets.QRadioButton(self.normGroup) + self.normSubtractRadio.setObjectName("normSubtractRadio") + self.gridLayout_2.addWidget(self.normSubtractRadio, 0, 2, 1, 1) + self.normDivideRadio = QtWidgets.QRadioButton(self.normGroup) + self.normDivideRadio.setChecked(False) + self.normDivideRadio.setObjectName("normDivideRadio") + self.gridLayout_2.addWidget(self.normDivideRadio, 0, 1, 1, 1) + self.label_5 = QtWidgets.QLabel(self.normGroup) + font = QtGui.QFont() + font.setBold(True) + font.setWeight(75) + self.label_5.setFont(font) + self.label_5.setObjectName("label_5") + self.gridLayout_2.addWidget(self.label_5, 0, 0, 1, 1) + self.label_3 = QtWidgets.QLabel(self.normGroup) + font = QtGui.QFont() + font.setBold(True) + font.setWeight(75) + self.label_3.setFont(font) + self.label_3.setObjectName("label_3") + self.gridLayout_2.addWidget(self.label_3, 1, 0, 1, 1) + self.label_4 = QtWidgets.QLabel(self.normGroup) + font = QtGui.QFont() + font.setBold(True) + font.setWeight(75) + self.label_4.setFont(font) + self.label_4.setObjectName("label_4") + self.gridLayout_2.addWidget(self.label_4, 2, 0, 1, 1) + self.normROICheck = QtWidgets.QCheckBox(self.normGroup) + self.normROICheck.setObjectName("normROICheck") + self.gridLayout_2.addWidget(self.normROICheck, 1, 1, 1, 1) + self.normXBlurSpin = QtWidgets.QDoubleSpinBox(self.normGroup) + self.normXBlurSpin.setObjectName("normXBlurSpin") + self.gridLayout_2.addWidget(self.normXBlurSpin, 2, 2, 1, 1) + self.label_8 = QtWidgets.QLabel(self.normGroup) + self.label_8.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.label_8.setObjectName("label_8") + self.gridLayout_2.addWidget(self.label_8, 2, 1, 1, 1) + self.label_9 = QtWidgets.QLabel(self.normGroup) + self.label_9.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.label_9.setObjectName("label_9") + self.gridLayout_2.addWidget(self.label_9, 2, 3, 1, 1) + self.normYBlurSpin = QtWidgets.QDoubleSpinBox(self.normGroup) + self.normYBlurSpin.setObjectName("normYBlurSpin") + self.gridLayout_2.addWidget(self.normYBlurSpin, 2, 4, 1, 1) + self.label_10 = QtWidgets.QLabel(self.normGroup) + self.label_10.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.label_10.setObjectName("label_10") + self.gridLayout_2.addWidget(self.label_10, 2, 5, 1, 1) + self.normOffRadio = QtWidgets.QRadioButton(self.normGroup) + self.normOffRadio.setChecked(True) + self.normOffRadio.setObjectName("normOffRadio") + self.gridLayout_2.addWidget(self.normOffRadio, 0, 3, 1, 1) + self.normTimeRangeCheck = QtWidgets.QCheckBox(self.normGroup) + self.normTimeRangeCheck.setObjectName("normTimeRangeCheck") + self.gridLayout_2.addWidget(self.normTimeRangeCheck, 1, 3, 1, 1) + self.normFrameCheck = QtWidgets.QCheckBox(self.normGroup) + self.normFrameCheck.setObjectName("normFrameCheck") + self.gridLayout_2.addWidget(self.normFrameCheck, 1, 2, 1, 1) + self.normTBlurSpin = QtWidgets.QDoubleSpinBox(self.normGroup) + self.normTBlurSpin.setObjectName("normTBlurSpin") + self.gridLayout_2.addWidget(self.normTBlurSpin, 2, 6, 1, 1) + self.gridLayout_3.addWidget(self.normGroup, 1, 0, 1, 1) + + self.retranslateUi(Form) + QtCore.QMetaObject.connectSlotsByName(Form) + + def retranslateUi(self, Form): + _translate = QtCore.QCoreApplication.translate + Form.setWindowTitle(_translate("Form", "Form")) + self.roiBtn.setText(_translate("Form", "ROI")) + self.normBtn.setText(_translate("Form", "Norm")) + self.normGroup.setTitle(_translate("Form", "Normalization")) + self.normSubtractRadio.setText(_translate("Form", "Subtract")) + self.normDivideRadio.setText(_translate("Form", "Divide")) + self.label_5.setText(_translate("Form", "Operation:")) + self.label_3.setText(_translate("Form", "Mean:")) + self.label_4.setText(_translate("Form", "Blur:")) + self.normROICheck.setText(_translate("Form", "ROI")) + self.label_8.setText(_translate("Form", "X")) + self.label_9.setText(_translate("Form", "Y")) + self.label_10.setText(_translate("Form", "T")) + self.normOffRadio.setText(_translate("Form", "Off")) + self.normTimeRangeCheck.setText(_translate("Form", "Time range")) + self.normFrameCheck.setText(_translate("Form", "Frame")) + +from ..widgets.HistogramLUTWidget import HistogramLUTWidget +from ..widgets.PlotWidget import PlotWidget +from ..widgets.GraphicsView import GraphicsView diff --git a/tools/rebuildUi.py b/tools/rebuildUi.py index 1e4cbf9c..98751412 100644 --- a/tools/rebuildUi.py +++ b/tools/rebuildUi.py @@ -4,6 +4,7 @@ import os, sys pyqtuic = 'pyuic4' pysideuic = 'pyside-uic' +pyqt5uic = 'pyuic5' for path, sd, files in os.walk('.'): for f in files: @@ -15,9 +16,15 @@ for path, sd, files in os.walk('.'): py = os.path.join(path, base + '_pyqt.py') if not os.path.exists(py) or os.stat(ui).st_mtime > os.stat(py).st_mtime: os.system('%s %s > %s' % (pyqtuic, ui, py)) - print(py) + print(py) py = os.path.join(path, base + '_pyside.py') if not os.path.exists(py) or os.stat(ui).st_mtime > os.stat(py).st_mtime: os.system('%s %s > %s' % (pysideuic, ui, py)) print(py) + + py = os.path.join(path, base + '_pyqt5.py') + if not os.path.exists(py) or os.stat(ui).st_mtime > os.stat(py).st_mtime: + os.system('%s %s > %s' % (pyqt5uic, ui, py)) + print(py) + From 100308a33aaae0efaa731e8cff1293fb1039e7b2 Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Thu, 3 Apr 2014 13:07:33 -0400 Subject: [PATCH 05/11] Add pyuic5 script (missing on ubuntu) --- tools/pyuic5 | 2 ++ 1 file changed, 2 insertions(+) create mode 100755 tools/pyuic5 diff --git a/tools/pyuic5 b/tools/pyuic5 new file mode 100755 index 00000000..628cc2f8 --- /dev/null +++ b/tools/pyuic5 @@ -0,0 +1,2 @@ +#!/usr/bin/python3 +import PyQt5.uic.pyuic From 478a3b1aa4dc3123bcb1133ff78b7a177acdfe04 Mon Sep 17 00:00:00 2001 From: compass Date: Sat, 17 Jan 2015 00:21:33 +0800 Subject: [PATCH 06/11] Fix some bugs in PyQt5 --- examples/FillBetweenItem.py | 2 ++ examples/GradientWidget.py | 2 +- examples/template.py | 2 ++ pyqtgraph/GraphicsScene/exportDialog.py | 4 ++- pyqtgraph/Qt.py | 4 ++- pyqtgraph/WidgetGroup.py | 6 ++-- pyqtgraph/console/Console.py | 4 ++- pyqtgraph/flowchart/Flowchart.py | 10 ++++-- pyqtgraph/graphicsItems/FillBetweenItem.py | 21 ++++++------ pyqtgraph/graphicsItems/GradientEditorItem.py | 32 ++++++++++++------- pyqtgraph/graphicsItems/ROI.py | 2 +- pyqtgraph/graphicsItems/ScatterPlotItem.py | 4 +-- pyqtgraph/opengl/GLViewWidget.py | 15 ++++++--- 13 files changed, 71 insertions(+), 37 deletions(-) diff --git a/examples/FillBetweenItem.py b/examples/FillBetweenItem.py index 74dd89bc..fc91ee32 100644 --- a/examples/FillBetweenItem.py +++ b/examples/FillBetweenItem.py @@ -8,6 +8,8 @@ import pyqtgraph as pg from pyqtgraph.Qt import QtGui, QtCore import numpy as np +#FIXME: When running on Qt5, not as perfect as on Qt4 + win = pg.plot() win.setWindowTitle('pyqtgraph example: FillBetweenItem') win.setXRange(-10, 10) diff --git a/examples/GradientWidget.py b/examples/GradientWidget.py index ef7d0fa6..fa5253ba 100644 --- a/examples/GradientWidget.py +++ b/examples/GradientWidget.py @@ -16,7 +16,7 @@ app = QtGui.QApplication([]) w = QtGui.QMainWindow() w.show() w.setWindowTitle('pyqtgraph example: GradientWidget') -w.resize(400,400) +w.setGeometry(10, 50, 400, 400) cw = QtGui.QWidget() w.setCentralWidget(cw) diff --git a/examples/template.py b/examples/template.py index 1198e317..6b5e1f75 100644 --- a/examples/template.py +++ b/examples/template.py @@ -11,6 +11,8 @@ import pyqtgraph as pg from pyqtgraph.Qt import QtCore, QtGui import numpy as np +app = QtGui.QApplication([]) + # win.setWindowTitle('pyqtgraph example: ____') ## Start Qt event loop unless running in interactive mode or using pyside. diff --git a/pyqtgraph/GraphicsScene/exportDialog.py b/pyqtgraph/GraphicsScene/exportDialog.py index 5efb7c44..eebf5999 100644 --- a/pyqtgraph/GraphicsScene/exportDialog.py +++ b/pyqtgraph/GraphicsScene/exportDialog.py @@ -1,4 +1,4 @@ -from ..Qt import QtCore, QtGui, USE_PYSIDE +from ..Qt import QtCore, QtGui, USE_PYSIDE, USE_PYQT5 from .. import exporters as exporters from .. import functions as fn from ..graphicsItems.ViewBox import ViewBox @@ -6,6 +6,8 @@ from ..graphicsItems.PlotItem import PlotItem if USE_PYSIDE: from . import exportDialogTemplate_pyside as exportDialogTemplate +elif USE_PYQT5: + from . import exportDialogTemplate_pyqt5 as exportDialogTemplate else: from . import exportDialogTemplate_pyqt as exportDialogTemplate diff --git a/pyqtgraph/Qt.py b/pyqtgraph/Qt.py index edae4d99..ddf486fe 100644 --- a/pyqtgraph/Qt.py +++ b/pyqtgraph/Qt.py @@ -20,7 +20,7 @@ QT_LIB = None ## Automatically determine whether to use PyQt or PySide. ## This is done by first checking to see whether one of the libraries ## is already imported. If not, then attempt to import PyQt4, then PySide. -libOrder = [PYQT4, PYSIDE, PYQT5] +libOrder = [PYQT5, PYQT4, PYSIDE] for lib in libOrder: if lib in sys.modules: @@ -172,6 +172,8 @@ if QT_LIB.startswith('PyQt'): ## Make sure we have Qt >= 4.7 versionReq = [4, 7] USE_PYSIDE = QT_LIB == PYSIDE # for backward compatibility +USE_PYQT5 = QT_LIB == PYQT5 # for backward compatibility +USE_PYQT4 = QT_LIB == PYQT4 # for backward compatibility QtVersion = PySide.QtCore.__version__ if QT_LIB == PYSIDE else QtCore.QT_VERSION_STR m = re.match(r'(\d+)\.(\d+).*', QtVersion) if m is not None and list(map(int, m.groups())) < versionReq: diff --git a/pyqtgraph/WidgetGroup.py b/pyqtgraph/WidgetGroup.py index 29541454..17e2b2bd 100644 --- a/pyqtgraph/WidgetGroup.py +++ b/pyqtgraph/WidgetGroup.py @@ -8,7 +8,7 @@ This class addresses the problem of having to save and restore the state of a large group of widgets. """ -from .Qt import QtCore, QtGui +from .Qt import QtCore, QtGui, USE_PYQT5 import weakref, inspect from .python2_3 import asUnicode @@ -219,7 +219,9 @@ class WidgetGroup(QtCore.QObject): v2 = self.readWidget(w) if v1 != v2: #print "widget", n, " = ", v2 - self.emit(QtCore.SIGNAL('changed'), self.widgetList[w], v2) + if not USE_PYQT5: + #I don't think this line have any different from the next line + self.emit(QtCore.SIGNAL('changed'), self.widgetList[w], v2) self.sigChanged.emit(self.widgetList[w], v2) def state(self): diff --git a/pyqtgraph/console/Console.py b/pyqtgraph/console/Console.py index 6d77c4cf..421ff1d6 100644 --- a/pyqtgraph/console/Console.py +++ b/pyqtgraph/console/Console.py @@ -1,8 +1,10 @@ -from ..Qt import QtCore, QtGui, USE_PYSIDE +from ..Qt import QtCore, QtGui, USE_PYSIDE, USE_PYQT5 import sys, re, os, time, traceback, subprocess if USE_PYSIDE: from . import template_pyside as template +elif USE_PYQT5: + from . import template_pyqt5 as template else: from . import template_pyqt as template diff --git a/pyqtgraph/flowchart/Flowchart.py b/pyqtgraph/flowchart/Flowchart.py index 48357b30..680a6dde 100644 --- a/pyqtgraph/flowchart/Flowchart.py +++ b/pyqtgraph/flowchart/Flowchart.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from ..Qt import QtCore, QtGui, USE_PYSIDE +from ..Qt import QtCore, QtGui, USE_PYSIDE, USE_PYQT5 from .Node import * from ..pgcollections import OrderedDict from ..widgets.TreeWidget import * @@ -9,6 +9,9 @@ from .. import FileDialog, DataTreeWidget if USE_PYSIDE: from . import FlowchartTemplate_pyside as FlowchartTemplate from . import FlowchartCtrlTemplate_pyside as FlowchartCtrlTemplate +elif USE_PYQT5: + from . import FlowchartTemplate_pyqt5 as FlowchartTemplate + from . import FlowchartCtrlTemplate_pyqt5 as FlowchartCtrlTemplate else: from . import FlowchartTemplate_pyqt as FlowchartTemplate from . import FlowchartCtrlTemplate_pyqt as FlowchartCtrlTemplate @@ -648,7 +651,10 @@ class FlowchartCtrlWidget(QtGui.QWidget): self.cwWin.resize(1000,800) h = self.ui.ctrlList.header() - h.setResizeMode(0, h.Stretch) + if not USE_PYQT5: + h.setResizeMode(0, h.Stretch) + else: + h.setSectionResizeMode(0, h.Stretch) self.ui.ctrlList.itemChanged.connect(self.itemChanged) self.ui.loadBtn.clicked.connect(self.loadClicked) diff --git a/pyqtgraph/graphicsItems/FillBetweenItem.py b/pyqtgraph/graphicsItems/FillBetweenItem.py index d2ee393c..6f21df56 100644 --- a/pyqtgraph/graphicsItems/FillBetweenItem.py +++ b/pyqtgraph/graphicsItems/FillBetweenItem.py @@ -1,4 +1,4 @@ -from ..Qt import QtGui +from ..Qt import QtGui, USE_PYQT5, USE_PYQT4, USE_PYSIDE from .. import functions as fn from .PlotDataItem import PlotDataItem from .PlotCurveItem import PlotCurveItem @@ -14,23 +14,23 @@ class FillBetweenItem(QtGui.QGraphicsPathItem): self.setCurves(curve1, curve2) elif curve1 is not None or curve2 is not None: raise Exception("Must specify two curves to fill between.") - + if brush is not None: self.setBrush(fn.mkBrush(brush)) self.updatePath() def setCurves(self, curve1, curve2): """Set the curves to fill between. - + Arguments must be instances of PlotDataItem or PlotCurveItem.""" - + if self.curves is not None: for c in self.curves: try: c.sigPlotChanged.disconnect(self.curveChanged) except (TypeError, RuntimeError): pass - + curves = [curve1, curve2] for c in curves: if not isinstance(c, PlotDataItem) and not isinstance(c, PlotCurveItem): @@ -40,7 +40,7 @@ class FillBetweenItem(QtGui.QGraphicsPathItem): curve2.sigPlotChanged.connect(self.curveChanged) self.setZValue(min(curve1.zValue(), curve2.zValue())-1) self.curveChanged() - + def setBrush(self, *args, **kwds): """Change the fill brush. Acceps the same arguments as pg.mkBrush()""" QtGui.QGraphicsPathItem.setBrush(self, fn.mkBrush(*args, **kwds)) @@ -58,13 +58,14 @@ class FillBetweenItem(QtGui.QGraphicsPathItem): paths.append(c.curve.getPath()) elif isinstance(c, PlotCurveItem): paths.append(c.getPath()) - + path = QtGui.QPainterPath() - p1 = paths[0].toSubpathPolygons() - p2 = paths[1].toReversed().toSubpathPolygons() + transform = QtGui.QTransform() + p1 = paths[0].toSubpathPolygons(transform) + p2 = paths[1].toReversed().toSubpathPolygons(transform) if len(p1) == 0 or len(p2) == 0: self.setPath(QtGui.QPainterPath()) return - + path.addPolygon(p1[0] + p2[0]) self.setPath(path) diff --git a/pyqtgraph/graphicsItems/GradientEditorItem.py b/pyqtgraph/graphicsItems/GradientEditorItem.py index e16370f5..ef6eff6e 100644 --- a/pyqtgraph/graphicsItems/GradientEditorItem.py +++ b/pyqtgraph/graphicsItems/GradientEditorItem.py @@ -116,16 +116,20 @@ class TickSliderItem(GraphicsWidget): self.resetTransform() ort = orientation if ort == 'top': - self.scale(1, -1) - self.translate(0, -self.height()) + transform = QtGui.QTransform.fromScale(1, -1) + transform.translate(0, -self.height()) + self.setTransform(transform) elif ort == 'left': - self.rotate(270) - self.scale(1, -1) - self.translate(-self.height(), -self.maxDim) + transform = QtGui.QTransform() + transform.rotate(270) + transform.scale(1, -1) + transform.translate(-self.height(), -self.maxDim) + self.setTransform(transform) elif ort == 'right': - self.rotate(270) - self.translate(-self.height(), 0) - #self.setPos(0, -self.height()) + transform = QtGui.QTransform() + transform.rotate(270) + transform.translate(-self.height(), 0) + self.setTransform(transform) elif ort != 'bottom': raise Exception("%s is not a valid orientation. Options are 'left', 'right', 'top', and 'bottom'" %str(ort)) @@ -237,7 +241,7 @@ class TickSliderItem(GraphicsWidget): self.addTick(pos.x()/self.length) elif ev.button() == QtCore.Qt.RightButton: self.showMenu(ev) - + #if ev.button() == QtCore.Qt.RightButton: #if self.moving: #ev.accept() @@ -781,11 +785,15 @@ class GradientEditorItem(TickSliderItem): self.updateGradient() self.sigGradientChangeFinished.emit(self) - -class Tick(QtGui.QGraphicsObject): ## NOTE: Making this a subclass of GraphicsObject instead results in + +class Tick(QtGui.QGraphicsWidget): ## NOTE: Making this a subclass of GraphicsObject instead results in ## activating this bug: https://bugreports.qt-project.org/browse/PYSIDE-86 ## private class - + + # When making Tick a subclass of QtGui.QGraphicsObject as origin, + # ..GraphicsScene.items(self, *args) will get Tick object as a + # class of QtGui.QMultimediaWidgets.QGraphicsVideoItem in python2.7-PyQt5(5.4.0) + sigMoving = QtCore.Signal(object) sigMoved = QtCore.Signal(object) diff --git a/pyqtgraph/graphicsItems/ROI.py b/pyqtgraph/graphicsItems/ROI.py index 179dafdc..f028ca68 100644 --- a/pyqtgraph/graphicsItems/ROI.py +++ b/pyqtgraph/graphicsItems/ROI.py @@ -1008,7 +1008,7 @@ class ROI(GraphicsObject): #print " dataBounds:", dataBounds ## Intersect transformed ROI bounds with data bounds - intBounds = dataBounds.intersect(QtCore.QRectF(0, 0, dShape[0], dShape[1])) + intBounds = dataBounds.intersected(QtCore.QRectF(0, 0, dShape[0], dShape[1])) #print " intBounds:", intBounds ## Determine index values to use when referencing the array. diff --git a/pyqtgraph/graphicsItems/ScatterPlotItem.py b/pyqtgraph/graphicsItems/ScatterPlotItem.py index 1c11fcf9..b54fd446 100644 --- a/pyqtgraph/graphicsItems/ScatterPlotItem.py +++ b/pyqtgraph/graphicsItems/ScatterPlotItem.py @@ -1,4 +1,4 @@ -from ..Qt import QtGui, QtCore, USE_PYSIDE +from ..Qt import QtGui, QtCore, USE_PYSIDE, USE_PYQT5 from ..Point import Point from .. import functions as fn from .GraphicsItem import GraphicsItem @@ -752,7 +752,7 @@ class ScatterPlotItem(GraphicsObject): self.data['targetRect'][updateMask] = list(imap(QtCore.QRectF, updatePts[0,:], updatePts[1,:], width, width)) data = self.data[viewMask] - if USE_PYSIDE: + if USE_PYSIDE or USE_PYQT5: list(imap(p.drawPixmap, data['targetRect'], repeat(atlas), data['sourceRect'])) else: p.drawPixmapFragments(data['targetRect'].tolist(), data['sourceRect'].tolist(), atlas) diff --git a/pyqtgraph/opengl/GLViewWidget.py b/pyqtgraph/opengl/GLViewWidget.py index c71bb3c9..2e7b4263 100644 --- a/pyqtgraph/opengl/GLViewWidget.py +++ b/pyqtgraph/opengl/GLViewWidget.py @@ -1,4 +1,4 @@ -from ..Qt import QtCore, QtGui, QtOpenGL +from ..Qt import QtCore, QtGui, QtOpenGL, USE_PYQT5 from OpenGL.GL import * import OpenGL.GL.framebufferobjects as glfbo import numpy as np @@ -323,10 +323,17 @@ class GLViewWidget(QtOpenGL.QGLWidget): def wheelEvent(self, ev): - if (ev.modifiers() & QtCore.Qt.ControlModifier): - self.opts['fov'] *= 0.999**ev.delta() + delta = 0 + if not USE_PYQT5: + delta = ev.delta() else: - self.opts['distance'] *= 0.999**ev.delta() + delta = ev.angleDelta().x() + if delta == 0: + delta = ev.angleDelta().y() + if (ev.modifiers() & QtCore.Qt.ControlModifier): + self.opts['fov'] *= 0.999**delta + else: + self.opts['distance'] *= 0.999**delta self.update() def keyPressEvent(self, ev): From 00092d99d4eac9e027bded7fcdc3a99d55fea115 Mon Sep 17 00:00:00 2001 From: compass Date: Sat, 17 Jan 2015 18:34:30 +0800 Subject: [PATCH 07/11] Add pyqt5 support for MatplotlibWidget --- pyqtgraph/widgets/MatplotlibWidget.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pyqtgraph/widgets/MatplotlibWidget.py b/pyqtgraph/widgets/MatplotlibWidget.py index 959e188a..3de063fc 100644 --- a/pyqtgraph/widgets/MatplotlibWidget.py +++ b/pyqtgraph/widgets/MatplotlibWidget.py @@ -1,11 +1,16 @@ -from ..Qt import QtGui, QtCore, USE_PYSIDE +from ..Qt import QtGui, QtCore, USE_PYSIDE, USE_PYQT5 import matplotlib -if USE_PYSIDE: - matplotlib.rcParams['backend.qt4']='PySide' +if not USE_PYQT5: + if USE_PYSIDE: + matplotlib.rcParams['backend.qt4']='PySide' + + from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas + from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar +else: + from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas + from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar -from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas -from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar from matplotlib.figure import Figure class MatplotlibWidget(QtGui.QWidget): From 98f079d86ad8edc2f847a1d223e534ffff52609c Mon Sep 17 00:00:00 2001 From: compass Date: Sat, 17 Jan 2015 18:45:32 +0800 Subject: [PATCH 08/11] Add pyqt5 support for examples/__main__.py --- examples/__main__.py | 4 +- examples/exampleLoaderTemplate_pyqt5.py | 97 +++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 examples/exampleLoaderTemplate_pyqt5.py diff --git a/examples/__main__.py b/examples/__main__.py index e972c60a..8123a7e3 100644 --- a/examples/__main__.py +++ b/examples/__main__.py @@ -7,11 +7,13 @@ if __name__ == "__main__" and (__package__ is None or __package__==''): __package__ = "examples" from . import initExample -from pyqtgraph.Qt import QtCore, QtGui, USE_PYSIDE +from pyqtgraph.Qt import QtCore, QtGui, USE_PYSIDE, USE_PYQT5 import pyqtgraph as pg if USE_PYSIDE: from .exampleLoaderTemplate_pyside import Ui_Form +elif USE_PYQT5: + from .exampleLoaderTemplate_pyqt5 import Ui_Form else: from .exampleLoaderTemplate_pyqt import Ui_Form diff --git a/examples/exampleLoaderTemplate_pyqt5.py b/examples/exampleLoaderTemplate_pyqt5.py new file mode 100644 index 00000000..24bfe79c --- /dev/null +++ b/examples/exampleLoaderTemplate_pyqt5.py @@ -0,0 +1,97 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file './exampleLoaderTemplate.ui' +# +# Created: Mon Feb 25 09:02:09 2013 +# by: PyQt4 UI code generator 4.9.3 +# +# WARNING! All changes made in this file will be lost! + +from PyQt5 import QtCore, QtGui, QtWidgets + +try: + _fromUtf8 = QtCore.QString.fromUtf8 +except AttributeError: + _fromUtf8 = lambda s: s + +class Ui_Form(object): + def setupUi(self, Form): + Form.setObjectName(_fromUtf8("Form")) + Form.resize(623, 380) + self.gridLayout = QtGui.QGridLayout(Form) + self.gridLayout.setMargin(0) + self.gridLayout.setSpacing(0) + self.gridLayout.setObjectName(_fromUtf8("gridLayout")) + self.splitter = QtGui.QSplitter(Form) + self.splitter.setOrientation(QtCore.Qt.Horizontal) + self.splitter.setObjectName(_fromUtf8("splitter")) + self.widget = QtGui.QWidget(self.splitter) + self.widget.setObjectName(_fromUtf8("widget")) + self.verticalLayout = QtGui.QVBoxLayout(self.widget) + # self.verticalLayout.setMargin(0) + self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) + self.exampleTree = QtGui.QTreeWidget(self.widget) + self.exampleTree.setObjectName(_fromUtf8("exampleTree")) + self.exampleTree.headerItem().setText(0, _fromUtf8("1")) + self.exampleTree.header().setVisible(False) + self.verticalLayout.addWidget(self.exampleTree) + self.horizontalLayout = QtGui.QHBoxLayout() + self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) + self.pyqtCheck = QtGui.QCheckBox(self.widget) + self.pyqtCheck.setObjectName(_fromUtf8("pyqtCheck")) + self.horizontalLayout.addWidget(self.pyqtCheck) + self.pysideCheck = QtGui.QCheckBox(self.widget) + self.pysideCheck.setObjectName(_fromUtf8("pysideCheck")) + self.horizontalLayout.addWidget(self.pysideCheck) + self.verticalLayout.addLayout(self.horizontalLayout) + self.horizontalLayout_2 = QtGui.QHBoxLayout() + self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) + self.forceGraphicsCheck = QtGui.QCheckBox(self.widget) + self.forceGraphicsCheck.setObjectName(_fromUtf8("forceGraphicsCheck")) + self.horizontalLayout_2.addWidget(self.forceGraphicsCheck) + self.forceGraphicsCombo = QtGui.QComboBox(self.widget) + self.forceGraphicsCombo.setObjectName(_fromUtf8("forceGraphicsCombo")) + self.forceGraphicsCombo.addItem(_fromUtf8("")) + self.forceGraphicsCombo.addItem(_fromUtf8("")) + self.forceGraphicsCombo.addItem(_fromUtf8("")) + self.horizontalLayout_2.addWidget(self.forceGraphicsCombo) + self.verticalLayout.addLayout(self.horizontalLayout_2) + self.loadBtn = QtGui.QPushButton(self.widget) + self.loadBtn.setObjectName(_fromUtf8("loadBtn")) + self.verticalLayout.addWidget(self.loadBtn) + self.widget1 = QtGui.QWidget(self.splitter) + self.widget1.setObjectName(_fromUtf8("widget1")) + self.verticalLayout_2 = QtGui.QVBoxLayout(self.widget1) + # self.verticalLayout_2.setMargin(0) + self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) + self.loadedFileLabel = QtGui.QLabel(self.widget1) + font = QtGui.QFont() + font.setBold(True) + font.setWeight(75) + self.loadedFileLabel.setFont(font) + self.loadedFileLabel.setText(_fromUtf8("")) + self.loadedFileLabel.setAlignment(QtCore.Qt.AlignCenter) + self.loadedFileLabel.setObjectName(_fromUtf8("loadedFileLabel")) + self.verticalLayout_2.addWidget(self.loadedFileLabel) + self.codeView = QtGui.QPlainTextEdit(self.widget1) + font = QtGui.QFont() + font.setFamily(_fromUtf8("FreeMono")) + self.codeView.setFont(font) + self.codeView.setObjectName(_fromUtf8("codeView")) + self.verticalLayout_2.addWidget(self.codeView) + self.gridLayout.addWidget(self.splitter, 0, 0, 1, 1) + + self.retranslateUi(Form) + QtCore.QMetaObject.connectSlotsByName(Form) + + def retranslateUi(self, Form): + # Form.setWindowTitle(QtWidgets.QApplication.translate("Form", "Form", None, QtWidgets.QApplication.UnicodeUTF8)) + # self.pyqtCheck.setText(QtWidgets.QApplication.translate("Form", "Force PyQt", None, QtWidgets.QApplication.UnicodeUTF8)) + # self.pysideCheck.setText(QtWidgets.QApplication.translate("Form", "Force PySide", None, QtWidgets.QApplication.UnicodeUTF8)) + # self.forceGraphicsCheck.setText(QtWidgets.QApplication.translate("Form", "Force Graphics System:", None, QtWidgets.QApplication.UnicodeUTF8)) + # self.forceGraphicsCombo.setItemText(0, QtWidgets.QApplication.translate("Form", "native", None, QtWidgets.QApplication.UnicodeUTF8)) + # self.forceGraphicsCombo.setItemText(1, QtWidgets.QApplication.translate("Form", "raster", None, QtWidgets.QApplication.UnicodeUTF8)) + # self.forceGraphicsCombo.setItemText(2, QtWidgets.QApplication.translate("Form", "opengl", None, QtWidgets.QApplication.UnicodeUTF8)) + # self.loadBtn.setText(QtWidgets.QApplication.translate("Form", "Run Example", None, QtWidgets.QApplication.UnicodeUTF8)) + pass + From 058dd183d3043e721afb64f05800a0b3ad2cbf37 Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Sat, 28 Feb 2015 10:32:34 -0500 Subject: [PATCH 09/11] Cleaned up example loader --- examples/__main__.py | 30 +---- examples/exampleLoaderTemplate.ui | 110 ++++++++++--------- examples/exampleLoaderTemplate_pyqt.py | 108 +++++++++--------- examples/exampleLoaderTemplate_pyqt5.py | 89 +++++++-------- examples/exampleLoaderTemplate_pyside.py | 93 ++++++++-------- examples/initExample.py | 6 + pyqtgraph/Qt.py | 37 ++++--- pyqtgraph/exporters/SVGExporter.py | 35 ------ pyqtgraph/graphicsItems/PlotItem/PlotItem.py | 41 +------ 9 files changed, 246 insertions(+), 303 deletions(-) diff --git a/examples/__main__.py b/examples/__main__.py index 8123a7e3..52048593 100644 --- a/examples/__main__.py +++ b/examples/__main__.py @@ -118,20 +118,9 @@ class ExampleLoader(QtGui.QMainWindow): self.ui.loadBtn.clicked.connect(self.loadFile) self.ui.exampleTree.currentItemChanged.connect(self.showFile) self.ui.exampleTree.itemDoubleClicked.connect(self.loadFile) - self.ui.pyqtCheck.toggled.connect(self.pyqtToggled) - self.ui.pysideCheck.toggled.connect(self.pysideToggled) self.ui.codeView.textChanged.connect(self.codeEdited) self.codeBtn.clicked.connect(self.runEditedCode) - def pyqtToggled(self, b): - if b: - self.ui.pysideCheck.setChecked(False) - - def pysideToggled(self, b): - if b: - self.ui.pyqtCheck.setChecked(False) - - def populateTree(self, root, examples): for key, val in examples.items(): item = QtGui.QTreeWidgetItem([key]) @@ -143,7 +132,6 @@ class ExampleLoader(QtGui.QMainWindow): else: self.populateTree(item, val) root.addChild(item) - def currentFile(self): item = self.ui.exampleTree.currentItem() @@ -155,19 +143,13 @@ class ExampleLoader(QtGui.QMainWindow): def loadFile(self, edited=False): extra = [] - if self.ui.pyqtCheck.isChecked(): - extra.append('pyqt') - elif self.ui.pysideCheck.isChecked(): - extra.append('pyside') + qtLib = str(self.ui.qtLibCombo.currentText()) + gfxSys = str(self.ui.graphicsSystemCombo.currentText()) - if self.ui.forceGraphicsCheck.isChecked(): - extra.append(str(self.ui.forceGraphicsCombo.currentText())) - - - #if sys.platform.startswith('win'): - #os.spawnl(os.P_NOWAIT, sys.executable, '"'+sys.executable+'"', '"' + fn + '"', *extra) - #else: - #os.spawnl(os.P_NOWAIT, sys.executable, sys.executable, fn, *extra) + if qtLib != 'default': + extra.append(qtLib.lower()) + elif gfxSys != 'default': + extra.append(gfxSys) if edited: path = os.path.abspath(os.path.dirname(__file__)) diff --git a/examples/exampleLoaderTemplate.ui b/examples/exampleLoaderTemplate.ui index 2da57800..a1d6bc19 100644 --- a/examples/exampleLoaderTemplate.ui +++ b/examples/exampleLoaderTemplate.ui @@ -6,28 +6,22 @@ 0 0 - 623 - 380 + 846 + 552 Form - - - 0 - - - 0 - + Qt::Horizontal - - + + false @@ -39,55 +33,69 @@ - - + + - - - Force PyQt - - + + default + - - - Force PySide - - + + native + - + + + raster + + + + + opengl + + + - - + + - - - Force Graphics System: - - + + default + - - - - native - - - - - raster - - - - - opengl - - - + + PyQt4 + - + + + PySide + + + + + PyQt5 + + + - + + + + Graphics System: + + + + + + + Qt Library: + + + + Run Example @@ -97,7 +105,7 @@ - + diff --git a/examples/exampleLoaderTemplate_pyqt.py b/examples/exampleLoaderTemplate_pyqt.py index 836640c6..708839f5 100644 --- a/examples/exampleLoaderTemplate_pyqt.py +++ b/examples/exampleLoaderTemplate_pyqt.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- -# Form implementation generated from reading ui file './exampleLoaderTemplate.ui' +# Form implementation generated from reading ui file 'exampleLoaderTemplate.ui' # -# Created: Mon Feb 25 09:02:09 2013 -# by: PyQt4 UI code generator 4.9.3 +# Created: Sat Feb 28 10:30:29 2015 +# by: PyQt4 UI code generator 4.10.4 # # WARNING! All changes made in this file will be lost! @@ -12,58 +12,64 @@ from PyQt4 import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: - _fromUtf8 = lambda s: s + def _fromUtf8(s): + return s + +try: + _encoding = QtGui.QApplication.UnicodeUTF8 + def _translate(context, text, disambig): + return QtGui.QApplication.translate(context, text, disambig, _encoding) +except AttributeError: + def _translate(context, text, disambig): + return QtGui.QApplication.translate(context, text, disambig) class Ui_Form(object): def setupUi(self, Form): Form.setObjectName(_fromUtf8("Form")) - Form.resize(623, 380) - self.gridLayout = QtGui.QGridLayout(Form) - self.gridLayout.setMargin(0) - self.gridLayout.setSpacing(0) - self.gridLayout.setObjectName(_fromUtf8("gridLayout")) + Form.resize(846, 552) + self.gridLayout_2 = QtGui.QGridLayout(Form) + self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2")) self.splitter = QtGui.QSplitter(Form) self.splitter.setOrientation(QtCore.Qt.Horizontal) self.splitter.setObjectName(_fromUtf8("splitter")) self.widget = QtGui.QWidget(self.splitter) self.widget.setObjectName(_fromUtf8("widget")) - self.verticalLayout = QtGui.QVBoxLayout(self.widget) - self.verticalLayout.setMargin(0) - self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) + self.gridLayout = QtGui.QGridLayout(self.widget) + self.gridLayout.setMargin(0) + self.gridLayout.setObjectName(_fromUtf8("gridLayout")) self.exampleTree = QtGui.QTreeWidget(self.widget) self.exampleTree.setObjectName(_fromUtf8("exampleTree")) self.exampleTree.headerItem().setText(0, _fromUtf8("1")) self.exampleTree.header().setVisible(False) - self.verticalLayout.addWidget(self.exampleTree) - self.horizontalLayout = QtGui.QHBoxLayout() - self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) - self.pyqtCheck = QtGui.QCheckBox(self.widget) - self.pyqtCheck.setObjectName(_fromUtf8("pyqtCheck")) - self.horizontalLayout.addWidget(self.pyqtCheck) - self.pysideCheck = QtGui.QCheckBox(self.widget) - self.pysideCheck.setObjectName(_fromUtf8("pysideCheck")) - self.horizontalLayout.addWidget(self.pysideCheck) - self.verticalLayout.addLayout(self.horizontalLayout) - self.horizontalLayout_2 = QtGui.QHBoxLayout() - self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) - self.forceGraphicsCheck = QtGui.QCheckBox(self.widget) - self.forceGraphicsCheck.setObjectName(_fromUtf8("forceGraphicsCheck")) - self.horizontalLayout_2.addWidget(self.forceGraphicsCheck) - self.forceGraphicsCombo = QtGui.QComboBox(self.widget) - self.forceGraphicsCombo.setObjectName(_fromUtf8("forceGraphicsCombo")) - self.forceGraphicsCombo.addItem(_fromUtf8("")) - self.forceGraphicsCombo.addItem(_fromUtf8("")) - self.forceGraphicsCombo.addItem(_fromUtf8("")) - self.horizontalLayout_2.addWidget(self.forceGraphicsCombo) - self.verticalLayout.addLayout(self.horizontalLayout_2) + self.gridLayout.addWidget(self.exampleTree, 0, 0, 1, 2) + self.graphicsSystemCombo = QtGui.QComboBox(self.widget) + self.graphicsSystemCombo.setObjectName(_fromUtf8("graphicsSystemCombo")) + self.graphicsSystemCombo.addItem(_fromUtf8("")) + self.graphicsSystemCombo.addItem(_fromUtf8("")) + self.graphicsSystemCombo.addItem(_fromUtf8("")) + self.graphicsSystemCombo.addItem(_fromUtf8("")) + self.gridLayout.addWidget(self.graphicsSystemCombo, 2, 1, 1, 1) + self.qtLibCombo = QtGui.QComboBox(self.widget) + self.qtLibCombo.setObjectName(_fromUtf8("qtLibCombo")) + self.qtLibCombo.addItem(_fromUtf8("")) + self.qtLibCombo.addItem(_fromUtf8("")) + self.qtLibCombo.addItem(_fromUtf8("")) + self.qtLibCombo.addItem(_fromUtf8("")) + self.gridLayout.addWidget(self.qtLibCombo, 1, 1, 1, 1) + self.label_2 = QtGui.QLabel(self.widget) + self.label_2.setObjectName(_fromUtf8("label_2")) + self.gridLayout.addWidget(self.label_2, 2, 0, 1, 1) + self.label = QtGui.QLabel(self.widget) + self.label.setObjectName(_fromUtf8("label")) + self.gridLayout.addWidget(self.label, 1, 0, 1, 1) self.loadBtn = QtGui.QPushButton(self.widget) self.loadBtn.setObjectName(_fromUtf8("loadBtn")) - self.verticalLayout.addWidget(self.loadBtn) + self.gridLayout.addWidget(self.loadBtn, 3, 1, 1, 1) self.widget1 = QtGui.QWidget(self.splitter) self.widget1.setObjectName(_fromUtf8("widget1")) - self.verticalLayout_2 = QtGui.QVBoxLayout(self.widget1) - self.verticalLayout_2.setMargin(0) - self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) + self.verticalLayout = QtGui.QVBoxLayout(self.widget1) + self.verticalLayout.setMargin(0) + self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.loadedFileLabel = QtGui.QLabel(self.widget1) font = QtGui.QFont() font.setBold(True) @@ -72,25 +78,29 @@ class Ui_Form(object): self.loadedFileLabel.setText(_fromUtf8("")) self.loadedFileLabel.setAlignment(QtCore.Qt.AlignCenter) self.loadedFileLabel.setObjectName(_fromUtf8("loadedFileLabel")) - self.verticalLayout_2.addWidget(self.loadedFileLabel) + self.verticalLayout.addWidget(self.loadedFileLabel) self.codeView = QtGui.QPlainTextEdit(self.widget1) font = QtGui.QFont() font.setFamily(_fromUtf8("FreeMono")) self.codeView.setFont(font) self.codeView.setObjectName(_fromUtf8("codeView")) - self.verticalLayout_2.addWidget(self.codeView) - self.gridLayout.addWidget(self.splitter, 0, 0, 1, 1) + self.verticalLayout.addWidget(self.codeView) + self.gridLayout_2.addWidget(self.splitter, 0, 0, 1, 1) self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form) def retranslateUi(self, Form): - Form.setWindowTitle(QtGui.QApplication.translate("Form", "Form", None, QtGui.QApplication.UnicodeUTF8)) - self.pyqtCheck.setText(QtGui.QApplication.translate("Form", "Force PyQt", None, QtGui.QApplication.UnicodeUTF8)) - self.pysideCheck.setText(QtGui.QApplication.translate("Form", "Force PySide", None, QtGui.QApplication.UnicodeUTF8)) - self.forceGraphicsCheck.setText(QtGui.QApplication.translate("Form", "Force Graphics System:", None, QtGui.QApplication.UnicodeUTF8)) - self.forceGraphicsCombo.setItemText(0, QtGui.QApplication.translate("Form", "native", None, QtGui.QApplication.UnicodeUTF8)) - self.forceGraphicsCombo.setItemText(1, QtGui.QApplication.translate("Form", "raster", None, QtGui.QApplication.UnicodeUTF8)) - self.forceGraphicsCombo.setItemText(2, QtGui.QApplication.translate("Form", "opengl", None, QtGui.QApplication.UnicodeUTF8)) - self.loadBtn.setText(QtGui.QApplication.translate("Form", "Run Example", None, QtGui.QApplication.UnicodeUTF8)) + Form.setWindowTitle(_translate("Form", "Form", None)) + self.graphicsSystemCombo.setItemText(0, _translate("Form", "default", None)) + self.graphicsSystemCombo.setItemText(1, _translate("Form", "native", None)) + self.graphicsSystemCombo.setItemText(2, _translate("Form", "raster", None)) + self.graphicsSystemCombo.setItemText(3, _translate("Form", "opengl", None)) + self.qtLibCombo.setItemText(0, _translate("Form", "default", None)) + self.qtLibCombo.setItemText(1, _translate("Form", "PyQt4", None)) + self.qtLibCombo.setItemText(2, _translate("Form", "PySide", None)) + self.qtLibCombo.setItemText(3, _translate("Form", "PyQt5", None)) + self.label_2.setText(_translate("Form", "Graphics System:", None)) + self.label.setText(_translate("Form", "Qt Library:", None)) + self.loadBtn.setText(_translate("Form", "Run Example", None)) diff --git a/examples/exampleLoaderTemplate_pyqt5.py b/examples/exampleLoaderTemplate_pyqt5.py index 29afb687..29c00325 100644 --- a/examples/exampleLoaderTemplate_pyqt5.py +++ b/examples/exampleLoaderTemplate_pyqt5.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'exampleLoaderTemplate.ui' # -# Created: Sat Feb 28 09:38:17 2015 +# Created: Sat Feb 28 10:28:50 2015 # by: PyQt5 UI code generator 5.2.1 # # WARNING! All changes made in this file will be lost! @@ -12,53 +12,50 @@ from PyQt5 import QtCore, QtGui, QtWidgets class Ui_Form(object): def setupUi(self, Form): Form.setObjectName("Form") - Form.resize(623, 380) - self.gridLayout = QtWidgets.QGridLayout(Form) - self.gridLayout.setContentsMargins(0, 0, 0, 0) - self.gridLayout.setSpacing(0) - self.gridLayout.setObjectName("gridLayout") + Form.resize(846, 552) + 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.verticalLayout = QtWidgets.QVBoxLayout(self.widget) - self.verticalLayout.setContentsMargins(0, 0, 0, 0) - self.verticalLayout.setObjectName("verticalLayout") + self.gridLayout = QtWidgets.QGridLayout(self.widget) + self.gridLayout.setContentsMargins(0, 0, 0, 0) + 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.verticalLayout.addWidget(self.exampleTree) - self.horizontalLayout = QtWidgets.QHBoxLayout() - self.horizontalLayout.setObjectName("horizontalLayout") - self.pyqtCheck = QtWidgets.QCheckBox(self.widget) - self.pyqtCheck.setObjectName("pyqtCheck") - self.horizontalLayout.addWidget(self.pyqtCheck) - self.pysideCheck = QtWidgets.QCheckBox(self.widget) - self.pysideCheck.setObjectName("pysideCheck") - self.horizontalLayout.addWidget(self.pysideCheck) - self.verticalLayout.addLayout(self.horizontalLayout) - self.horizontalLayout_2 = QtWidgets.QHBoxLayout() - self.horizontalLayout_2.setObjectName("horizontalLayout_2") - self.forceGraphicsCheck = QtWidgets.QCheckBox(self.widget) - self.forceGraphicsCheck.setObjectName("forceGraphicsCheck") - self.horizontalLayout_2.addWidget(self.forceGraphicsCheck) - self.forceGraphicsCombo = QtWidgets.QComboBox(self.widget) - self.forceGraphicsCombo.setObjectName("forceGraphicsCombo") - self.forceGraphicsCombo.addItem("") - self.forceGraphicsCombo.addItem("") - self.forceGraphicsCombo.addItem("") - self.horizontalLayout_2.addWidget(self.forceGraphicsCombo) - self.verticalLayout.addLayout(self.horizontalLayout_2) + 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("") + self.qtLibCombo.addItem("") + 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) self.loadBtn = QtWidgets.QPushButton(self.widget) self.loadBtn.setObjectName("loadBtn") - self.verticalLayout.addWidget(self.loadBtn) + self.gridLayout.addWidget(self.loadBtn, 3, 1, 1, 1) self.widget1 = QtWidgets.QWidget(self.splitter) self.widget1.setObjectName("widget1") - self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.widget1) - self.verticalLayout_2.setContentsMargins(0, 0, 0, 0) - self.verticalLayout_2.setObjectName("verticalLayout_2") + self.verticalLayout = QtWidgets.QVBoxLayout(self.widget1) + self.verticalLayout.setContentsMargins(0, 0, 0, 0) + self.verticalLayout.setObjectName("verticalLayout") self.loadedFileLabel = QtWidgets.QLabel(self.widget1) font = QtGui.QFont() font.setBold(True) @@ -67,14 +64,14 @@ class Ui_Form(object): self.loadedFileLabel.setText("") self.loadedFileLabel.setAlignment(QtCore.Qt.AlignCenter) self.loadedFileLabel.setObjectName("loadedFileLabel") - self.verticalLayout_2.addWidget(self.loadedFileLabel) + self.verticalLayout.addWidget(self.loadedFileLabel) self.codeView = QtWidgets.QPlainTextEdit(self.widget1) font = QtGui.QFont() font.setFamily("FreeMono") self.codeView.setFont(font) self.codeView.setObjectName("codeView") - self.verticalLayout_2.addWidget(self.codeView) - self.gridLayout.addWidget(self.splitter, 0, 0, 1, 1) + self.verticalLayout.addWidget(self.codeView) + self.gridLayout_2.addWidget(self.splitter, 0, 0, 1, 1) self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form) @@ -82,11 +79,15 @@ class Ui_Form(object): def retranslateUi(self, Form): _translate = QtCore.QCoreApplication.translate Form.setWindowTitle(_translate("Form", "Form")) - self.pyqtCheck.setText(_translate("Form", "Force PyQt")) - self.pysideCheck.setText(_translate("Form", "Force PySide")) - self.forceGraphicsCheck.setText(_translate("Form", "Force Graphics System:")) - self.forceGraphicsCombo.setItemText(0, _translate("Form", "native")) - self.forceGraphicsCombo.setItemText(1, _translate("Form", "raster")) - self.forceGraphicsCombo.setItemText(2, _translate("Form", "opengl")) + 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", "PyQt4")) + self.qtLibCombo.setItemText(2, _translate("Form", "PySide")) + self.qtLibCombo.setItemText(3, _translate("Form", "PyQt5")) + 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_pyside.py b/examples/exampleLoaderTemplate_pyside.py index f596e566..61f1d09f 100644 --- a/examples/exampleLoaderTemplate_pyside.py +++ b/examples/exampleLoaderTemplate_pyside.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- -# Form implementation generated from reading ui file './exampleLoaderTemplate.ui' +# Form implementation generated from reading ui file 'exampleLoaderTemplate.ui' # -# Created: Mon Feb 25 09:02:09 2013 -# by: pyside-uic 0.2.13 running on PySide 1.1.1 +# Created: Sat Feb 28 10:31:57 2015 +# by: pyside-uic 0.2.15 running on PySide 1.2.1 # # WARNING! All changes made in this file will be lost! @@ -12,53 +12,50 @@ from PySide import QtCore, QtGui class Ui_Form(object): def setupUi(self, Form): Form.setObjectName("Form") - Form.resize(623, 380) - self.gridLayout = QtGui.QGridLayout(Form) - self.gridLayout.setContentsMargins(0, 0, 0, 0) - self.gridLayout.setSpacing(0) - self.gridLayout.setObjectName("gridLayout") + Form.resize(846, 552) + self.gridLayout_2 = QtGui.QGridLayout(Form) + self.gridLayout_2.setObjectName("gridLayout_2") self.splitter = QtGui.QSplitter(Form) self.splitter.setOrientation(QtCore.Qt.Horizontal) self.splitter.setObjectName("splitter") self.widget = QtGui.QWidget(self.splitter) self.widget.setObjectName("widget") - self.verticalLayout = QtGui.QVBoxLayout(self.widget) - self.verticalLayout.setContentsMargins(0, 0, 0, 0) - self.verticalLayout.setObjectName("verticalLayout") + self.gridLayout = QtGui.QGridLayout(self.widget) + self.gridLayout.setContentsMargins(0, 0, 0, 0) + self.gridLayout.setObjectName("gridLayout") self.exampleTree = QtGui.QTreeWidget(self.widget) self.exampleTree.setObjectName("exampleTree") self.exampleTree.headerItem().setText(0, "1") self.exampleTree.header().setVisible(False) - self.verticalLayout.addWidget(self.exampleTree) - self.horizontalLayout = QtGui.QHBoxLayout() - self.horizontalLayout.setObjectName("horizontalLayout") - self.pyqtCheck = QtGui.QCheckBox(self.widget) - self.pyqtCheck.setObjectName("pyqtCheck") - self.horizontalLayout.addWidget(self.pyqtCheck) - self.pysideCheck = QtGui.QCheckBox(self.widget) - self.pysideCheck.setObjectName("pysideCheck") - self.horizontalLayout.addWidget(self.pysideCheck) - self.verticalLayout.addLayout(self.horizontalLayout) - self.horizontalLayout_2 = QtGui.QHBoxLayout() - self.horizontalLayout_2.setObjectName("horizontalLayout_2") - self.forceGraphicsCheck = QtGui.QCheckBox(self.widget) - self.forceGraphicsCheck.setObjectName("forceGraphicsCheck") - self.horizontalLayout_2.addWidget(self.forceGraphicsCheck) - self.forceGraphicsCombo = QtGui.QComboBox(self.widget) - self.forceGraphicsCombo.setObjectName("forceGraphicsCombo") - self.forceGraphicsCombo.addItem("") - self.forceGraphicsCombo.addItem("") - self.forceGraphicsCombo.addItem("") - self.horizontalLayout_2.addWidget(self.forceGraphicsCombo) - self.verticalLayout.addLayout(self.horizontalLayout_2) + self.gridLayout.addWidget(self.exampleTree, 0, 0, 1, 2) + self.graphicsSystemCombo = QtGui.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 = QtGui.QComboBox(self.widget) + self.qtLibCombo.setObjectName("qtLibCombo") + self.qtLibCombo.addItem("") + self.qtLibCombo.addItem("") + self.qtLibCombo.addItem("") + self.qtLibCombo.addItem("") + self.gridLayout.addWidget(self.qtLibCombo, 1, 1, 1, 1) + self.label_2 = QtGui.QLabel(self.widget) + self.label_2.setObjectName("label_2") + self.gridLayout.addWidget(self.label_2, 2, 0, 1, 1) + self.label = QtGui.QLabel(self.widget) + self.label.setObjectName("label") + self.gridLayout.addWidget(self.label, 1, 0, 1, 1) self.loadBtn = QtGui.QPushButton(self.widget) self.loadBtn.setObjectName("loadBtn") - self.verticalLayout.addWidget(self.loadBtn) + self.gridLayout.addWidget(self.loadBtn, 3, 1, 1, 1) self.widget1 = QtGui.QWidget(self.splitter) self.widget1.setObjectName("widget1") - self.verticalLayout_2 = QtGui.QVBoxLayout(self.widget1) - self.verticalLayout_2.setContentsMargins(0, 0, 0, 0) - self.verticalLayout_2.setObjectName("verticalLayout_2") + self.verticalLayout = QtGui.QVBoxLayout(self.widget1) + self.verticalLayout.setContentsMargins(0, 0, 0, 0) + self.verticalLayout.setObjectName("verticalLayout") self.loadedFileLabel = QtGui.QLabel(self.widget1) font = QtGui.QFont() font.setWeight(75) @@ -67,25 +64,29 @@ class Ui_Form(object): self.loadedFileLabel.setText("") self.loadedFileLabel.setAlignment(QtCore.Qt.AlignCenter) self.loadedFileLabel.setObjectName("loadedFileLabel") - self.verticalLayout_2.addWidget(self.loadedFileLabel) + self.verticalLayout.addWidget(self.loadedFileLabel) self.codeView = QtGui.QPlainTextEdit(self.widget1) font = QtGui.QFont() font.setFamily("FreeMono") self.codeView.setFont(font) self.codeView.setObjectName("codeView") - self.verticalLayout_2.addWidget(self.codeView) - self.gridLayout.addWidget(self.splitter, 0, 0, 1, 1) + self.verticalLayout.addWidget(self.codeView) + self.gridLayout_2.addWidget(self.splitter, 0, 0, 1, 1) self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form) def retranslateUi(self, Form): Form.setWindowTitle(QtGui.QApplication.translate("Form", "Form", None, QtGui.QApplication.UnicodeUTF8)) - self.pyqtCheck.setText(QtGui.QApplication.translate("Form", "Force PyQt", None, QtGui.QApplication.UnicodeUTF8)) - self.pysideCheck.setText(QtGui.QApplication.translate("Form", "Force PySide", None, QtGui.QApplication.UnicodeUTF8)) - self.forceGraphicsCheck.setText(QtGui.QApplication.translate("Form", "Force Graphics System:", None, QtGui.QApplication.UnicodeUTF8)) - self.forceGraphicsCombo.setItemText(0, QtGui.QApplication.translate("Form", "native", None, QtGui.QApplication.UnicodeUTF8)) - self.forceGraphicsCombo.setItemText(1, QtGui.QApplication.translate("Form", "raster", None, QtGui.QApplication.UnicodeUTF8)) - self.forceGraphicsCombo.setItemText(2, QtGui.QApplication.translate("Form", "opengl", None, QtGui.QApplication.UnicodeUTF8)) + self.graphicsSystemCombo.setItemText(0, QtGui.QApplication.translate("Form", "default", None, QtGui.QApplication.UnicodeUTF8)) + self.graphicsSystemCombo.setItemText(1, QtGui.QApplication.translate("Form", "native", None, QtGui.QApplication.UnicodeUTF8)) + self.graphicsSystemCombo.setItemText(2, QtGui.QApplication.translate("Form", "raster", None, QtGui.QApplication.UnicodeUTF8)) + self.graphicsSystemCombo.setItemText(3, QtGui.QApplication.translate("Form", "opengl", None, QtGui.QApplication.UnicodeUTF8)) + self.qtLibCombo.setItemText(0, QtGui.QApplication.translate("Form", "default", None, QtGui.QApplication.UnicodeUTF8)) + self.qtLibCombo.setItemText(1, QtGui.QApplication.translate("Form", "PyQt4", None, QtGui.QApplication.UnicodeUTF8)) + self.qtLibCombo.setItemText(2, QtGui.QApplication.translate("Form", "PySide", None, QtGui.QApplication.UnicodeUTF8)) + self.qtLibCombo.setItemText(3, QtGui.QApplication.translate("Form", "PyQt5", None, QtGui.QApplication.UnicodeUTF8)) + self.label_2.setText(QtGui.QApplication.translate("Form", "Graphics System:", None, QtGui.QApplication.UnicodeUTF8)) + self.label.setText(QtGui.QApplication.translate("Form", "Qt Library:", None, QtGui.QApplication.UnicodeUTF8)) self.loadBtn.setText(QtGui.QApplication.translate("Form", "Run Example", None, QtGui.QApplication.UnicodeUTF8)) diff --git a/examples/initExample.py b/examples/initExample.py index 3dcb5ba2..c10de84e 100644 --- a/examples/initExample.py +++ b/examples/initExample.py @@ -28,13 +28,19 @@ elif 'pyqt5' in sys.argv: from PyQt5 import QtGui 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)) + ## Enable fault handling to give more helpful error messages on crash. ## Only available in python 3.3+ try: diff --git a/pyqtgraph/Qt.py b/pyqtgraph/Qt.py index ddf486fe..5fdce579 100644 --- a/pyqtgraph/Qt.py +++ b/pyqtgraph/Qt.py @@ -20,7 +20,7 @@ QT_LIB = None ## Automatically determine whether to use PyQt or PySide. ## This is done by first checking to see whether one of the libraries ## is already imported. If not, then attempt to import PyQt4, then PySide. -libOrder = [PYQT5, PYQT4, PYSIDE] +libOrder = [PYQT4, PYSIDE, PYQT5] for lib in libOrder: if lib in sys.modules: @@ -36,8 +36,6 @@ if QT_LIB is None: except ImportError: pass -print(QT_LIB) - if QT_LIB == None: raise Exception("PyQtGraph requires one of PyQt4, PyQt5 or PySide; none of these packages could be imported.") @@ -124,24 +122,30 @@ elif QT_LIB == PYQT5: # Re-implement deprecated APIs def scale(self, sx, sy): - self.setTransform(QtGui.QTransform.fromScale(sx, sy), True) + tr = self.transform() + tr.scale(sx, sy) + self.setTransform(tr) QtWidgets.QGraphicsItem.scale = scale def rotate(self, angle): - self.setRotation(self.rotation() + angle) + tr = self.transform() + tr.rotate(angle) + self.setTransform(tr) QtWidgets.QGraphicsItem.rotate = rotate def translate(self, dx, dy): - self.setTransform(QtGui.QTransform.fromTranslate(dx, dy), True) + tr = self.transform() + tr.translate(dx, dy) + self.setTransform(tr) QtWidgets.QGraphicsItem.translate = translate - def setMargin(self, i): - self.setContentsMargins(i, i, i, i) - QtWidgets.QGridLayout.setMargin = setMargin + #def setMargin(self, i): + #self.setContentsMargins(i, i, i, i) + #QtWidgets.QGridLayout.setMargin = setMargin - def setResizeMode(self, mode): - self.setSectionResizeMode(mode) - QtWidgets.QHeaderView.setResizeMode = setResizeMode + #def setResizeMode(self, mode): + #self.setSectionResizeMode(mode) + #QtWidgets.QHeaderView.setResizeMode = setResizeMode QtGui.QApplication = QtWidgets.QApplication @@ -171,12 +175,11 @@ if QT_LIB.startswith('PyQt'): ## Make sure we have Qt >= 4.7 versionReq = [4, 7] -USE_PYSIDE = QT_LIB == PYSIDE # for backward compatibility -USE_PYQT5 = QT_LIB == PYQT5 # for backward compatibility -USE_PYQT4 = QT_LIB == PYQT4 # for backward compatibility -QtVersion = PySide.QtCore.__version__ if QT_LIB == PYSIDE else QtCore.QT_VERSION_STR +USE_PYSIDE = QT_LIB == PYSIDE +USE_PYQT4 = QT_LIB == PYQT4 +USE_PYQT5 = QT_LIB == PYQT5 +QtVersion = PySide.QtCore.__version__ if QT_LIB == PYSIDE else QtCore.QT_VERSION_STR m = re.match(r'(\d+)\.(\d+).*', QtVersion) if m is not None and list(map(int, m.groups())) < versionReq: print(list(map(int, m.groups()))) raise Exception('pyqtgraph requires Qt version >= %d.%d (your version is %s)' % (versionReq[0], versionReq[1], QtVersion)) - diff --git a/pyqtgraph/exporters/SVGExporter.py b/pyqtgraph/exporters/SVGExporter.py index 4a02965b..71b5bf5a 100644 --- a/pyqtgraph/exporters/SVGExporter.py +++ b/pyqtgraph/exporters/SVGExporter.py @@ -45,41 +45,6 @@ class SVGExporter(Exporter): if toBytes is False and copy is False and fileName is None: self.fileSaveDialog(filter="Scalable Vector Graphics (*.svg)") return - #self.svg = QtSvg.QSvgGenerator() - #self.svg.setFileName(fileName) - #dpi = QtGui.QDesktopWidget().physicalDpiX() - ### not really sure why this works, but it seems to be important: - #self.svg.setSize(QtCore.QSize(self.params['width']*dpi/90., self.params['height']*dpi/90.)) - #self.svg.setResolution(dpi) - ##self.svg.setViewBox() - #targetRect = QtCore.QRect(0, 0, self.params['width'], self.params['height']) - #sourceRect = self.getSourceRect() - - #painter = QtGui.QPainter(self.svg) - #try: - #self.setExportMode(True) - #self.render(painter, QtCore.QRectF(targetRect), sourceRect) - #finally: - #self.setExportMode(False) - #painter.end() - - ## Workaround to set pen widths correctly - #data = open(fileName).readlines() - #for i in range(len(data)): - #line = data[i] - #m = re.match(r'( Date: Sat, 28 Feb 2015 11:05:57 -0500 Subject: [PATCH 10/11] more examples working under pyqt5 --- examples/ScatterPlotSpeedTest.py | 4 +++- examples/VideoSpeedTest.py | 4 +++- examples/__main__.py | 12 ++++++++---- examples/parametertree.py | 2 +- pyqtgraph/Qt.py | 12 ++++++------ pyqtgraph/WidgetGroup.py | 28 +++++++--------------------- 6 files changed, 28 insertions(+), 34 deletions(-) diff --git a/examples/ScatterPlotSpeedTest.py b/examples/ScatterPlotSpeedTest.py index 4dbe57db..9cbf0c63 100644 --- a/examples/ScatterPlotSpeedTest.py +++ b/examples/ScatterPlotSpeedTest.py @@ -12,7 +12,7 @@ For testing rapid updates of ScatterPlotItem under various conditions. import initExample -from pyqtgraph.Qt import QtGui, QtCore, USE_PYSIDE +from pyqtgraph.Qt import QtGui, QtCore, USE_PYSIDE, USE_PYQT5 import numpy as np import pyqtgraph as pg from pyqtgraph.ptime import time @@ -22,6 +22,8 @@ app = QtGui.QApplication([]) #mw.resize(800,800) if USE_PYSIDE: from ScatterPlotSpeedTestTemplate_pyside import Ui_Form +elif USE_PYQT5: + from ScatterPlotSpeedTestTemplate_pyqt5 import Ui_Form else: from ScatterPlotSpeedTestTemplate_pyqt import Ui_Form diff --git a/examples/VideoSpeedTest.py b/examples/VideoSpeedTest.py index 6fce8a86..d26f507e 100644 --- a/examples/VideoSpeedTest.py +++ b/examples/VideoSpeedTest.py @@ -10,13 +10,15 @@ is used by the view widget import initExample ## Add path to library (just for examples; you do not need this) -from pyqtgraph.Qt import QtGui, QtCore, USE_PYSIDE +from pyqtgraph.Qt import QtGui, QtCore, USE_PYSIDE, USE_PYQT5 import numpy as np import pyqtgraph as pg import pyqtgraph.ptime as ptime if USE_PYSIDE: import VideoTemplate_pyside as VideoTemplate +elif USE_PYQT5: + import VideoTemplate_pyqt5 as VideoTemplate else: import VideoTemplate_pyqt as VideoTemplate diff --git a/examples/__main__.py b/examples/__main__.py index 52048593..a1ebb40a 100644 --- a/examples/__main__.py +++ b/examples/__main__.py @@ -268,15 +268,19 @@ except: if __name__ == '__main__': - if '--test' in sys.argv[1:]: + args = sys.argv[1:] + + if '--test' in args: # get rid of orphaned cache files first pg.renamePyc(path) - + files = buildFileList(examples) - if '--pyside' in sys.argv[1:]: + if '--pyside' in args: lib = 'PySide' - elif '--pyqt' in sys.argv[1:]: + elif '--pyqt' in args or '--pyqt4' in args: lib = 'PyQt4' + elif '--pyqt5' in args: + lib = 'PyQt5' else: lib = '' diff --git a/examples/parametertree.py b/examples/parametertree.py index b8638e02..8d8a7352 100644 --- a/examples/parametertree.py +++ b/examples/parametertree.py @@ -124,7 +124,7 @@ p.sigTreeStateChanged.connect(change) def valueChanging(param, value): - print "Value changing (not finalized):", param, value + print("Value changing (not finalized): %s %s" % (param, value)) # Too lazy for recursion: for child in p.children(): diff --git a/pyqtgraph/Qt.py b/pyqtgraph/Qt.py index 5fdce579..a25edead 100644 --- a/pyqtgraph/Qt.py +++ b/pyqtgraph/Qt.py @@ -139,13 +139,13 @@ elif QT_LIB == PYQT5: self.setTransform(tr) QtWidgets.QGraphicsItem.translate = translate - #def setMargin(self, i): - #self.setContentsMargins(i, i, i, i) - #QtWidgets.QGridLayout.setMargin = setMargin + def setMargin(self, i): + self.setContentsMargins(i, i, i, i) + QtWidgets.QGridLayout.setMargin = setMargin - #def setResizeMode(self, mode): - #self.setSectionResizeMode(mode) - #QtWidgets.QHeaderView.setResizeMode = setResizeMode + def setResizeMode(self, mode): + self.setSectionResizeMode(mode) + QtWidgets.QHeaderView.setResizeMode = setResizeMode QtGui.QApplication = QtWidgets.QApplication diff --git a/pyqtgraph/WidgetGroup.py b/pyqtgraph/WidgetGroup.py index 17e2b2bd..d7e265c5 100644 --- a/pyqtgraph/WidgetGroup.py +++ b/pyqtgraph/WidgetGroup.py @@ -60,9 +60,13 @@ def setComboState(w, v): class WidgetGroup(QtCore.QObject): - """This class takes a list of widgets and keeps an internal record of their state which is always up to date. Allows reading and writing from groups of widgets simultaneously.""" + """This class takes a list of widgets and keeps an internal record of their + state that is always up to date. - ## List of widget types which can be handled by WidgetGroup. + Allows reading and writing from groups of widgets simultaneously. + """ + + ## List of widget types that can be handled by WidgetGroup. ## The value for each type is a tuple (change signal function, get function, set function, [auto-add children]) ## The change signal function that takes an object and returns a signal that is emitted any time the state of the widget changes, not just ## when it is changed by user interaction. (for example, 'clicked' is not a valid signal here) @@ -200,53 +204,35 @@ class WidgetGroup(QtCore.QObject): if hasattr(obj, 'widgetGroupInterface'): return True return False - #return (type(obj) in WidgetGroup.classes) def setScale(self, widget, scale): val = self.readWidget(widget) self.scales[widget] = scale self.setWidget(widget, val) - #print "scaling %f to %f" % (val, self.readWidget(widget)) - def mkChangeCallback(self, w): return lambda *args: self.widgetChanged(w, *args) def widgetChanged(self, w, *args): - #print "widget changed" n = self.widgetList[w] v1 = self.cache[n] v2 = self.readWidget(w) if v1 != v2: - #print "widget", n, " = ", v2 if not USE_PYQT5: - #I don't think this line have any different from the next line + # Old signal kept for backward compatibility. self.emit(QtCore.SIGNAL('changed'), self.widgetList[w], v2) self.sigChanged.emit(self.widgetList[w], v2) def state(self): for w in self.uncachedWidgets: self.readWidget(w) - - #cc = self.cache.copy() - #if 'averageGroup' in cc: - #val = cc['averageGroup'] - #w = self.findWidget('averageGroup') - #self.readWidget(w) - #if val != self.cache['averageGroup']: - #print " AverageGroup did not match cached value!" - #else: - #print " AverageGroup OK" return self.cache.copy() def setState(self, s): - #print "SET STATE", self, s for w in self.widgetList: n = self.widgetList[w] - #print " restore %s?" % n if n not in s: continue - #print " restore state", w, n, s[n] self.setWidget(w, s[n]) def readWidget(self, w): From 52d7f2142c4fb7c152a778cfe262e26b27d26627 Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Sat, 28 Feb 2015 11:26:45 -0500 Subject: [PATCH 11/11] Fix line width in a few examples --- examples/ViewBox.py | 4 +- pyqtgraph/graphicsItems/FillBetweenItem.py | 11 ++++- pyqtgraph/graphicsItems/InfiniteLine.py | 52 ---------------------- pyqtgraph/imageview/ImageView.py | 12 +---- 4 files changed, 13 insertions(+), 66 deletions(-) diff --git a/examples/ViewBox.py b/examples/ViewBox.py index 3a66afe3..2ba2094c 100644 --- a/examples/ViewBox.py +++ b/examples/ViewBox.py @@ -42,7 +42,7 @@ class movableRect(QtGui.QGraphicsRectItem): self.setAcceptHoverEvents(True) def hoverEnterEvent(self, ev): self.savedPen = self.pen() - self.setPen(QtGui.QPen(QtGui.QColor(255, 255, 255))) + self.setPen(pg.mkPen(255, 255, 255)) ev.ignore() def hoverLeaveEvent(self, ev): self.setPen(self.savedPen) @@ -57,7 +57,7 @@ class movableRect(QtGui.QGraphicsRectItem): self.setPos(self.mapToParent(ev.pos()) - self.pressDelta) rect = movableRect(QtCore.QRectF(0, 0, 1, 1)) -rect.setPen(QtGui.QPen(QtGui.QColor(100, 200, 100))) +rect.setPen(pg.mkPen(100, 200, 100)) vb.addItem(rect) l.addItem(vb, 0, 1) diff --git a/pyqtgraph/graphicsItems/FillBetweenItem.py b/pyqtgraph/graphicsItems/FillBetweenItem.py index 6f21df56..a82af2da 100644 --- a/pyqtgraph/graphicsItems/FillBetweenItem.py +++ b/pyqtgraph/graphicsItems/FillBetweenItem.py @@ -7,7 +7,7 @@ class FillBetweenItem(QtGui.QGraphicsPathItem): """ GraphicsItem filling the space between two PlotDataItems. """ - def __init__(self, curve1=None, curve2=None, brush=None): + def __init__(self, curve1=None, curve2=None, brush=None, pen=None): QtGui.QGraphicsPathItem.__init__(self) self.curves = None if curve1 is not None and curve2 is not None: @@ -16,8 +16,15 @@ class FillBetweenItem(QtGui.QGraphicsPathItem): raise Exception("Must specify two curves to fill between.") if brush is not None: - self.setBrush(fn.mkBrush(brush)) + self.setBrush(brush) + self.setPen(pen) self.updatePath() + + def setBrush(self, *args, **kwds): + QtGui.QGraphicsPathItem.setBrush(self, fn.mkBrush(*args, **kwds)) + + def setPen(self, *args, **kwds): + QtGui.QGraphicsPathItem.setPen(self, fn.mkPen(*args, **kwds)) def setCurves(self, curve1, curve2): """Set the curves to fill between. diff --git a/pyqtgraph/graphicsItems/InfiniteLine.py b/pyqtgraph/graphicsItems/InfiniteLine.py index dfe2a4c1..2aff75f8 100644 --- a/pyqtgraph/graphicsItems/InfiniteLine.py +++ b/pyqtgraph/graphicsItems/InfiniteLine.py @@ -61,7 +61,6 @@ class InfiniteLine(GraphicsObject): pen = (200, 200, 100) self.setPen(pen) self.currentPen = self.pen - #self.setFlag(self.ItemSendsScenePositionChanges) def setMovable(self, m): """Set whether the line is movable by the user.""" @@ -176,7 +175,6 @@ class InfiniteLine(GraphicsObject): br = self.boundingRect() p.setPen(self.currentPen) p.drawLine(Point(br.right(), 0), Point(br.left(), 0)) - #p.drawRect(self.boundingRect()) def dataBounds(self, axis, frac=1.0, orthoRange=None): if axis == 0: @@ -184,25 +182,6 @@ class InfiniteLine(GraphicsObject): else: return (0,0) - #def mousePressEvent(self, ev): - #if self.movable and ev.button() == QtCore.Qt.LeftButton: - #ev.accept() - #self.pressDelta = self.mapToParent(ev.pos()) - QtCore.QPointF(*self.p) - #else: - #ev.ignore() - - #def mouseMoveEvent(self, ev): - #self.setPos(self.mapToParent(ev.pos()) - self.pressDelta) - ##self.emit(QtCore.SIGNAL('dragged'), self) - #self.sigDragged.emit(self) - #self.hasMoved = True - - #def mouseReleaseEvent(self, ev): - #if self.hasMoved and ev.button() == QtCore.Qt.LeftButton: - #self.hasMoved = False - ##self.emit(QtCore.SIGNAL('positionChangeFinished'), self) - #self.sigPositionChangeFinished.emit(self) - def mouseDragEvent(self, ev): if self.movable and ev.button() == QtCore.Qt.LeftButton: if ev.isStart(): @@ -214,15 +193,11 @@ class InfiniteLine(GraphicsObject): if not self.moving: return - #pressDelta = self.mapToParent(ev.buttonDownPos()) - Point(self.p) self.setPos(self.cursorOffset + self.mapToParent(ev.pos())) self.sigDragged.emit(self) if ev.isFinish(): self.moving = False self.sigPositionChangeFinished.emit(self) - #else: - #print ev - def mouseClickEvent(self, ev): if self.moving and ev.button() == QtCore.Qt.RightButton: @@ -248,30 +223,3 @@ class InfiniteLine(GraphicsObject): else: self.currentPen = self.pen self.update() - - #def hoverEnterEvent(self, ev): - #print "line hover enter" - #ev.ignore() - #self.updateHoverPen() - - #def hoverMoveEvent(self, ev): - #print "line hover move" - #ev.ignore() - #self.updateHoverPen() - - #def hoverLeaveEvent(self, ev): - #print "line hover leave" - #ev.ignore() - #self.updateHoverPen(False) - - #def updateHoverPen(self, hover=None): - #if hover is None: - #scene = self.scene() - #hover = scene.claimEvent(self, QtCore.Qt.LeftButton, scene.Drag) - - #if hover: - #self.currentPen = fn.mkPen(255, 0,0) - #else: - #self.currentPen = self.pen - #self.update() - diff --git a/pyqtgraph/imageview/ImageView.py b/pyqtgraph/imageview/ImageView.py index c7c3206e..5836a39f 100644 --- a/pyqtgraph/imageview/ImageView.py +++ b/pyqtgraph/imageview/ImageView.py @@ -24,9 +24,7 @@ from ..graphicsItems.ROI import * from ..graphicsItems.LinearRegionItem import * from ..graphicsItems.InfiniteLine import * from ..graphicsItems.ViewBox import * -#from widgets import ROI import sys -#from numpy import ndarray from .. import ptime as ptime import numpy as np from .. import debug as debug @@ -38,12 +36,6 @@ try: except ImportError: from numpy import nanmin, nanmax -#try: - #from .. import metaarray as metaarray - #HAVE_METAARRAY = True -#except: - #HAVE_METAARRAY = False - class PlotROI(ROI): def __init__(self, size): @@ -119,13 +111,13 @@ class ImageView(QtGui.QWidget): self.view.addItem(self.roi) self.roi.hide() self.normRoi = PlotROI(10) - self.normRoi.setPen(QtGui.QPen(QtGui.QColor(255,255,0))) + self.normRoi.setPen('y') self.normRoi.setZValue(20) self.view.addItem(self.normRoi) self.normRoi.hide() self.roiCurve = self.ui.roiPlot.plot() self.timeLine = InfiniteLine(0, movable=True) - self.timeLine.setPen(QtGui.QPen(QtGui.QColor(255, 255, 0, 200))) + self.timeLine.setPen((255, 255, 0, 200)) self.timeLine.setZValue(1) self.ui.roiPlot.addItem(self.timeLine) self.ui.splitter.setSizes([self.height()-35, 35])