Package NetworkEditor :: Module items :: Class NetworkNodeBase
[hide private]
[frames] | no frames]

Class NetworkNodeBase

source code

               object --+        
                        |        
itemBase.NetworkItemsBase --+    
                            |    
        itemBase.NetworkItems --+
                                |
                               NetworkNodeBase
Known Subclasses:
NetworkNode

Base class for a network editor Node

Instance Methods [hide private]
  __init__(self, name='NoName', sourceCode=None, originalClass=None, constrkw=None, library=None, progbar=0, autoRun=True, **kw)
  configure(self, **kw)
Configure a NetworkNode object.
  getDescr(self)
returns a dict with the current configuration of this node
  rename(self, name, tagModified=True)
Rename a node.
  ischild(self, node)
returns True is self is a child node of node
  isMacro(self)
Returns False if this node is not a MacroNode, returns True if MacroNode
  startMoveOneNode(self, event)
  moveSelectedNodeEnd(self, event)
  isModified(self)
  resetModifiedTag(self)
set _modified attribute to False in node, ports, widgets.
  resetTags(self)
set _modified attribute to False in node, ports, widgets.
  getInputPortByName(self, name)
  getOutputPortByName(self, name)
  getSpecialInputPortByName(self, name)
  getSpecialOutputPortByName(self, name)
  getInConnections(self)
  getOutConnections(self)
  getConnections(self)
  getWidgetByName(self, name)
  getNodeDefinitionSourceCode(self, networkName, indent="", ignoreOriginal=False)
This method builds the text-string to describe a network node in a saved file.
  getNodeSourceCodeForModifications(self, networkName, indent="", ignoreOriginal=False)
Return the code that describes node modifications compared to the original node (as described in a node library)
  getNodeSourceCodeForInstanciation(self, networkName="masterNet", indent="", ignoreOriginal=False, full=0)
This method is called when saving a network.
  getNodeSourceCodeForPorts(self, networkName, indent="", ignoreOriginal=False, full=0, dummyNode=None, nodeName=None)
Create code used to save a network which reflects changes of ports compared to the port definitions in a given network node of a node library.
  getNodeSourceCodeForWidgets(self, networkName, indent="", ignoreOriginal=False, full=0, dummyNode=None, nodeName=None)
Create code used to save a network which reflects changes of widgets compared to the widget definitions in a given network node of a node library.
  getNodeSourceCodeForWidgetValue(self, networkName, portIndex, indent="", ignoreOriginal=False, full=0, nodeName=None)
Returns code to set the widget value.
  getNodeSourceCodeForNode(self, networkName, indent="", ignoreOriginal=False, full=0)
return code to configure a node with modifications compared to the node definition in a node library.
  getNodeSourceCodeForDoit(self, networkName, nodeName, indent="", ignoreOriginal=False, full=0)
  getAfterConnectionsSourceCode(self, networkName, indent="", ignoreOriginal=False)
Here, we provide a hook for users to generate source code which might be needed to adress certain events after connections were formed: for example, connections might generate new ports.
  compareToOrigNodeDescr(self)
compare this node to the original node as defined in a given node library, such as StandardNodes.
  checkIfNodeForSavingIsDefined(self, lines, networkName, indent)
This method fixes a problem with saving macros that come from a node library.
  saveSource_cb(self, dependencies=False)
the classname is extracted from the given filename
  saveSource(self, filename, classname, dependencies=False)
  getNodeSourceCode(self, className, networkName='self.network', indent="", dependencies=False)
This method is called through the 'save source code' mechanism.
  getHeaderBlock(self, className, indent="", **kw)
Generate source code to import a node from a library or file.
  getInitBlock(self, className, indent="", **kw)
Generate source code to define the __init__() method of the node, building the correct constrkw dict, etc.
  getPortsCreationSourceCode(self, ports, ptype='input', indent="", **kw)
generates code to create ports using the inputportsDescr and outputPortsDescr
  getWidgetsCreationSourceCode(self, indent="", **kw)
generating code to create widgets using the widgetDescr
  getComputeFunctionSourceCode(self, indent="", **kw)
  outputData(self, **kw)
  setFunction(self, source, tagModified=True)
Set the node's compute function.
  scheduleChildren(self, portList=None)
run the children of this node in the same thread as the parent if portList is None all children are scheduled, else only children of the specified ports are scheduled
  schedule_cb(self, event=None)
  schedule(self)
start an execution thread for the subtree under that node
  computeFunction(self)
  growRight(self, id, dx)
Expand (and shrink) the x-dimension of the node icon to (and from) the right.
  growDown(self, id, dy)
Expand (and shrink) the y-dimension of the node icon to (and from) the top.
  updateCode(self, port='ip', action=None, tagModified=True, **kw)
update signature of compute function in source code.
  toggleNodeExpand_cb(self, event=None)
  getWidthForPorts(self, maxi=None)
  getWidthForLabel(self, maxi=None)
  getWidthForNodeWidgets(self, maxi=None)
  autoResizeX(self)
  autoResizeY(self)
  autoResize(self)
  getSize(self)
returns size of this node as a tuple of (width, height) in pixels
  hideInNodeWidgets(self, rescale=1)
  showInNodeWidgets(self, rescale=1)
  getWidgetsForMaster(self, masterName)
Return a dict of all widgets bound for a given master in a given node (self).
  buildIcons(self, canvas, posx, posy, small=False)
Build NODE icon with ports etc
  addSaveNodeMenuEntries(self)
add 'save source code' and 'add to library' entried tonode menu'
  cut_cb(self, event=None)
  delete_cb(self, event=None)
  edit(self, event=None)
  editComputeFunction_cb(self, event=None)
  evalString(self, str)
  move(self, dx, dy, absolute=True, tagModified=True)
if absolute is set to False, the node moves about the increment dx,dy.
  getSourceCode(self)
  toggleParamPanel_cb(self, event=None)
  getOutputPortByType(self, type, name=None)
  getStateDefinitionCode(self, nodeName, indent='')
  getUniqueNodeName(self)
  safeName(self, name)
remove all weird symbols from node name so that it becomes a regular string usabel as a Python variable in a saved network

Inherited from itemBase.NetworkItems: __repr__, afterAddingToNetwork, afterRemovingFromNetwork, beforeAddingToNetwork, beforeRemovingFromNetwork, deleteIcon, deletePort, deselect, editNodeMenu, freeze, gettags, hideParamPanel, highlight, introspect, postItemMenu, run, select, toggleAutoRun_cb, toggleFrozen_cb, unfreeze, unhighlight

Inherited from itemBase.NetworkItems (private): _introspectCB

Inherited from itemBase.NetworkItemsBase: delEditor, getEditor, setEditor

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __str__


Properties [hide private]

Inherited from itemBase.NetworkItemsBase: editor

Inherited from object: __class__


Method Details [hide private]

__init__(self, name='NoName', sourceCode=None, originalClass=None, constrkw=None, library=None, progbar=0, autoRun=True, **kw)
(Constructor)

source code 
None
Overrides: itemBase.NetworkItems.__init__

configure(self, **kw)

source code 
Configure a NetworkNode object. Going through this framework tags
the node modified. Supports the following keywords:
name:       node name (string)
position:   node position on canvas. Must be a tuple of (x,y) coords
function:   the computational method of this node
expanded:   True or False. If True: expand the node
specialPortsVisible: True or False. If True: show the special ports
paramPanelImmediate: True or False. This sets the node's paramPanel immediate
                     state

getDescr(self)

source code 
returns a dict with the current configuration of this node

rename(self, name, tagModified=True)

source code 
Rename a node. remember the name has changed, resize the node if necessary
Overrides: itemBase.NetworkItems.rename

ischild(self, node)

source code 
returns True is self is a child node of node

isMacro(self)

source code 
Returns False if this node is not a MacroNode, returns True if MacroNode

startMoveOneNode(self, event)

source code 
None

moveSelectedNodeEnd(self, event)

source code 
None

isModified(self)

source code 
None

resetModifiedTag(self)

source code 
set _modified attribute to False in node, ports, widgets.

resetTags(self)

source code 
set _modified attribute to False in node, ports, widgets. Also, sets _original attribute to True in node, ports, widgets And we also reset the two flags in all connections from and to ports

getInputPortByName(self, name)

source code 
None

getOutputPortByName(self, name)

source code 
None

getSpecialInputPortByName(self, name)

source code 
None

getSpecialOutputPortByName(self, name)

source code 
None

getInConnections(self)

source code 
None

getOutConnections(self)

source code 
None

getConnections(self)

source code 
None

getWidgetByName(self, name)

source code 
None

getNodeDefinitionSourceCode(self, networkName, indent="", ignoreOriginal=False)

source code 
This method builds the text-string to describe a network node
in a saved file.
networkName: string holding the networkName
indent: string of whitespaces for code indentation. Default: ''
ignoreOriginal: True/False. Default: False. If set to True, the node's attr
                _original is ignored (used in cut/copy/paste nodes inside a
                macro that came from a node library where nodes are marked
                original
This method is called by net.getNodesCreationSourceCode()
NOTE: macros.py MacroNode re-implements this method!

getNodeSourceCodeForModifications(self, networkName, indent="", ignoreOriginal=False)

source code 
Return the code that describes node modifications compared to the original node (as described in a node library)

getNodeSourceCodeForInstanciation(self, networkName="masterNet", indent="", ignoreOriginal=False, full=0)

source code 
This method is called when saving a network. Here, code is generated to import a node from a library, instanciate the node, and adding it to the network.

getNodeSourceCodeForPorts(self, networkName, indent="", ignoreOriginal=False, full=0, dummyNode=None, nodeName=None)

source code 
Create code used to save a network which reflects changes of ports compared to the port definitions in a given network node of a node library. We create text to configure a port with changes, adding a port or deleting a port. If optional keyword 'full' is set to 1, we will append text to configure unchanged ports

getNodeSourceCodeForWidgets(self, networkName, indent="", ignoreOriginal=False, full=0, dummyNode=None, nodeName=None)

source code 
Create code used to save a network which reflects changes of widgets compared to the widget definitions in a given network node of a node library. We create text to configure a widget with changes, adding a widget or deleting a widget. If optional keyword 'full' is set to 1, we will append text to configure unchanged widgets.

getNodeSourceCodeForWidgetValue(self, networkName, portIndex, indent="", ignoreOriginal=False, full=0, nodeName=None)

source code 
Returns code to set the widget value. Note: here we have to take unbound widgets into account.

getNodeSourceCodeForNode(self, networkName, indent="", ignoreOriginal=False, full=0)

source code 
return code to configure a node with modifications compared to the node definition in a node library. Note:

getNodeSourceCodeForDoit(self, networkName, nodeName, indent="", ignoreOriginal=False, full=0)

source code 
None

getAfterConnectionsSourceCode(self, networkName, indent="", ignoreOriginal=False)

source code 
Here, we provide a hook for users to generate source code which might be needed to adress certain events after connections were formed: for example, connections might generate new ports.

compareToOrigNodeDescr(self)

source code 
compare this node to the original node as defined in a given node library, such as StandardNodes. Return a dictionary containing the differences.

checkIfNodeForSavingIsDefined(self, lines, networkName, indent)

source code 
This method fixes a problem with saving macros that come from a node library. If only a widget value has changed, we do not have a handle to the node. Thus, we need to create this additional line to get a handle

saveSource_cb(self, dependencies=False)

source code 
the classname is extracted from the given filename

saveSource(self, filename, classname, dependencies=False)

source code 
None

getNodeSourceCode(self, className, networkName='self.network', indent="", dependencies=False)

source code 
This method is called through the 'save source code' mechanism.

Generate source code describing a node. This code can be put 
into a node library. This is not for saving networks.

dependencies: True/False
    False: the node is fully independent from his original node. 
    True : the node is saved as a subclass of the original node, and only 
           modifications from the original are saved. 

getHeaderBlock(self, className, indent="", **kw)

source code 
Generate source code to import a node from a library or file.

getInitBlock(self, className, indent="", **kw)

source code 
Generate source code to define the __init__() method of the node, building the correct constrkw dict, etc.

getPortsCreationSourceCode(self, ports, ptype='input', indent="", **kw)

source code 
generates code to create ports using the inputportsDescr and outputPortsDescr

getWidgetsCreationSourceCode(self, indent="", **kw)

source code 
generating code to create widgets using the widgetDescr

getComputeFunctionSourceCode(self, indent="", **kw)

source code 
None

outputData(self, **kw)

source code 
None

setFunction(self, source, tagModified=True)

source code 
Set the node's compute function. If tagModified is True, we set _modified=True

scheduleChildren(self, portList=None)

source code 
run the children of this node in the same thread as the parent if portList is None all children are scheduled, else only children of the specified ports are scheduled

schedule_cb(self, event=None)

source code 
None
Overrides: itemBase.NetworkItems.schedule_cb

schedule(self)

source code 
start an execution thread for the subtree under that node

computeFunction(self)

source code 
None

growRight(self, id, dx)

source code 
Expand (and shrink) the x-dimension of the node icon to (and from) the right.

growDown(self, id, dy)

source code 
Expand (and shrink) the y-dimension of the node icon to (and from) the top.

updateCode(self, port='ip', action=None, tagModified=True, **kw)

source code 
update signature of compute function in source code. We re-write the first line with all port names as arguments. **kw are not used but allow to match updateCode signature of output ports

toggleNodeExpand_cb(self, event=None)

source code 
None

getWidthForPorts(self, maxi=None)

source code 
None

getWidthForLabel(self, maxi=None)

source code 
None

getWidthForNodeWidgets(self, maxi=None)

source code 
None

autoResizeX(self)

source code 
None

autoResizeY(self)

source code 
None

autoResize(self)

source code 
None

getSize(self)

source code 
returns size of this node as a tuple of (width, height) in pixels

hideInNodeWidgets(self, rescale=1)

source code 
None

showInNodeWidgets(self, rescale=1)

source code 
None

getWidgetsForMaster(self, masterName)

source code 
Return a dict of all widgets bound for a given master in a given node (self). Masters can be 'Node' or 'ParamPanel'. key is an instance of the port, value is an instance of the widget

buildIcons(self, canvas, posx, posy, small=False)

source code 
Build NODE icon with ports etc
Overrides: itemBase.NetworkItems.buildIcons

addSaveNodeMenuEntries(self)

source code 
add 'save source code' and 'add to library' entried tonode menu'

cut_cb(self, event=None)

source code 
None

delete_cb(self, event=None)

source code 
None

edit(self, event=None)

source code 
None

editComputeFunction_cb(self, event=None)

source code 
None

evalString(self, str)

source code 
None

move(self, dx, dy, absolute=True, tagModified=True)

source code 
if absolute is set to False, the node moves about the increment dx,dy. If absolute is True, the node moves to the position dx,dy Connections are updated automatically.

getSourceCode(self)

source code 
None

toggleParamPanel_cb(self, event=None)

source code 
None

getOutputPortByType(self, type, name=None)

source code 
None

getStateDefinitionCode(self, nodeName, indent='')

source code 
None

getUniqueNodeName(self)

source code 
None

safeName(self, name)

source code 
remove all weird symbols from node name so that it becomes a regular string usabel as a Python variable in a saved network