To access the node's contents there is a small 'API' that you can use in the class.
Getting data from a data input:
Setting value of data output:
Executing an exec output:
Adding a new input:
self.create_new_input(type_: str, label: str, widget_name=None, widget_pos='under', pos=-1)
- type_ refers to the input's type (exec or data)
- label is the displayed name of the port
- pos=-1 means the input will be appended at the end, everything else specifies the index at which the input will be inserted. All widget related arguments are only important for data inputs:
- widget_name holds the name of the input widget you want to use. If you don't want to use a widget, use None. Else, the widget name must be a string referring either to one of the std input widgets (see in NodeManager which are currently supported) or to a custom input widget you programmed.
- widget_pos determines whether the input widget will be placed besides or under the the port
Adding a new output:
self.create_new_output(type_: str, label: str, pos=-1)
Deleting an input:
Deleting an output:
Access Ryven's stylesheet
One of the best ways to make your nodes dynamic is to enable script variable dependencies. You can register methods that get called when the variable with the given name changes or gets created. To register such a method (or slot) in your node class, use
To unregister a method, use
Don't forget to unregister the old variable name when the referred name (given by the user through some widget probably) changes. Old connections don't get broken up when registering new ones, you can register as many connections as you want.
Accessing a script variable's value
Setting a script variable's value
This operation causes all registered methods (by any node) referring to the variable's name to be executed, in the order the connections were registered.
You can log mesasges to the script's logs via
self.log_message(message: str, target='global')
target can be global or error which addresses the global messages log or the error log.
A node can also request new logs using
One node can hold mutliple personal logs.
To disable a log, use
All logs required by a node (via self.new_log()) get disabled automatically when this node is removed.
If you are troubleshooting your nodes, you can turn debugging on. This will print a lot of information in the output window including the following error message
EXCEPTION IN <NodeInstance Name> NI: <exception>
whenever the execution of a node returned an error. That's a very useful feature. You can also quickly debug nodes by editing their source code directly in Ryven.
If you want to access files you've put into your package folder (like pictures, but also python files etc.), you can access the path of the package of your node using
in node files, and
in widget files. Note, that this way you can create custom class hierarchies! As an example, take a look at the widgets of the matrix nodes in the linalg package, where I let them simply derive from one base class I've put in the package folder.