PyQt4 Node Editor

Node editors are useful for lots of different applications from flowcharting to visual programming and shader creation.  Qt doesn’t have any specific widgets or graphics items to assist with creation of a node network unfortunately and most of the available options are either ugly or not particular nice to use, so I’ve been working on my own solution for some time now.

Originally, I had intended to write a node based shader editor, but this has turned into something of a project on it’s own.  It’s not at release state yet, but I’m very happy with how it looks and works.


Sample node implementation –

from node.node import Node
from sockets import *

class VectorNode(Node):
   title = 'Vector'

   interface_widgets = [
       {'type': Text,  'name': 'Name', 'value': 'Node.002'},
       {'type': Float, 'name': 'x', 'value': 0.0},
       {'type': Float, 'name': 'y', 'value': 0.0},
       {'type': Float, 'name': 'z', 'value': 0.0},

   output_sockets = [
       {'type': VectorSocket, 'name': 'Vector'}

   def calc(self):
       self.outputs['Vector'] = [self.interface['x'], self.interface['y'], self.interface['z']]

Quick video of early functionality –

PyQt4 Node Editor

Leave a Reply