Cleaned up example loader
This commit is contained in:
parent
caa15d2005
commit
058dd183d3
@ -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__))
|
||||
|
@ -6,28 +6,22 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>623</width>
|
||||
<height>380</height>
|
||||
<width>846</width>
|
||||
<height>552</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QWidget" name="">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QTreeWidget" name="exampleTree">
|
||||
<attribute name="headerVisible">
|
||||
<bool>false</bool>
|
||||
@ -39,55 +33,69 @@
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="graphicsSystemCombo">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="pyqtCheck">
|
||||
<property name="text">
|
||||
<string>Force PyQt</string>
|
||||
</property>
|
||||
</widget>
|
||||
<property name="text">
|
||||
<string>default</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="pysideCheck">
|
||||
<property name="text">
|
||||
<string>Force PySide</string>
|
||||
</property>
|
||||
</widget>
|
||||
<property name="text">
|
||||
<string>native</string>
|
||||
</property>
|
||||
</item>
|
||||
</layout>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>raster</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>opengl</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="qtLibCombo">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="forceGraphicsCheck">
|
||||
<property name="text">
|
||||
<string>Force Graphics System:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<property name="text">
|
||||
<string>default</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="forceGraphicsCombo">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>native</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>raster</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>opengl</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<property name="text">
|
||||
<string>PyQt4</string>
|
||||
</property>
|
||||
</item>
|
||||
</layout>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>PySide</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>PyQt5</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Graphics System:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Qt Library:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QPushButton" name="loadBtn">
|
||||
<property name="text">
|
||||
<string>Run Example</string>
|
||||
@ -97,7 +105,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="loadedFileLabel">
|
||||
<property name="font">
|
||||
|
@ -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))
|
||||
|
||||
|
@ -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"))
|
||||
|
||||
|
@ -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))
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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))
|
||||
|
||||
|
@ -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'(<g .*)stroke-width="1"(.*transform="matrix\(([^\)]+)\)".*)', line)
|
||||
#if m is not None:
|
||||
##print "Matched group:", line
|
||||
#g = m.groups()
|
||||
#matrix = list(map(float, g[2].split(',')))
|
||||
##print "matrix:", matrix
|
||||
#scale = max(abs(matrix[0]), abs(matrix[3]))
|
||||
#if scale == 0 or scale == 1.0:
|
||||
#continue
|
||||
#data[i] = g[0] + ' stroke-width="%0.2g" ' % (1.0/scale) + g[1] + '\n'
|
||||
##print "old line:", line
|
||||
##print "new line:", data[i]
|
||||
#open(fileName, 'w').write(''.join(data))
|
||||
|
||||
## Qt's SVG generator is not complete. (notably, it lacks clipping)
|
||||
## Instead, we will use Qt to generate SVG for each item independently,
|
||||
|
@ -16,7 +16,7 @@ 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, QT_LIB
|
||||
from ...Qt import QtGui, QtCore, QT_LIB
|
||||
from ... import pixmaps
|
||||
import sys
|
||||
|
||||
@ -785,42 +785,9 @@ class PlotItem(GraphicsWidget):
|
||||
fileName = str(fileName)
|
||||
PlotItem.lastFileDir = os.path.dirname(fileName)
|
||||
|
||||
self.svg = QtSvg.QSvgGenerator()
|
||||
self.svg.setFileName(fileName)
|
||||
res = 120.
|
||||
view = self.scene().views()[0]
|
||||
bounds = view.viewport().rect()
|
||||
bounds = QtCore.QRectF(0, 0, bounds.width(), bounds.height())
|
||||
|
||||
self.svg.setResolution(res)
|
||||
self.svg.setViewBox(bounds)
|
||||
|
||||
self.svg.setSize(QtCore.QSize(bounds.width(), bounds.height()))
|
||||
|
||||
painter = QtGui.QPainter(self.svg)
|
||||
view.render(painter, bounds)
|
||||
|
||||
painter.end()
|
||||
|
||||
## Workaround to set pen widths correctly
|
||||
import re
|
||||
data = open(fileName).readlines()
|
||||
for i in range(len(data)):
|
||||
line = data[i]
|
||||
m = re.match(r'(<g .*)stroke-width="1"(.*transform="matrix\(([^\)]+)\)".*)', line)
|
||||
if m is not None:
|
||||
#print "Matched group:", line
|
||||
g = m.groups()
|
||||
matrix = list(map(float, g[2].split(',')))
|
||||
#print "matrix:", matrix
|
||||
scale = max(abs(matrix[0]), abs(matrix[3]))
|
||||
if scale == 0 or scale == 1.0:
|
||||
continue
|
||||
data[i] = g[0] + ' stroke-width="%0.2g" ' % (1.0/scale) + g[1] + '\n'
|
||||
#print "old line:", line
|
||||
#print "new line:", data[i]
|
||||
open(fileName, 'w').write(''.join(data))
|
||||
|
||||
from ...exporters import SVGExporter
|
||||
ex = SVGExporter(self)
|
||||
ex.export(fileName)
|
||||
|
||||
def writeImage(self, fileName=None):
|
||||
if fileName is None:
|
||||
|
Loading…
Reference in New Issue
Block a user