Skip to content

API reference

The pages in this section are generated from the docstrings in the source, so they always match the code that is installed.

Package

The package re-exports the pieces most applications need:

nodeeditor

NodeEditorColorScheme

Global color scheme configuration for Node Editor

This class provides a centralized way to manage and update all colors used in the node editor, including edge colors and socket colors.

Example: >>> scheme = NodeEditorColorScheme() >>> scheme.edges.default = "#FF0000" # Red edges >>> scheme.sockets.highlight = "#00FF00" # Green highlights

get_instance classmethod

get_instance()

Get the singleton instance of the color scheme

:return: NodeEditorColorScheme instance

reset_to_defaults

reset_to_defaults()

Reset all colors to their default values

to_dict

to_dict()

Export current color scheme to dictionary

:return: Dictionary representation of the color scheme

from_dict

from_dict(config)

Import color scheme from dictionary

:param config: Dictionary with color configuration

EdgeColors

Bases: BaseColors

Configuration for Edge colors

default property writable

default

Get default edge color

selected property writable

selected

Get selected edge color

hovered property writable

hovered

Get hovered edge color

dragging property writable

dragging

Get dragging edge color

set_all

set_all(
    default=None, selected=None, hovered=None, dragging=None
)

Set all edge colors at once

:param default: Default edge color :param selected: Selected edge color :param hovered: Hovered edge color :param dragging: Dragging edge color

SocketColors

Bases: BaseColors

Configuration for Socket colors

outline property writable

outline

Get socket outline color

highlight property writable

highlight

Get socket highlight color

get_type_color

get_type_color(socket_type)

Get color for a specific socket type

:param socket_type: Socket type index :return: QColor for the socket type

set_type_color

set_type_color(socket_type, color)

Set color for a specific socket type

:param socket_type: Socket type index :param color: Color to set

set_type_colors

set_type_colors(colors)

Set all socket type colors at once

:param colors: List of colors

get_all_type_colors

get_all_type_colors()

Get all socket type colors

:return: List of QColor objects

set_all

set_all(outline=None, highlight=None, type_colors=None)

Set all socket colors at once

:param outline: Socket outline color :param highlight: Socket highlight color :param type_colors: List of socket type colors

SocketShape

Base class for socket shapes.

Subclasses describe their outline as a list of points normalized against the socket radius, and get the hit-test path and the painting for free.

points

points()

The outline as normalized points, in units of the socket radius.

:return: list of (x, y) pairs

path

path(radius, direction=DIRECTION_OUTPUT)

The outline as a path, centered on the item origin.

:param radius: the socket's radius in scene units :param direction: +1 for output sockets, -1 for input sockets :return: the outline path

draw

draw(painter, ctx)

Paint the shape.

:param painter: the QPainter to draw into :param ctx: the :class:SocketShapeContext for this paint

SocketShapeContext

Everything a shape needs while it paints itself.

CircleShape

Bases: SocketShape

The classic socket: a filled circle.

path

path(radius, direction=DIRECTION_OUTPUT)

The circle as a path, centered on the item origin.

:param radius: the socket's radius in scene units :param direction: ignored, a circle looks the same on both sides :return: the outline path

SquareShape

Bases: SocketShape

A square socket.

The half side is 0.85 * radius, which reads as the same weight as the circle next to it.

points

points()

The square's four corners, in units of the socket radius.

:return: list of (x, y) pairs

TriangleShape

Bases: SocketShape

A triangular socket.

The tip points away from the node: right on an output socket, left on an input socket.

points

points()

The triangle's three corners, in units of the socket radius.

The tip points right, so the outline mirrors on input sockets.

:return: list of (x, y) pairs

ChevronShape

Bases: SocketShape

A chevron socket: the concave hexagon, pointing right.

The shape never mirrors, on either side of a node. A chevron on an input socket aims its tip into the node, so the two sides of a graph read as one left-to-right flow: in, processed, out.

points

points()

The chevron's six corners, in units of the socket radius.

:return: list of (x, y) pairs

GraphCycleError

Bases: Exception

Raised when a graph that has to be acyclic contains a cycle.

:Instance Attributes:

- **cycles** - the cycles found, each a list of
  :class:`~nodeeditor.node_edge.Edge` in traversal order

get_color_scheme

get_color_scheme()

Get the global color scheme instance

:return: NodeEditorColorScheme instance

register_socket_shape

register_socket_shape(name, shape)

Register a socket shape under name.

shape may be a :class:SocketShape instance, a :class:SocketShape subclass, or a plain callable fn(painter, ctx). Registering an existing name replaces the old shape.

:param name: the name nodes use to select this shape :param shape: the shape, its class, or a drawing callback :return: the registered shape

get_socket_shape

get_socket_shape(name)

The shape registered under name.

Unknown names fall back to the circle rather than raising, so a typo in a node's shape map cannot break a graph.

:param name: the registered shape name :return: the shape to draw with

Modules

Area Modules
Scene node_scene, node_scene_clipboard, node_scene_history
Node node_node, node_multi_input_node
Groups node_group
Edge node_edge and the edge interaction helpers
Socket node_socket
Socket shapes node_socket_shapes
Color scheme node_colors_config
Editor widget node_editor_widget
Editor window node_editor_window
Graph algorithms node_graph
Graphics items the node_graphics_* modules
Content widgets node_content_widget, node_icon_*, node_decorators
Serialization node_serializable
Utilities utils, utils_no_qt