dial_core.node_editor.Port¶
-
class
dial_core.node_editor.
Port
(name, port_type, allows_multiple_connections=True)[source]¶ Bases:
object
The Port class provides a connection point between different nodes.
- A Port object allows two types of connections:
- one-to-one: This Port can be only connected to another port.
- many-to-many: This Port can be connected to multiple ports, and multiple ports
- can be connected to this one.
A Port object also has an associated Type. Two Port objects can only be connected if they share the same Type.
Variables: - name – The name (identifier) of the port. Can’t be changed once the Port is created.
- port_type – The type of this port. A Port object can only be connected to other Ports that share its same type.
- connections – Set with all the Ports this port is currently connected to.
- node – The Node object this Port belongs to, if any.
- allows_multiple_connections – A boolean option, indicating the type of connection
- port allows (this) –
-
connect_to
(port)[source]¶ Connects the current port to another port.
Its a two way connection (the two ports will be connected to each other) a = Port() b = Port() a.connect_to(b)
Parameters: port (
Port
) – Port object being connected to.Raises: - ValueError – If the port is connected to itself.
- ValueError – If the ports aren’t compatible (can’t be connected).
-
property
connections
¶ Returns the ports this port is currently connected.
Shouldn’t be manipulated directly. Use the connect_to, disconnect_from functions to handle port connections
Return type: Set
[Port
]Returns: A set with all the Ports connected to this port.
-
disconnect_from
(port)[source]¶ Disconnects the current port from the other port.
Parameters: port ( Port
) – Port object being disconnect from.
-
is_compatible_with
(port)[source]¶ Checks if this port is compatible with another port.
Two ports are compatible if they’re of the same type and don’t belong to the same node.
Parameters: port ( Port
) – Port being compared with.Return type: bool
-
property
name
¶ Returns the name (identifier) of the port.
Return type: str
-
property
port_type
¶ Returns the Type allowed by this port.
Used to check which ports can be connected between them.
Return type: Any