API

Scene and View

FlowScene

class qtpynodeeditor.FlowScene(registry=None, style=None, parent=None, allow_node_creation=True, allow_node_deletion=True)[source]
auto_arrange(layout='bipartite', scale=700, align='horizontal', **kwargs)[source]

Automatically arrange nodes with networkx, if available

Raises
ImportError

If networkx is unavailable

create_connection(port_a: qtpynodeeditor.port.Port, port_b: qtpynodeeditor.port.Port = None, *, converter: qtpynodeeditor.type_converter.TypeConverter = None, check_cycles=True) → qtpynodeeditor.connection.Connection[source]

Create a connection

Parameters
port_aPort

The first port, either input or output

port_bPort, optional

The second port, opposite of the type of port_a

converterTypeConverter, optional

The type converter to use for data propagation

check_cyclesbool, optional

Ensures that creating the connection would not introduce a cycle

Returns
valueConnection
Raises
NodeConnectionFailure

If it is not possible to create the connection

ConnectionDataTypeFailure

If port data types are not compatible

create_connection_by_index(node_in: qtpynodeeditor.node.Node, port_index_in: int, node_out: qtpynodeeditor.node.Node, port_index_out: int, converter: qtpynodeeditor.type_converter.TypeConverter) → qtpynodeeditor.connection.Connection[source]

Create connection

Parameters
node_inNode
port_index_inint
node_outNode
port_index_outint
converterTypeConverter
Returns
valueConnection
create_node(data_model: qtpynodeeditor.node_data.NodeDataModel) → qtpynodeeditor.node.Node[source]

Create a node in the scene

Parameters
data_modelNodeDataModel
Returns
valueNode
restore_connection(connection_json: dict) → qtpynodeeditor.connection.Connection[source]

Restore a connection.

Parameters
connection_jsondict
Returns
valueConnection
restore_node(node_json: dict) → qtpynodeeditor.node.Node[source]

Restore a node from a state dictinoary

Parameters
node_jsondict
Returns
valueNode
selected_nodes() → list[source]

Selected nodes

Returns
valuelist of Node
property style_collection

The style collection for the scene

FlowView

class qtpynodeeditor.FlowView(parent: QWidget = None) QGraphicsView(QGraphicsScene, parent: QWidget = None)[source]
clear_selection_action() → PyQt5.QtWidgets.QAction[source]

Clear selection action

Returns
valueQAction
contextMenuEvent(event: PyQt5.QtGui.QContextMenuEvent)[source]
Parameters
eventQContextMenuEvent
delete_selection_action() → PyQt5.QtWidgets.QAction[source]

Delete selection action

Returns
valueQAction
drawBackground(painter: PyQt5.QtGui.QPainter, r: PyQt5.QtCore.QRectF)[source]
Parameters
painterQPainter
rQRectF
generate_context_menu(pos: PyQt5.QtCore.QPoint)[source]

Generate a context menu for contextMenuEvent

Parameters
posQPoint

The point where the context menu was requested

keyPressEvent(event: PyQt5.QtGui.QKeyEvent)[source]
Parameters
eventQKeyEvent
keyReleaseEvent(event: PyQt5.QtGui.QKeyEvent)[source]
Parameters
eventQKeyEvent
mouseMoveEvent(event: PyQt5.QtGui.QMouseEvent)[source]
Parameters
eventQMouseEvent
mousePressEvent(event: PyQt5.QtGui.QMouseEvent)[source]
Parameters
eventQMouseEvent
property scene

Scene

Returns
valueFlowScene
setScene(scene: qtpynodeeditor.flow_scene.FlowScene)[source]
Parameters
sceneFlowScene
showEvent(event: PyQt5.QtGui.QShowEvent)[source]
Parameters
eventQShowEvent
wheelEvent(event: PyQt5.QtGui.QWheelEvent)[source]
Parameters
eventQWheelEvent

Styles

StyleCollection

class qtpynodeeditor.StyleCollection(*, node=None, connection=None, flow_view=None)[source]

