class Channel: def __init__(self, channel_type, name=None, xml=None)
Channels are contained by Nodes and can be connected to Channels in other Nodes.
class Connection: def __init__(self)
Connections represent pairs of connected Channels.
class EventHook: def __init__(self, name=None)
EventHooks are used to manage a list of callbacks.Imported from nodenet.eventhook.
class Node: def __init__(self, name=None, xml=None)
Nodes can be connected to each other within a NodeNet.
class NodeNet: def __init__(self, xml=None)
NodeNet is a data structure for storing networks of nodes.
Channel(channel_type, name=None, xml=None)
Channels are contained by Nodes and can be connected to Channels in other Nodes.
Each Channel is classified as either an input channel or an output channel, as
represented by the channel type contants INPUT_CHANNEL
and
OUTPUT_CHANNEL
.
channel_type
-- INPUT_CHANNEL
or OUTPUT_CHANNEL
name
-- a name for the channel
xml
-- a string containing XML data which can be used to initialize the channel
on_connect(channel, remote_channel)
Called when the channel is being connected to a remote channel. Return true to abort the connection.
on_delete(channel)
Called when the channel is being removed from a node. Return true to abort the removal.
on_disconnect(channel, remote_channel)
Called when the channel is being disconnected from a remote channel. Return true to abort the disconnection.
on_get_xml(channel)
Called when a string XML representation of the channel is required. Any returned value will be used in place of the standard representation.
on_rename(channel, name)
Called when the channel is being renamed. Return true to abort the renaming.
on_set_xml(channel, xml)
Called when the channel is being initialized from a string containing XML data. Return true to abort the standard XML processing
add_peer(remote_channel)
Connect this channel to a remote channel.
get_channel_type()
Returns either INPUT_CHANNEL or OUTPUT_CHANNEL.
get_connections()
Returns all the Connection objects which are connected through this channel.
get_name()
Returns the name of this channel.
get_node()
Returns the node containing this channel.
get_peers()
Returns all the remote channels this channel is connected to.
get_xml()
Returns a string XML representation of this channel.
remove_connection(connection)
Remove a connection between this channel and a remote channel.
set_name(name)
Sets the name of this channel.
set_xml(xml_str)
Initialized this channel from a string containing XML data.
add_peer(remote_channel)
Connect this channel to a remote channel. The remove Channel
object is passed in.
The new Connection
object is returned.
get_channel_type()
Returns either INPUT_CHANNEL
or OUTPUT_CHANNEL
.
get_connections()
Returns all the Connection
objects which are connected through this channel.
get_name()
Returns the name of this channel.
get_node()
Returns the node containing this channel.
get_peers()
Returns all the remote channels this channel is connected to.
get_xml()
Returns a string XML representation of this channel.
remove_connection(connection)
Remove a connection between this channel and a remote channel. The Connection
object is passed in.
set_name(name)
Sets the name of this channel.
set_xml(xml_str)
Initialized this channel from a string containing XML data.
Connection()
Connections represent pairs of connected Channels. Each Connection has an output
channel where data flows from and an input channel where data flows to. Connection objects
shouldn't be created directly. Instead, use the add_peer
method of a
Channel
object.
get_destination()
Returns the destination channel.
get_position()
Returns the position of the connection, for use in a graphical user interface.
get_source()
Returns the source channel.
get_xml()
Returns a string XML representation of the connection.
set_position(pos)
Sets the position of the connection, for use in a graphical user interface.
get_destination()
Returns the destination channel.
get_position()
Returns the position of the connection, for use in a graphical user interface.
get_source()
Returns the source channel.
get_xml()
Returns a string XML representation of the connection.
set_position(pos)
Sets the position of the connection, for use in a graphical user interface.
Node(name=None, xml=None)
Nodes can be connected to each other within a NodeNet. Each node has a collection of Channels, where each Channel represents data flowing in to or out of that Node. Nodes also have a name, a position within a network and an icon for displaying the node in graphical user interface.
name
-- an initial name for the new node
xml
-- a string containing XML data which can be used to initialize the node
on_activate(node)
Called when the node is activated. Typically this happens when a use doubleclicks on the node in a GUI control.
on_add_channel(node, channel)
Called when a channel is being added to the node. Return true to abort the addition
on_create_xml_channel(node, xml)
Called when a channel is being created from XML data to be added to this node. Return true to abort the standard processing.
on_delete(node)
Called when the node is being removed from a network. Return true to abort the removal.
on_get_xml(node)
Called when a XML string representation of the node is required. Return a value to provide an alternate representation of the node
on_rename(node, name)
Called when a node is being renamed. Return true to abort the renaming
on_reposition(node, position)
Called when a node is being moved. Return true to abort the reposition.
on_set_xml(node, xml)
Called when a node is being initialized from a string containing XML data. Return true to abort the standard processing
add_channel(channel)
Adds a Channel to this node.
get_channel_by_name(name)
Finds a Channel by its name.
get_channels()
Returns a list of all the Channel objects contained by this node.
get_icon()
Returns the icon for this node.
get_name()
Returns the name of this node.
get_network()
Returns the NodeNet containing this node.
get_position()
Returns the position of this node.
get_xml()
Returns a string containing XML representing this node.
remove_channel(channel)
Removes a Channel from this node.
set_icon(icon)
Sets the icon for this node.
set_name(name)
Sets the name of this node.
set_position(pos)
Sets the position of this node.
set_xml(xml_str)
Initialize this node from an XML string.
add_channel(channel)
Adds a Channel
to this node.
get_channel_by_name(name)
Finds a Channel
by its name. If not present, a ValueError
is thrown.
get_channels()
Returns a list of all the Channel
objects contained by this node.
get_icon()
Returns the icon for this node. The icon is a Python Imaging Library image.
get_name()
Returns the name of this node.
get_network()
Returns the NodeNet
containing this node.
get_position()
Returns the position of this node. The position is represented as a tuple containing two integers.
get_xml()
Returns a string containing XML representing this node. This string can be used to reconstruct this node later.
remove_channel(channel)
Removes a Channel
from this node.
set_icon(icon)
Sets the icon for this node. The icon is a Python Imaging Library image.
set_name(name)
Sets the name of this node.
set_position(pos)
Sets the position of this node. The position is represented as a tuple containing two integers.
set_xml(xml_str)
Initialize this node from an XML string. The string can be obtained from get_xml
.
NodeNet(xml=None)
NodeNet is a data structure for storing networks of nodes. It is
independant of any particular GUI, but it does use the EventHook
class to provide callback hooks which allow an application to be
notified when the network changes.
xml
-- A string containing XML data which can be used to initialize the entire network
on_add_node(node_net, node)
Called when a node is being added to the network. A hook should return true to stop the addition of the new node.
on_change(node_net)
Called when the data in the network is about to change
on_changed(node_net)
Called when the data in the network has changed
on_create_xml_node(node_net, xml)
Called when a new node is being created from a string containing XML. A hook should return true to abort the standard XML processing.
on_get_xml(node_net)
Called when an XML string is being extracted from the network. If a hook returns a value, it is taken as a alternative XML representation of the network.
on_set_xml(node_net)
Called when the network is being initialized from a string containing XML. A hook should return true to abort the standard XML processing.
add_node(node)
Adds a Node to the network.
add_node_from_xml(child_xml_str)
Add a node to the network from a string containg XML.
begin_change()
begin_change and end_change should be called in pairs, bracketing any changes to the NodeNet which should be seen as atomic from the point of view of the on_change and on_changed event hooks.
end_change()
begin_change and end_change should be called in pairs, bracketing any changes to the NodeNet which should be seen as atomic from the point of view of the on_change and on_changed event hooks.
get_connections()
Returns a list of all the Connection objects in the network.
get_node_by_name(name)
Look up a Node by name.
get_nodes()
Returns a list of all the Node objects in the network.
get_xml()
Returns a string containing XML data representing the network.
remove_node(node)
Removes a Node from the network.
set_xml(xml_str)
Initialize the network from a string containing XML.
add_node(node)
Adds a Node
to the network.
add_node_from_xml(child_xml_str)
Add a node to the network from a string containg XML. Unlike set_xml
, the string
passed in should contain a <node> element as the root element, not a <nodenet> element.
begin_change()
begin_change
and end_change
should be called in pairs, bracketing any changes to the NodeNet
which should be seen as atomic from the point of view of the on_change
and on_changed
event hooks.
end_change()
begin_change
and end_change
should be called in pairs, bracketing any changes to the NodeNet
which should be seen as atomic from the point of view of the on_change
and on_changed
event hooks.
get_connections()
Returns a list of all the Connection
objects in the network.
get_node_by_name(name)
Look up a Node
by name. If present, the Node
will
be returned. If not present, a ValueError
will be thrown.
get_nodes()
Returns a list of all the Node
objects in the network.
get_xml()
Returns a string containing XML data representing the network. The network later
be reconstructed by passing the same string to set_xml
or using it
in the constructor.
remove_node(node)
Removes a Node
from the network.
set_xml(xml_str)
Initialize the network from a string containing XML. This string is usually
obtained by an earlier call to get_xml
.