From 60836462d28c3bdeb46604510d2ad739647f9e25 Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Mon, 7 Jan 2013 10:45:03 -0500 Subject: [PATCH] Updated flowchart documentation --- doc/source/index.rst | 1 + doc/source/prototyping.rst | 8 +------- pyqtgraph/flowchart/Flowchart.py | 11 ++++++++--- pyqtgraph/flowchart/Node.py | 6 +++++- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/doc/source/index.rst b/doc/source/index.rst index 7a1a77e9..9727aaab 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -23,6 +23,7 @@ Contents: exporting prototyping parametertree/index + flowchart/index internals apireference diff --git a/doc/source/prototyping.rst b/doc/source/prototyping.rst index 63815a08..e8dffb66 100644 --- a/doc/source/prototyping.rst +++ b/doc/source/prototyping.rst @@ -18,14 +18,8 @@ Visual Programming Flowcharts Pyqtgraph's flowcharts provide a visual programming environment similar in concept to LabView--functional modules are added to a flowchart and connected by wires to define a more complex and arbitrarily configurable algorithm. A small number of predefined modules (called Nodes) are included with pyqtgraph, but most flowchart developers will want to define their own library of Nodes. At their core, the Nodes are little more than 1) a Python function 2) a list of input/output terminals, and 3) an optional widget providing a control panel for the Node. Nodes may transmit/receive any type of Python object via their terminals. -One major limitation of flowcharts is that there is no mechanism for looping within a flowchart. (however individual Nodes may contain loops (they may contain any Python code at all), and an entire flowchart may be executed from within a loop). +See the `flowchart documentation `_ and the flowchart examples for more information. -There are two distinct modes of executing the code in a flowchart: - -1. Provide data to the input terminals of the flowchart. This method is slower and will provide a graphical representation of the data as it passes through the flowchart. This is useful for debugging as it allows the user to inspect the data at each terminal and see where exceptions occurred within the flowchart. -2. Call Flowchart.process. This method does not update the displayed state of the flowchart and only retains the state of each terminal as long as it is needed. Additionally, Nodes which do not contribute to the output values of the flowchart (such as plotting nodes) are ignored. This mode allows for faster processing of large data sets and avoids memory issues which can occur if doo much data is present in the flowchart at once (e.g., when processing image data through several stages). - -See the flowchart example for more information. Graphical Canvas ---------------- diff --git a/pyqtgraph/flowchart/Flowchart.py b/pyqtgraph/flowchart/Flowchart.py index 6b1352d5..5d7dc093 100644 --- a/pyqtgraph/flowchart/Flowchart.py +++ b/pyqtgraph/flowchart/Flowchart.py @@ -113,8 +113,11 @@ class Flowchart(Node): self.inputNode.setOutput(**args) def outputChanged(self): - self.widget().outputChanged(self.outputNode.inputValues()) - self.sigOutputChanged.emit(self) + ## called when output of internal node has changed + vals = self.outputNode.inputValues() + self.widget().outputChanged(vals) + self.setOutput(**vals) + #self.sigOutputChanged.emit(self) def output(self): return self.outputNode.inputValues() @@ -261,7 +264,9 @@ class Flowchart(Node): def process(self, **args): """ Process data through the flowchart, returning the output. - Keyword arguments must be the names of input terminals + + Keyword arguments must be the names of input terminals. + The return value is a dict with one key per output terminal. """ data = {} ## Stores terminal:value pairs diff --git a/pyqtgraph/flowchart/Node.py b/pyqtgraph/flowchart/Node.py index e6e98d1a..cd73b42b 100644 --- a/pyqtgraph/flowchart/Node.py +++ b/pyqtgraph/flowchart/Node.py @@ -229,7 +229,11 @@ class Node(QtCore.QObject): return "" % (self.name(), id(self)) def ctrlWidget(self): - """Return this Node's control widget.""" + """Return this Node's control widget. + + By default, Nodes have no control widget. Subclasses may reimplement this + method to provide a custom widget. This method is called by Flowcharts + when they are constructing their Node list.""" return None def bypass(self, byp):