Container for all styles

Style

class qtpynodeeditor.Style(json_style=None)[source]
load_from_json(json_style: str)[source]

Load from json

Parameters
json_stylestr or dict

ConnectionStyle

class qtpynodeeditor.ConnectionStyle(json_style=None)[source]

Style for connections

Attributes
construction_colorQColor
normal_colorQColor
selected_colorQColor
selected_halo_colorQColor
hovered_colorQColor
line_widthfloat
construction_line_widthfloat
point_diameterfloat
use_data_defined_colorsbool
get_normal_color(type_id: str = None) → PyQt5.QtGui.QColor[source]

Normal color

Parameters
type_idstr
Returns
valueQColor
load_from_json(json_style: str)[source]

Load from json

Parameters
json_stylestr

FlowViewStyle

class qtpynodeeditor.FlowViewStyle(json_style=None)[source]
load_from_json(json_style: str)[source]

Load from json

Parameters
json_stylestr or dict

NodeStyle

class qtpynodeeditor.NodeStyle(json_style=None)[source]
load_from_json(json_style: str)[source]

Load from json

Parameters
json_stylestr

Nodes

Node

class qtpynodeeditor.Node(parent: QObject = None)[source]
property geometry

Get the node geometry.

Returns
valueNodeGeometry
property graphics_object

Get/set the associated node graphics object.

Returns
valueNodeGraphicsObject
has_any_connection(node: qtpynodeeditor.node.Node) → bool[source]

Is this node connected to node through any port?

Parameters
nodeNode

The node to check connectivity

Returns
connectedbool
has_connection_by_port_type(target: qtpynodeeditor.node.Node, port_type: qtpynodeeditor.enums.PortType) → bool[source]

Is this node connected to target through an input/output port?

Parameters
targetNode

The target node to check connectivity

port_typePortType

The port type (PortType.input, PortType.output) to check

Returns
connectedbool
property id

Node unique identifier (uuid)

Returns
valuestr
property model

Get the node data model.

Returns
valueNodeDataModel
on_data_updated(port: qtpynodeeditor.port.Port)[source]

Fetches data from model’s output port and propagates it along the connection

Parameters
portPort
on_node_size_updated()[source]

update the graphic part if the size of the embeddedwidget changes

property position

Get the node position

Parameters
nodeNode
Returns
valueQPointF
propagate_data(node_data: qtpynodeeditor.node_data.NodeData, input_port: qtpynodeeditor.port.Port)[source]

Propagates incoming data to the underlying model.

Parameters
node_dataNodeData
input_portint
react_to_possible_connection(reacting_port_type: qtpynodeeditor.enums.PortType, reacting_data_type: qtpynodeeditor.node_data.NodeDataType, scene_point: PyQt5.QtCore.QPointF)[source]

React to possible connection

Parameters
port_typePortType
node_data_typeNodeDataType
scene_pointQPointF
property size

Get the node size

Parameters
nodeNode
Returns
valueQSizeF
property state

Node state

Returns
valueNodeState
property style

Node style

walk_paths_by_port_type(port_type: qtpynodeeditor.enums.PortType) → Generator[Tuple[qtpynodeeditor.node.Node, ], None, None][source]

Yields paths to connected nodes by port type

Yields
node_pathtuple

The path to the node

NodeData

class qtpynodeeditor.NodeData[source]

Class represents data transferred between nodes.

The actual data is stored in subtypes

same_type(other) → bool[source]

Is another NodeData instance of the same type?

Parameters
otherNodeData
Returns
valuebool

NodeDataModel

class qtpynodeeditor.NodeDataModel(parent: QObject = None)[source]
property data_type

Data type placeholder - to be implemented by subclass.

Parameters
port_typePortType
port_indexint
Returns
valueNodeDataType
embedded_widget() → PyQt5.QtWidgets.QWidget[source]

Embedded widget

Returns
valueQWidget
input_connection_created(connection)[source]

Input connection created

Parameters
connectionConnection
input_connection_deleted(connection)[source]

Input connection deleted

