diff --git a/CHANGELOG b/CHANGELOG index e574e479..490f85e6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -33,7 +33,9 @@ pyqtgraph-0.9.9 [unreleased] - Essentially a graphical interface to dict; all items have text and value - Assigns previously-selected text after list is cleared and repopulated - Get, set current value - - Added Flowchart.sigChartChanged + - Flowchart updates + - Added Flowchart.sigChartChanged + - Custom nodes may now be registered in sub-menu trees - ImageItem.getHistogram is more clever about constructing histograms - Added FillBetweenItem.setCurves() - MultiPlotWidget now has setMinimumPlotHeight method and displays scroll bar diff --git a/README.md b/README.md index f9e214d5..83327089 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ Contributors * Stefan Holzmann * Nicholas TJ * John David Reaver + * David Kaplan Requirements ------------ diff --git a/examples/FlowchartCustomNode.py b/examples/FlowchartCustomNode.py index 54c56622..1cf1ba10 100644 --- a/examples/FlowchartCustomNode.py +++ b/examples/FlowchartCustomNode.py @@ -127,7 +127,10 @@ class UnsharpMaskNode(CtrlNode): ## NodeLibrary: library = fclib.LIBRARY.copy() # start with the default node set library.addNodeType(ImageViewNode, [('Display',)]) -library.addNodeType(UnsharpMaskNode, [('Image',)]) +# Add the unsharp mask node to two locations in the menu to demonstrate +# that we can create arbitrary menu structures +library.addNodeType(UnsharpMaskNode, [('Image',), + ('Submenu_test','submenu2','submenu3')]) fc.setLibrary(library) diff --git a/pyqtgraph/flowchart/Flowchart.py b/pyqtgraph/flowchart/Flowchart.py index 878f86ae..ab5f4a82 100644 --- a/pyqtgraph/flowchart/Flowchart.py +++ b/pyqtgraph/flowchart/Flowchart.py @@ -823,16 +823,20 @@ class FlowchartWidget(dockarea.DockArea): self.buildMenu() def buildMenu(self, pos=None): + def buildSubMenu(node, rootMenu, subMenus, pos=None): + for section, node in node.items(): + menu = QtGui.QMenu(section) + rootMenu.addMenu(menu) + if isinstance(node, OrderedDict): + buildSubMenu(node, menu, subMenus, pos=pos) + subMenus.append(menu) + else: + act = rootMenu.addAction(section) + act.nodeType = section + act.pos = pos self.nodeMenu = QtGui.QMenu() - self.subMenus = [] - for section, nodes in self.chart.library.getNodeTree().items(): - menu = QtGui.QMenu(section) - self.nodeMenu.addMenu(menu) - for name in nodes: - act = menu.addAction(name) - act.nodeType = name - act.pos = pos - self.subMenus.append(menu) + self.subMenus = [] + buildSubMenu(self.chart.library.getNodeTree(), self.nodeMenu, self.subMenus, pos=pos) self.nodeMenu.triggered.connect(self.nodeMenuTriggered) return self.nodeMenu