QNodeEditor.socket.Socket#

class QNodeEditor.socket.Socket(entry: Entry, value_type: Type = <class 'int'>)#

Bases: QObject

Socket container holding a reference to all edges connected to it.

This class should not be used since all socket instances are handled by Entry instances automatically.

entry#

Entry this socket belongs to

Type:

Entry

edges#

List of edges connected to this socket

Type:

list[edge.Edge]

graphics#

Graphics object that is shown in the scene representing this socket

Type:

graphics.socket.SocketGraphics

Properties

connected()

Signal that is emitted when a new edge is connected to the socket

disconnected()

Signal that is emitted when an edge is disconnected from the socket

Methods

__init__

Create a new socket.

add_edge

Connect a new edge to the socket.

get_state

Get the state of the socket as a (JSON-safe) dictionary.

remove_all_edges

Remove all edges from the socket

remove_edge

Remove an edge from the socket

set_state

Set the state of this socket from a state dictionary.

update_edges

Update the graphics for all edges connected to this socket

__init__(entry: Entry, value_type: Type = <class 'int'>)#

Create a new socket.

Parameters:
  • entry (Entry) – Entry this socket belongs to

  • value_type (Type) – Type of the socket (not yet implemented)

add_edge(edge: Edge) None#

Connect a new edge to the socket.

Parameters:

edge (edge.Edge) – Edge to connect to the socket

Return type:

None

get_state() dict#

Get the state of the socket as a (JSON-safe) dictionary.

The dictionary contains:

  • id: The internal ID of the socket

Returns:

JSON-safe dictionary representing socket state

Return type:

dict

remove_all_edges() None#

Remove all edges from the socket

Return type:

None

remove_edge(edge: Edge) None#

Remove an edge from the socket

Parameters:

edge (edge.Edge) – Edge to remove from the socket

Return type:

None

set_state(state: dict, restore_id: bool = True) bool#

Set the state of this socket from a state dictionary.

The dictionary contains:

  • id: The internal ID of the socket

Parameters:
  • state (dict) – Dictionary representation of the desired socket state

  • restore_id (bool) – Whether to restore the internal ID or use a new one

Returns:

Whether setting the entry state succeeded.

Return type:

bool

update_edges() None#

Update the graphics for all edges connected to this socket

Return type:

None

connected: Signal#

Signal that is emitted when a new edge is connected to the socket

Type:

Signal

disconnected: Signal#

Signal that is emitted when an edge is disconnected from the socket

Type:

Signal