Parameters
connectionConnection
property node_style

Node style

Returns
valueNodeStyle
out_data(port: int) → qtpynodeeditor.node_data.NodeData[source]

Out data

Parameters
portint
Returns
valueNodeData
output_connection_created(connection)[source]

Output connection created

Parameters
connectionConnection
output_connection_deleted(connection)[source]

Output connection deleted

Parameters
connectionConnection
painter_delegate()[source]

Painter delegate

Returns
valueNodePainterDelegate
port_out_connection_policy(port_index: int) → qtpynodeeditor.enums.ConnectionPolicy[source]

Port out connection policy

Parameters
port_indexint
Returns
valueConnectionPolicy
resizable() → bool[source]

Resizable

Returns
valuebool
restore(doc: dict)[source]

Subclasses may implement this to load additional state from pickled or saved-to-JSON data.

Parameters
valuedict
save() → dict[source]

Subclasses may implement this to save additional state for pickling/saving to JSON.

Returns
valuedict
set_in_data(node_data: qtpynodeeditor.node_data.NodeData, port: qtpynodeeditor.port.Port)[source]

Triggers the algorithm; to be overridden by subclasses

Parameters
node_dataNodeData
portPort
property style

Style collection for drawing this data model

validation_message() → str[source]

Validation message

Returns
valuestr
validation_state() → qtpynodeeditor.enums.NodeValidationState[source]

Validation state

Returns
valueNodeValidationState

NodeState

class qtpynodeeditor.NodeState(node)[source]
property all_connections

All input and output connections

connections(port_type: qtpynodeeditor.enums.PortType, port_index: int) → list[source]

Connections

Parameters
port_typePortType
port_indexint
Returns
valuelist
erase_connection(port_type: qtpynodeeditor.enums.PortType, port_index: int, connection: Connection)[source]

Erase connection

Parameters
port_typePortType
port_indexint
connectionConnection
property input_connections

All input connections

property is_reacting

Is the node reacting to a mouse event?

Returns
valuebool
property output_connections

All output connections

property reacting_data_type

Reacting data type

Returns
valueNodeDataType
property reacting_port_type

Reacting port type

Returns
valuePortType
property reaction

Reaction

Returns
valueNodeState.ReactToConnectionState
property resizing

Resizing

Returns
valuebool
set_reaction(reaction: qtpynodeeditor.enums.ReactToConnectionState, reacting_port_type: qtpynodeeditor.enums.PortType = <PortType.none: 'none'>, reacting_data_type: qtpynodeeditor.node_data.NodeDataType = None)[source]

Set reaction

Parameters
reactionNodeState.ReactToConnectionState
reacting_port_typePortType, optional
reacting_data_typeNodeDataType

NodeDataType

class qtpynodeeditor.NodeDataType(id, name)
property id

Alias for field number 0

property name

Alias for field number 1

NodeGeometry

class qtpynodeeditor.NodeGeometry(node: Node)[source]
property bounding_rect

Bounding rect

Returns
valueQRectF
static calculate_node_position_between_node_ports(target_port_index: int, target_port: qtpynodeeditor.enums.PortType, target_node: Node, source_port_index: int, source_port: qtpynodeeditor.enums.PortType, source_node: Node, new_node: Node) → PyQt5.QtCore.QPointF[source]

calculate node position between node ports

Calculating the nodes position in the scene. It’ll be positioned half way between the two ports that it “connects”. The first line calculates the halfway point between the ports (node position + port position on the node for both nodes averaged). The second line offsets self coordinate with the size of the new node, so that the new nodes center falls on the originally calculated coordinate, instead of it’s upper left corner.

Parameters
target_port_indexint
target_portPortType
target_nodeNode
source_port_indexint
source_portPortType
source_nodeNode
new_nodeNode
Returns
valueQPointF
property caption_height

Caption height

Returns
valueint
property caption_width

Caption width

