forked from calanoue/pyqtgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- from bazaar.launchpad.net/~luke-campagnola/pyqtgraph/dev/
- Loading branch information
Showing
317 changed files
with
18,613 additions
and
20,901 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from GraphicsScene import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import exportDialogTemplate | ||
from pyqtgraph.Qt import QtCore, QtGui | ||
import pyqtgraph as pg | ||
import pyqtgraph.exporters as exporters | ||
|
||
|
||
class ExportDialog(QtGui.QWidget): | ||
def __init__(self, scene): | ||
QtGui.QWidget.__init__(self) | ||
self.setVisible(False) | ||
self.setWindowTitle("Export") | ||
self.shown = False | ||
self.currentExporter = None | ||
self.scene = scene | ||
|
||
self.selectBox = QtGui.QGraphicsRectItem() | ||
self.selectBox.setPen(pg.mkPen('y', width=3, style=QtCore.Qt.DashLine)) | ||
self.selectBox.hide() | ||
self.scene.addItem(self.selectBox) | ||
|
||
self.ui = exportDialogTemplate.Ui_Form() | ||
self.ui.setupUi(self) | ||
|
||
self.ui.closeBtn.clicked.connect(self.close) | ||
self.ui.exportBtn.clicked.connect(self.exportClicked) | ||
self.ui.itemTree.currentItemChanged.connect(self.exportItemChanged) | ||
self.ui.formatList.currentItemChanged.connect(self.exportFormatChanged) | ||
|
||
|
||
def show(self, item=None): | ||
if item is not None: | ||
while not isinstance(item, pg.ViewBox) and not isinstance(item, pg.PlotItem) and item is not None: | ||
item = item.parentItem() | ||
self.updateItemList(select=item) | ||
self.setVisible(True) | ||
self.activateWindow() | ||
self.raise_() | ||
self.selectBox.setVisible(True) | ||
|
||
if not self.shown: | ||
self.shown = True | ||
vcenter = self.scene.getViewWidget().geometry().center() | ||
self.setGeometry(vcenter.x()-self.width()/2, vcenter.y()-self.height()/2, self.width(), self.height()) | ||
|
||
def updateItemList(self, select=None): | ||
self.ui.itemTree.clear() | ||
si = QtGui.QTreeWidgetItem(["Entire Scene"]) | ||
si.gitem = self.scene | ||
self.ui.itemTree.addTopLevelItem(si) | ||
self.ui.itemTree.setCurrentItem(si) | ||
si.setExpanded(True) | ||
for child in self.scene.items(): | ||
if child.parentItem() is None: | ||
self.updateItemTree(child, si, select=select) | ||
|
||
def updateItemTree(self, item, treeItem, select=None): | ||
si = None | ||
if isinstance(item, pg.ViewBox): | ||
si = QtGui.QTreeWidgetItem(['ViewBox']) | ||
elif isinstance(item, pg.PlotItem): | ||
si = QtGui.QTreeWidgetItem(['Plot']) | ||
|
||
if si is not None: | ||
si.gitem = item | ||
treeItem.addChild(si) | ||
treeItem = si | ||
if si.gitem is select: | ||
self.ui.itemTree.setCurrentItem(si) | ||
|
||
for ch in item.childItems(): | ||
self.updateItemTree(ch, treeItem, select=select) | ||
|
||
|
||
def exportItemChanged(self, item, prev): | ||
if item is None: | ||
return | ||
if item.gitem is self.scene: | ||
newBounds = self.scene.views()[0].viewRect() | ||
else: | ||
newBounds = item.gitem.sceneBoundingRect() | ||
self.selectBox.setRect(newBounds) | ||
self.selectBox.show() | ||
self.updateFormatList() | ||
|
||
def updateFormatList(self): | ||
current = self.ui.formatList.currentItem() | ||
if current is not None: | ||
current = str(current.text()) | ||
self.ui.formatList.clear() | ||
self.exporterClasses = {} | ||
gotCurrent = False | ||
for exp in exporters.listExporters(): | ||
self.ui.formatList.addItem(exp.Name) | ||
self.exporterClasses[exp.Name] = exp | ||
if exp.Name == current: | ||
self.ui.formatList.setCurrentRow(self.ui.formatList.count()-1) | ||
gotCurrent = True | ||
|
||
if not gotCurrent: | ||
self.ui.formatList.setCurrentRow(0) | ||
|
||
def exportFormatChanged(self, item, prev): | ||
if item is None: | ||
self.currentExporter = None | ||
self.ui.paramTree.clear() | ||
return | ||
expClass = self.exporterClasses[str(item.text())] | ||
exp = expClass(item=self.ui.itemTree.currentItem().gitem) | ||
params = exp.parameters() | ||
if params is None: | ||
self.ui.paramTree.clear() | ||
else: | ||
self.ui.paramTree.setParameters(params) | ||
self.currentExporter = exp | ||
|
||
def exportClicked(self): | ||
self.selectBox.hide() | ||
self.currentExporter.export() | ||
|
||
def close(self): | ||
self.selectBox.setVisible(False) | ||
self.setVisible(False) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# Form implementation generated from reading ui file 'exportDialogTemplate.ui' | ||
# | ||
# Created: Thu Mar 22 13:13:06 2012 | ||
# by: PyQt4 UI code generator 4.8.5 | ||
# | ||
# WARNING! All changes made in this file will be lost! | ||
|
||
from PyQt4 import QtCore, QtGui | ||
|
||
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(241, 367) | ||
Form.setWindowTitle(QtGui.QApplication.translate("Form", "Export", None, QtGui.QApplication.UnicodeUTF8)) | ||
self.gridLayout = QtGui.QGridLayout(Form) | ||
self.gridLayout.setSpacing(0) | ||
self.gridLayout.setObjectName(_fromUtf8("gridLayout")) | ||
self.label = QtGui.QLabel(Form) | ||
self.label.setText(QtGui.QApplication.translate("Form", "Item to export:", None, QtGui.QApplication.UnicodeUTF8)) | ||
self.label.setObjectName(_fromUtf8("label")) | ||
self.gridLayout.addWidget(self.label, 0, 0, 1, 3) | ||
self.itemTree = QtGui.QTreeWidget(Form) | ||
self.itemTree.setObjectName(_fromUtf8("itemTree")) | ||
self.itemTree.headerItem().setText(0, _fromUtf8("1")) | ||
self.itemTree.header().setVisible(False) | ||
self.gridLayout.addWidget(self.itemTree, 1, 0, 1, 3) | ||
self.label_2 = QtGui.QLabel(Form) | ||
self.label_2.setText(QtGui.QApplication.translate("Form", "Export format", None, QtGui.QApplication.UnicodeUTF8)) | ||
self.label_2.setObjectName(_fromUtf8("label_2")) | ||
self.gridLayout.addWidget(self.label_2, 2, 0, 1, 3) | ||
self.formatList = QtGui.QListWidget(Form) | ||
self.formatList.setObjectName(_fromUtf8("formatList")) | ||
self.gridLayout.addWidget(self.formatList, 3, 0, 1, 3) | ||
self.exportBtn = QtGui.QPushButton(Form) | ||
self.exportBtn.setText(QtGui.QApplication.translate("Form", "Export", None, QtGui.QApplication.UnicodeUTF8)) | ||
self.exportBtn.setObjectName(_fromUtf8("exportBtn")) | ||
self.gridLayout.addWidget(self.exportBtn, 6, 1, 1, 1) | ||
self.closeBtn = QtGui.QPushButton(Form) | ||
self.closeBtn.setText(QtGui.QApplication.translate("Form", "Close", None, QtGui.QApplication.UnicodeUTF8)) | ||
self.closeBtn.setObjectName(_fromUtf8("closeBtn")) | ||
self.gridLayout.addWidget(self.closeBtn, 6, 2, 1, 1) | ||
self.paramTree = ParameterTree(Form) | ||
self.paramTree.setObjectName(_fromUtf8("paramTree")) | ||
self.paramTree.headerItem().setText(0, _fromUtf8("1")) | ||
self.paramTree.header().setVisible(False) | ||
self.gridLayout.addWidget(self.paramTree, 5, 0, 1, 3) | ||
self.label_3 = QtGui.QLabel(Form) | ||
self.label_3.setText(QtGui.QApplication.translate("Form", "Export options", None, QtGui.QApplication.UnicodeUTF8)) | ||
self.label_3.setObjectName(_fromUtf8("label_3")) | ||
self.gridLayout.addWidget(self.label_3, 4, 0, 1, 3) | ||
|
||
self.retranslateUi(Form) | ||
QtCore.QMetaObject.connectSlotsByName(Form) | ||
|
||
def retranslateUi(self, Form): | ||
pass | ||
|
||
from pyqtgraph.parametertree import ParameterTree |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>Form</class> | ||
<widget class="QWidget" name="Form"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>241</width> | ||
<height>367</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Export</string> | ||
</property> | ||
<layout class="QGridLayout" name="gridLayout"> | ||
<property name="spacing"> | ||
<number>0</number> | ||
</property> | ||
<item row="0" column="0" colspan="3"> | ||
<widget class="QLabel" name="label"> | ||
<property name="text"> | ||
<string>Item to export:</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="1" column="0" colspan="3"> | ||
<widget class="QTreeWidget" name="itemTree"> | ||
<attribute name="headerVisible"> | ||
<bool>false</bool> | ||
</attribute> | ||
<column> | ||
<property name="text"> | ||
<string notr="true">1</string> | ||
</property> | ||
</column> | ||
</widget> | ||
</item> | ||
<item row="2" column="0" colspan="3"> | ||
<widget class="QLabel" name="label_2"> | ||
<property name="text"> | ||
<string>Export format</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="3" column="0" colspan="3"> | ||
<widget class="QListWidget" name="formatList"/> | ||
</item> | ||
<item row="6" column="1"> | ||
<widget class="QPushButton" name="exportBtn"> | ||
<property name="text"> | ||
<string>Export</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="6" column="2"> | ||
<widget class="QPushButton" name="closeBtn"> | ||
<property name="text"> | ||
<string>Close</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="5" column="0" colspan="3"> | ||
<widget class="ParameterTree" name="paramTree"> | ||
<attribute name="headerVisible"> | ||
<bool>false</bool> | ||
</attribute> | ||
<column> | ||
<property name="text"> | ||
<string notr="true">1</string> | ||
</property> | ||
</column> | ||
</widget> | ||
</item> | ||
<item row="4" column="0" colspan="3"> | ||
<widget class="QLabel" name="label_3"> | ||
<property name="text"> | ||
<string>Export options</string> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
<customwidgets> | ||
<customwidget> | ||
<class>ParameterTree</class> | ||
<extends>QTreeWidget</extends> | ||
<header>pyqtgraph.parametertree</header> | ||
</customwidget> | ||
</customwidgets> | ||
<resources/> | ||
<connections/> | ||
</ui> |
Oops, something went wrong.