Creating New Nodes - Basics

This page provides you with the information you need to create nodes for Ryven.

ProTipp for programming the nodes: Use the example projects and Ryven's code preview feature (drag the handle at the bottom of a flow upwards) to get a better look at how the nodes and their GUI components are implemented. You can also edit the source code of methods of the placed nodes and play around. This is really useful.

The overall process looks like this:

  • The NodeManager lets you create new and edit existing nodes imported from a nodes package.
  • Programming the nodes and their GUI components can either be done inside the NodeManager or outside by editing the metacode files using your favourite code editor (Atom recommended).
  • You save the nodes in a package when you're done.
  • And then you can import the package in Ryven to use the nodes.

A node's basic attributes are:

  • title
  • description
  • class name
  • use of main widget
  • design style
  • color
  • inputs (initial)
  • outputs (initial)

NodeManager Overview

Saving nodes

Click save and select the nodes that you want to have included in the package. Then create and select a new folder for the package or an existing one if you want to override an existing package (the folder name will be the package's name!), and click export. You should keep temporary backups of packages when overriding them in case something goes wrong.

Name Conventions

Classname Conformity

If your node has a title that, except for spaces, is not class-or file-/foldername conform (like +, &, %), you need to give a custom Internal Name which then will be used internally instead of the node's title. You are getting warned if that happens.

Further Name Conventions

  • a package's name must be unique
  • multiple nodes in a package do can have the same name, but for intuitive use in the editor, you should make sure that the description differs

Updating Packages

A package is identified by its name. When overriding an existing package (which you should do after you sufficiently tested a copied version), none of your content will be deleted. Source code files get only created if they do not already exist (see next section) and all your custom files and folders you have put somwhere into the package's directory (like pictures that you may use) stay as they are.

Programming Nodes

And there we are. Basic concepts:

  • For every node (as well as all its widget classes, more on that later), the NodeManager creates metacode files from templates if they do not already exist. If you don't want to program the nodes inside the Nodemanager, you can just edit these metacode files directly.
  • The actual source code files will be created every time you import the package in Ryven. These get created in the same locations as the metacode files.
  • Do not edit the non-metacode files directly, as these changes will be lost!

By taking a look into the code, you will see some imports, some info and a class. That's your node's actual class. Now you just edit this class following the instructions below.

Update Event Method

You basically put your code into the update method. If your node has one or more execution inputs, you always need to check for input_called. That enables your node having mutliple execution inputs triggering different behaviour.

def update_event(self, input_called=-1):
    if input_called == 0:
        ... do something here
    elif input_called == 1:
        ... and something else here

If your node does not have any execution inputs (-> if its passive, pure data processing) do not check for input_called as the node is supposed to update every time anything changed. Note that input_called refers to the index.

A + node's update event could look like this:

def update_event(self, input_called=-1):
    sum_val = self.input(0) + self.input(1)
    self.set_output_val(0, sum_val)

And from this point, you can add further methods to the class, import libraries, create more classes, everything you can do in a Python file. And that's it. Everything beyond that is the use of special features. There are a few very useful ones but you don't have to use them.

Special Actions

A very handy feature. The special actions attribute is a dictionary and holds information about accessible right-click operations which then will automatically be created when right clicking on a node. A possible entry would be

self.special_actions['print something'] = {'method': M(self.action_print_something)}

In this case, a method action_print_something would need to exist which gets triggered when the user clicks on print something.

def action_print_something(self):
    print('Hello World!')

To remove an action, simply use

del self.special_actions['print something']

You can define as many actions for your node as you want and you can totally edit this dict at any time. Just make sure to instead of directly using the method's object, use M(your_method) (always do that when referencing methods). It ensures that this method can be live edited in Ryven and that the references get updated.