Returns
valueint
check_hit_scene_point(port_type: qtpynodeeditor.enums.PortType, scene_point: PyQt5.QtCore.QPointF, scene_transform: PyQt5.QtGui.QTransform) → Optional[qtpynodeeditor.port.Port][source]

Check a scene point for a specific port type.

Parameters
port_typePortType

The port type to check for.

scene_pointQPointF

The point in the scene.

scene_transformQTransform

The scene transform.

Returns
portPort or None

The nearby port, if found.

property dragging_pos

Dragging pos

Returns
valueQPointF
property dragging_position

Dragging pos

Returns
valueQPointF
entry_bounding_rect(*, addon=0.0) → PyQt5.QtCore.QRectF[source]

Entry bounding rect

Returns
valueQRectF
property entry_height

Entry height

Returns
valueint
property entry_width

Entry width

Returns
valueint
equivalent_widget_height() → int[source]

The maximum height a widget can be without causing the node to grow.

Returns
valueint
property height

Node height.

Returns
valueint
property hovered

Hovered

Returns
valuebool
property num_sinks

Number of sinks.

Returns
valueint
property num_sources

Number of sources.

Returns
valueint
port_scene_position(port_type: qtpynodeeditor.enums.PortType, index: int, t: PyQt5.QtGui.QTransform = None) → PyQt5.QtCore.QPointF[source]

Port scene position

Parameters
port_typePortType
indexint
tQTransform
Returns
valueQPointF
port_width(port_type: qtpynodeeditor.enums.PortType) → int[source]

Port width

Parameters
port_typePortType
Returns
valueint
recalculate_size(font: PyQt5.QtGui.QFont = None)[source]
If font is unspecified,

Updates size unconditionally

Otherwise,

Updates size if the QFontMetrics is changed

property resize_rect

Resize rect

Returns
valueQRect
property size

Get the node size

Parameters
nodeNode
Returns
valueQSizeF
property spacing

Spacing

Returns
valueint
property validation_height

Validation height

Returns
valueint
property validation_width

Validation width

Returns
valueint
property widget_position

Returns the position of a widget on the Node surface

Returns
valueQPointF
property width

Node width.

Returns
valueint

NodeGraphicsObject

class qtpynodeeditor.NodeGraphicsObject(parent: QGraphicsItem = None)[source]
boundingRect() → PyQt5.QtCore.QRectF[source]
Returns
valueQRectF
contextMenuEvent(event: PyQt5.QtWidgets.QGraphicsSceneContextMenuEvent)[source]
Parameters
eventQGraphicsSceneContextMenuEvent
hoverEnterEvent(event: PyQt5.QtWidgets.QGraphicsSceneHoverEvent)[source]
Parameters
eventQGraphicsSceneHoverEvent
hoverLeaveEvent(event: PyQt5.QtWidgets.QGraphicsSceneHoverEvent)[source]
Parameters
eventQGraphicsSceneHoverEvent
hoverMoveEvent(event: PyQt5.QtWidgets.QGraphicsSceneHoverEvent)[source]
Parameters
q_graphics_scene_hover_eventQGraphicsSceneHoverEvent
itemChange(change: PyQt5.QtWidgets.QGraphicsItem.GraphicsItemChange, value: Any) → Any[source]
Parameters
changeQGraphicsItem.GraphicsItemChange
valueany
Returns
valueany
lock(locked: bool)[source]

Lock

Parameters
lockedbool
mouseDoubleClickEvent(event: PyQt5.QtWidgets.QGraphicsSceneMouseEvent)[source]
Parameters
eventQGraphicsSceneMouseEvent
mouseMoveEvent(event: PyQt5.QtWidgets.QGraphicsSceneMouseEvent)[source]
Parameters
eventQGraphicsSceneMouseEvent
mousePressEvent(event: PyQt5.QtWidgets.QGraphicsSceneMouseEvent)[source]
Parameters
eventQGraphicsSceneMouseEvent
mouseReleaseEvent(event: PyQt5.QtWidgets.QGraphicsSceneMouseEvent)[source]
Parameters
eventQGraphicsSceneMouseEvent
move_connections()[source]

