本文整理汇总了Python中pyqtgraph.flowchart.Node.saveState方法的典型用法代码示例。如果您正苦于以下问题:Python Node.saveState方法的具体用法?Python Node.saveState怎么用?Python Node.saveState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqtgraph.flowchart.Node
的用法示例。
在下文中一共展示了Node.saveState方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Flowchart
# 需要导入模块: from pyqtgraph.flowchart import Node [as 别名]
# 或者: from pyqtgraph.flowchart.Node import saveState [as 别名]
#.........这里部分代码省略.........
self.sigStateChanged.emit()
def chartGraphicsItem(self):
"""Return the graphicsItem which displays the internals of this flowchart.
(graphicsItem() still returns the external-view item)"""
#return self._chartGraphicsItem
return self.viewBox
def widget(self):
if self._widget is None:
self._widget = FlowchartCtrlWidget(self)
self.scene = self._widget.scene()
self.viewBox = self._widget.viewBox()
#self._scene = QtGui.QGraphicsScene()
#self._widget.setScene(self._scene)
#self.scene.addItem(self.chartGraphicsItem())
#ci = self.chartGraphicsItem()
#self.viewBox.addItem(ci)
#self.viewBox.autoRange()
return self._widget
def listConnections(self):
conn = set()
for n in self._nodes.values():
terms = n.outputs()
for n, t in terms.items():
for c in t.connections():
conn.add((t, c))
return conn
def saveState(self):
state = Node.saveState(self)
state['nodes'] = []
state['connects'] = []
#state['terminals'] = self.saveTerminals()
for name, node in self._nodes.items():
cls = type(node)
if hasattr(cls, 'nodeName'):
clsName = cls.nodeName
pos = node.graphicsItem().pos()
ns = {'class': clsName, 'name': name, 'pos': (pos.x(), pos.y()), 'state': node.saveState()}
state['nodes'].append(ns)
conn = self.listConnections()
for a, b in conn:
state['connects'].append((a.node().name(), a.name(), b.node().name(), b.name()))
state['inputNode'] = self.inputNode.saveState()
state['outputNode'] = self.outputNode.saveState()
return state
def restoreState(self, state, clear=False):
self.blockSignals(True)
try:
if clear:
self.clear()
Node.restoreState(self, state)
nodes = state['nodes']
nodes.sort(lambda a, b: cmp(a['pos'][0], b['pos'][0]))
for n in nodes:
if n['name'] in self._nodes: