node_socket Module¶
A module containing NodeEditor’s class for representing Socket and Socket Position Constants.
Socket Position Constants¶
-
nodeeditor.node_socket.LEFT_TOP= 1¶
-
nodeeditor.node_socket.LEFT_CENTER= 2¶
-
nodeeditor.node_socket.LEFT_BOTTOM= 3¶
-
nodeeditor.node_socket.RIGHT_TOP= 4¶
-
nodeeditor.node_socket.RIGHT_CENTER= 5¶
-
nodeeditor.node_socket.RIGHT_BOTTOM= 6¶
Socket Class¶
-
class
nodeeditor.node_socket.Socket(node: Node, index: int = 0, position: int = 1, socket_type: int = 1, multi_edges: bool = True, count_on_this_node_side: int = 1, is_input: bool = False)¶ Bases:
nodeeditor.node_serializable.Serializable- Parameters
index (
int) – Current index of this socket in the positionposition – Socket position. See Socket Position Constants
socket_type – Constant defining type(color) of this socket
multi_edges (
bool) – Can this socket have multiple Edges connected?count_on_this_node_side (
int) – number of total sockets on this positionis_input (
bool) – Is this an input Socket?
- Instance Attributes
node - reference to the
Nodecontaining this Socketedges - list of Edges connected to this Socket
grSocket - reference to the
QDMGraphicsSocketposition - Socket position. See Socket Position Constants
index - Current index of this socket in the position
socket_type - Constant defining type(color) of this socket
count_on_this_node_side - number of sockets on this position
is_multi_edges -
Trueif Socket can contain multiple Edgesis_input -
Trueif this socket serves for Inputis_output -
Trueif this socket serves for Output
-
Socket_GR_Class¶
-
delete()¶ Delete this Socket from graphics scene for sure
-
changeSocketType(new_socket_type: int) → bool¶ Change the Socket Type
- Parameters
new_socket_type (
int) – new socket type- Returns
Returns
Trueif the socket type was actually changed- Return type
bool
-
setSocketPosition()¶ Helper function to set Graphics Socket position. Exact socket position is calculated inside
Node.
-
getSocketPosition()¶ - Returns
Returns this Socket position according to the implementation stored in
Node- Return type
x, yposition
-
hasAnyEdge() → bool¶ Returns
Trueif anyEdgeis connected to this socket- Returns
Trueif anyEdgeis connected to this socket- Return type
bool
-
addEdge(edge: Edge)¶ Append an Edge to the list of connected Edges
-
removeEdge(edge: Edge)¶ Disconnect passed
Edgefrom this Socket :param edge:Edgeto disconnect :type edge:Edge
-
removeAllEdges(silent=False)¶ Disconnect all Edges from this Socket
-
determineMultiEdges(data: dict) → bool¶ Deserialization helper function. In our tutorials we created a new version of graph data format. This function is here to help solve the issue of opening older files in the newer format. If the ‘multi_edges’ param is missing in the dictionary, we determine if this Socket should support multiple Edges.
- Parameters
data (
dict) – Socket data indictformat for deserialization- Returns
Trueif this Socket should support multi_edges
-
serialize() → collections.OrderedDict¶ Serialization method to serialize this class data into
OrderedDictwhich can be easily stored in memory or file.- Returns
data serialized in
OrderedDict- Return type
OrderedDict
-
deserialize(data: dict, hashmap: dict = {}, restore_id: bool = True) → bool¶ Deserialization method which take data in python
dictformat with helping hashmap containing references to existing entities.- Parameters
data (
dict) – Dictionary containing serialized datahashmap (
dict) – Helper dictionary containing references (by id == key) to existing objectsrestore_id (bool) – True if we are creating new Sockets. False is useful when loading existing Sockets of which we want to keep the existing object’s id.
- Returns
Trueif deserialization was successful, otherwiseFalse- Return type
bool