Visits all attached connections and corrects their corresponding end points.

property node

Node

Returns
valueNode
paint(painter: PyQt5.QtGui.QPainter, option: PyQt5.QtWidgets.QStyleOptionGraphicsItem, widget: PyQt5.QtWidgets.QWidget)[source]

Paint

Parameters
painterQPainter
optionQStyleOptionGraphicsItem
widgetQWidget
setPos(self, Union[QPointF, QPoint]) setPos(self, float, float)[source]

DataModelRegistry

class qtpynodeeditor.DataModelRegistry[source]
categories() → set[source]

Categories

Returns
valueDataModelRegistry.CategoriesSet
create(model_name: str) → qtpynodeeditor.node_data.NodeDataModel[source]

Create a NodeDataModel given its user-friendly name.

Parameters
model_namestr
Returns
data_model_instanceNodeDataModel

The instance of the given data model.

Raises
ValueError

If the model name is not registered.

get_model_by_name(model_name: str) → Tuple[Type[qtpynodeeditor.node_data.NodeDataModel], dict][source]

Get information on how to create a specific NodeDataModel node given its user-friendly name.

Parameters
model_namestr
Returns
data_modelNodeDataModel

The data model class.

init_kwargsdict

Default init keyword arguments.

Raises
ValueError

If the model name is not registered.

get_type_converter(d1: qtpynodeeditor.node_data.NodeDataType, d2: qtpynodeeditor.node_data.NodeDataType) → qtpynodeeditor.type_converter.TypeConverter[source]

Get type converter

Parameters
d1NodeDataType
d2NodeDataType
Returns
valueTypeConverter
register_type_converter(type_in: qtpynodeeditor.node_data.NodeDataType, type_out: qtpynodeeditor.node_data.NodeDataType, type_converter: qtpynodeeditor.type_converter.TypeConverter)[source]

Register a type converter for a given data type.

Parameters
type_inNodeDataType or NodeData subclass

The input type.

type_outNodeDataType or NodeData subclass

The output type.

type_converterTypeConverter

The type converter to use for the conversion.

registered_model_creators() → dict[source]

Registered model creators

Returns
valuedict
registered_models_category_association() → dict[source]

Registered models category association

Returns
valueDataModelRegistry.RegisteredModelsCategoryMap

Connections

Connection

class qtpynodeeditor.Connection(parent: QObject = None)[source]
clear_node(port_type: qtpynodeeditor.enums.PortType)[source]

Clear node

Parameters
port_typePortType
connect_to(port: qtpynodeeditor.port.Port)[source]

Assigns a node to the required port.

Parameters
portPort
data_type(port_type: qtpynodeeditor.enums.PortType) → qtpynodeeditor.node_data.NodeDataType[source]

Data type

Parameters
port_typePortType
Returns
valueNodeDataType
property geometry

Connection geometry

Returns
valueConnectionGeometry
get_node(port_type: qtpynodeeditor.enums.PortType) → Optional[qtpynodeeditor.node.Node][source]

Get node

Parameters
port_typePortType
Returns
valueNode
get_port_index(port_type: qtpynodeeditor.enums.PortType) → int[source]

Get port index

Parameters
port_typePortType
Returns
indexint
property graphics_object

Get the connection graphics object

Returns
graphicsConnectionGraphicsObject
property id

Unique identifier (uuid)

Returns
uuidstr
property input_node

Input node

interact_with_node(node: qtpynodeeditor.node.Node)[source]

Interact with node

Parameters
nodeNode
property is_complete

Connection is complete - in/out nodes are set

Returns
valuebool
property last_hovered_node

Last hovered node

Returns
valueNode
property output

Output node

property output_node

Output node

propagate_data(node_data: qtpynodeeditor.node_data.NodeData)[source]

Propagate the given data from the output port -> input port.

Parameters
node_dataNodeData
property required_port

Required port

Returns
valuePortType
property requires_port

Requires port

Returns
valuebool
property type_converter

The type converter used for the connection.

Returns
converterTypeConverter or None

