custom nodes in flowchart

495 views
Skip to first unread message

Hachi Manzur

unread,
Jan 3, 2013, 3:55:49 PM1/3/13
to pyqt...@googlegroups.com
Hi all, I need to use pyqtgraph flowchart capabilities, and I need to define my own nodes. The documentation in this regard is scarce. Can you provide a simple example on how to do it ?

Thanks

Luke Campagnola

unread,
Jan 4, 2013, 10:35:31 AM1/4/13
to pyqt...@googlegroups.com
On Thu, Jan 3, 2013 at 3:55 PM, Hachi Manzur <hema...@gmail.com> wrote:
Hi all, I need to use pyqtgraph flowchart capabilities, and I need to define my own nodes. The documentation in this regard is scarce. Can you provide a simple example on how to do it ?

Certainly! I've attached an example that defines two custom nodes and registers them with the flowchart library. I'll include this file in the next release.
I'd also recommend just browsing through the code in flowcharts.library -- there are many nodes defined there, some of which are quite simple.

A node class implements at least:
  1) A list of input / ouptut terminals and their properties
  2) a process() function which takes the names of input terminals as keyword arguments and returns a dict with the names of output terminals as keys.

Optionally, a node class can implement the ctrlWidget() method, which must return a QWidget (usually containing other widgets) that will be displayed in the flowchart control panel. Some nodes implement fairly complex control widgets, but most nodes follow a simple form-like pattern: a list of parameter names and a single value (represented as spin box, check box, etc..) for each parameter. To make this easier, the CtrlNode subclass allows you to instead define a simple data structure that CtrlNode will use to automatically generate the control widget. This is used in the example I attached as well as in many of the default library nodes (especially the filters).

There are many other optional parameters for nodes and terminals -- whether the user is allowed to add/remove/rename terminals, whether one terminal may be connected to many others or just one, etc. I'd be happy to write up some more documentation on this.

Luke 

FlowchartCustomNode.py

Hachi Manzur

unread,
Jan 22, 2013, 10:23:17 PM1/22/13
to pyqt...@googlegroups.com
Hi Luke, thank you so much for your reply !
Sorry I didn't answer before.

I'll give it a try and I'll let you know

Hachi
Reply all
Reply to author
Forward
0 new messages