ConnectionGeometry

class qtpynodeeditor.ConnectionGeometry(style)[source]
property bounding_rect

Bounding rect

Returns
valueQRectF
get_end_point(port_type: qtpynodeeditor.enums.PortType) → PyQt5.QtCore.QPointF[source]

Get end point

Parameters
port_typePortType
Returns
valueQPointF
property hovered

Hovered

Returns
valuebool
line_width() → float[source]

Line width

Returns
valuedouble
move_end_point(port_type: qtpynodeeditor.enums.PortType, offset: PyQt5.QtCore.QPointF)[source]

Move end point

Parameters
port_typePortType
offsetQPointF
points_c1_c2() → tuple[source]

Connection points (c1, c2)

Returns
c1: QPointF

The first point

c2: QPointF

The second point

set_end_point(port_type: qtpynodeeditor.enums.PortType, point: PyQt5.QtCore.QPointF)[source]

Set end point

Parameters
port_typePortType
pointQPointF
property sink

Sink

Returns
valueQPointF
property source

Source

Returns
valueQPointF

ConnectionGraphicsObject

class qtpynodeeditor.ConnectionGraphicsObject(parent: QGraphicsItem = None)[source]
boundingRect() → PyQt5.QtCore.QRectF[source]
Returns
valueQRectF
property connection

Connection

Returns
valueConnection
hoverEnterEvent(event: PyQt5.QtWidgets.QGraphicsSceneHoverEvent)[source]
Parameters
eventQGraphicsSceneHoverEvent
hoverLeaveEvent(event: PyQt5.QtWidgets.QGraphicsSceneHoverEvent)[source]
Parameters
eventQGraphicsSceneHoverEvent
lock(locked: bool)[source]

Lock

Parameters
lockedbool
mouseMoveEvent(event: PyQt5.QtWidgets.QGraphicsSceneMouseEvent)[source]
Parameters
eventQGraphicsSceneMouseEvent
mousePressEvent(event: PyQt5.QtWidgets.QGraphicsSceneMouseEvent)[source]
Parameters
eventQGraphicsSceneMouseEvent
mouseReleaseEvent(event: PyQt5.QtWidgets.QGraphicsSceneMouseEvent)[source]
Parameters
eventQGraphicsSceneMouseEvent
move()[source]

Updates the position of both ends

paint(painter: PyQt5.QtGui.QPainter, option: PyQt5.QtWidgets.QStyleOptionGraphicsItem, widget: PyQt5.QtWidgets.QWidget)[source]

Paint

Parameters
painterQPainter
optionQStyleOptionGraphicsItem
widgetQWidget
shape() → PyQt5.QtGui.QPainterPath[source]

Shape

Returns
valueQPainterPath

Exceptions

class qtpynodeeditor.NodeConnectionFailure[source]
class qtpynodeeditor.ConnectionCycleFailure[source]

Connection would introduce a cycle in the graph

class qtpynodeeditor.ConnectionDataTypeFailure[source]

Ports do not have compatible data types

class qtpynodeeditor.ConnectionPointFailure[source]

Connection point is not on top of the node port

class qtpynodeeditor.ConnectionPortNotEmptyFailure[source]

Port should be empty

class qtpynodeeditor.ConnectionRequiresPortFailure[source]

A port is required

class qtpynodeeditor.ConnectionSelfFailure[source]

Cannot connect a node to itself

class qtpynodeeditor.MultipleInputConnectionError[source]
class qtpynodeeditor.PortsAlreadyConnectedError[source]
class qtpynodeeditor.PortsOfSameTypeError[source]

Ports

Port

class qtpynodeeditor.Port(node, *, port_type: qtpynodeeditor.enums.PortType, index: int)[source]
add_connection(connection: Connection)[source]

Add a Connection to the Port

property can_connect

Can this port be connected to?

property caption

Data model-specified caption for the port

property caption_visible

Show the data model-specified caption?

property connection_policy

The connection policy (one/many) for the port

property data

The NodeData associated with the Port, if an output port

property data_type

The NodeData type associated with the Port

property display_text

The text to show on the label caption

get_mapped_scene_position(transform)[source]

Node port scene position after a transform

Parameters
port_typePortType
port_indexint
Returns
valueQPointF
property model

The data model associated with the Port

remove_connection(connection: Connection)[source]

Remove a Connection from the Port

property scene_position

The position in the scene of the Port

Returns
valueQPointF

PortType

class qtpynodeeditor.PortType(value)[source]

An enumeration.

Other / Internal

ConnectionPainter

class qtpynodeeditor.ConnectionPainter[source]
static get_painter_stroke(geom: qtpynodeeditor.connection_geometry.ConnectionGeometry) → PyQt5.QtGui.QPainterPath[source]

Get painter stroke

Parameters
geomConnectionGeometry
Returns
valueQPainterPath
static paint(painter: PyQt5.QtGui.QPainter, connection: Connection, style: qtpynodeeditor.style.ConnectionStyle)[source]

Paint

Parameters
painterQPainter
connectionConnection
styleConnectionStyle

ConnectionPolicy

class qtpynodeeditor.ConnectionPolicy(value)[source]

An enumeration.

NodeConnectionInteraction

class qtpynodeeditor.NodeConnectionInteraction(node: Node, connection: Connection, scene: FlowScene)[source]
can_connect() → Tuple[Port, Optional[qtpynodeeditor.type_converter.TypeConverter]][source]
Can connect when following conditions are met:
  1. Connection ‘requires’ a port - i.e., is missing either a start node or an end node

  2. Connection’s vacant end is above the node port in the user interface

  3. Node port is vacant

  4. Connection does not introduce a cycle in the graph

  5. Connection type equals node port type, or there is a registered type conversion that can translate between the two

Returns
portPort

The port to be connected.

converterTypeConverter

The data type converter to use.

Raises
NodeConnectionFailure
ConnectionDataTypeFailure

If port data types are not compatible

connection_end_scene_position(port_type: qtpynodeeditor.enums.PortType) → PyQt5.QtCore.QPointF[source]

Connection end scene position

Parameters
port_typePortType
Returns
valueQPointF
property connection_node

The node already specified for the connection

property connection_required_port

The required port type to complete the connection

Returns
valuePortType
property creates_cycle

Would completing the connection introduce a cycle?

disconnect(port_to_disconnect: qtpynodeeditor.enums.PortType)[source]
  1. Node and Connection should be already connected

  2. If so, clear Connection entry in the NodeState

  3. Propagate invalid data to IN node

  4. Set Connection end to ‘requiring a port’

Parameters
port_to_disconnectPortType
node_port_is_empty(port_type: qtpynodeeditor.enums.PortType, port_index: int) → bool[source]

Node port is empty

Parameters
port_typePortType
port_indexint
Returns
valuebool
node_port_scene_position(port_type: qtpynodeeditor.enums.PortType, port_index: int) → PyQt5.QtCore.QPointF[source]

Node port scene position

Parameters
port_typePortType
port_indexint
Returns
valueQPointF
node_port_under_scene_point(port_type: qtpynodeeditor.enums.PortType, scene_point: PyQt5.QtCore.QPointF) → Optional[Port][source]

Node port under scene point

Parameters
port_typePortType
pQPointF
Returns
portPort
try_connect() → bool[source]

Try to connect the nodes. Steps:

1) Check conditions from 'can_connect'
1.5) If the connection is possible but a type conversion is needed, add
     a converter node to the scene, and connect it properly
2) Assign node to required port in Connection
3) Assign Connection to empty port in NodeState
4) Adjust Connection geometry
5) Poke model to initiate data transfer
Returns
valuebool

NodePainter

class qtpynodeeditor.NodePainter[source]
static draw_connection_points(painter: PyQt5.QtGui.QPainter, geom: qtpynodeeditor.node_geometry.NodeGeometry, state: qtpynodeeditor.node_state.NodeState, model: qtpynodeeditor.node_data.NodeDataModel, scene: FlowScene, node_style: qtpynodeeditor.style.NodeStyle, connection_style: qtpynodeeditor.style.ConnectionStyle)[source]

Draw connection points

Parameters
painterQPainter
geomNodeGeometry
stateNodeState
modelNodeDataModel
sceneFlowScene
connection_styleConnectionStyle
static draw_entry_labels(painter: PyQt5.QtGui.QPainter, geom: qtpynodeeditor.node_geometry.NodeGeometry, state: qtpynodeeditor.node_state.NodeState, model: qtpynodeeditor.node_data.NodeDataModel, node_style: qtpynodeeditor.style.NodeStyle)[source]

Draw entry labels

Parameters
painterQPainter
geomNodeGeometry
stateNodeState
modelNodeDataModel
node_styleNodeStyle
static draw_filled_connection_points(painter: PyQt5.QtGui.QPainter, geom: qtpynodeeditor.node_geometry.NodeGeometry, state: qtpynodeeditor.node_state.NodeState, model: qtpynodeeditor.node_data.NodeDataModel, node_style: qtpynodeeditor.style.NodeStyle, connection_style: qtpynodeeditor.style.ConnectionStyle)[source]

Draw filled connection points

Parameters
painterQPainter
geomNodeGeometry
stateNodeState
modelNodeDataModel
node_styleNodeStyle
connection_styleConnectionStyle
static draw_model_name(painter: PyQt5.QtGui.QPainter, geom: qtpynodeeditor.node_geometry.NodeGeometry, state: qtpynodeeditor.node_state.NodeState, model: qtpynodeeditor.node_data.NodeDataModel, node_style: qtpynodeeditor.style.NodeStyle)[source]

Draw model name

Parameters
painterQPainter
geomNodeGeometry
stateNodeState
modelNodeDataModel
static draw_node_rect(painter: PyQt5.QtGui.QPainter, geom: qtpynodeeditor.node_geometry.NodeGeometry, model: qtpynodeeditor.node_data.NodeDataModel, graphics_object: qtpynodeeditor.node_graphics_object.NodeGraphicsObject, node_style: qtpynodeeditor.style.NodeStyle)[source]

Draw node rect

Parameters
painterQPainter
geomNodeGeometry
modelNodeDataModel
graphics_objectNodeGraphicsObject
node_styleNodeStyle
static draw_resize_rect(painter: PyQt5.QtGui.QPainter, geom: qtpynodeeditor.node_geometry.NodeGeometry, model: qtpynodeeditor.node_data.NodeDataModel)[source]

Draw resize rect

Parameters
painterQPainter
geomNodeGeometry
modelNodeDataModel
static draw_validation_rect(painter: PyQt5.QtGui.QPainter, geom: qtpynodeeditor.node_geometry.NodeGeometry, model: qtpynodeeditor.node_data.NodeDataModel, graphics_object: qtpynodeeditor.node_graphics_object.NodeGraphicsObject, node_style: qtpynodeeditor.style.NodeStyle)[source]

Draw validation rect

Parameters
painterQPainter
geomNodeGeometry
modelNodeDataModel
graphics_objectNodeGraphicsObject
node_styleNodeStyle
static paint(painter: PyQt5.QtGui.QPainter, node: Node, scene: FlowScene, node_style: qtpynodeeditor.style.NodeStyle, connection_style: qtpynodeeditor.style.ConnectionStyle)[source]

Paint

Parameters
painterQPainter
nodeNode
sceneFlowScene
node_styleNodeStyle
connection_styleConnectionStyle

NodePainterDelegate

class qtpynodeeditor.NodePainterDelegate[source]
paint(painter: PyQt5.QtGui.QPainter, geom: qtpynodeeditor.node_geometry.NodeGeometry, model: qtpynodeeditor.node_data.NodeDataModel)[source]

Paint

Parameters
painterQPainter
geomNodeGeometry
modelNodeDataModel

NodeValidationState

class qtpynodeeditor.NodeValidationState(value)[source]

An enumeration.