trame.widgets.flow module

class trame.widgets.flow.Background(**kwargs)

Bases: AbstractElement

Background for NodeEditor.

class trame.widgets.flow.Controls(**kwargs)

Bases: AbstractElement

Controls for NodeEditor.

class trame.widgets.flow.ControlsButton(**kwargs)

Bases: AbstractElement

ControlsButton for Controls.

class trame.widgets.flow.CustomNode(type: str, var_name: str = 'props', **kwargs)

Bases: Template

class trame.widgets.flow.Handle(position: Literal['top', 'bottom', 'left', 'right'], type: Literal['source', 'target'], **kwargs)

Bases: AbstractElement

class trame.widgets.flow.MiniMap(**kwargs)

Bases: AbstractElement

MiniMap for NodeEditor.

class trame.widgets.flow.MiniMapNode(id: str, position: Position, dimensions: Dimensions, **kwargs)

Bases: AbstractElement

MiniMapNode for MiniMap.

class trame.widgets.flow.NodeEditor(**kwargs)

Bases: AbstractElement

Node Editor based on VueFlow.

add_node(node: Node)

Add a Node to the graph.

add_edge(edge: Edge)

Add an Edge to the graph.

get_node(id: str)

Get a Node from its id. Returns None if not found.

get_edge(source: str, target: str, source_handle: str | None = None, target_handle: str | None = None)

Get an Edge from its source and target. Returns None if not found.

remove_node(node_id: str)

Remove a Node from the graph. Does nothing if no node has id=`node_id`

remove_edge(source: str, target: str, source_handle: str | None = None, target_handle: str | None = None)

Remove an Edge from the graph. Does nothing if there is no edge from source to target.

serialize_graph() str

Returns graph as a string representing a Graph object.

deserialize_graph(graph_str: str) bool

Deserialize graph from a string representing a Graph object.

Returns False if deserialization produced any error, else True.

update_node(node_id: str, **kwargs)

Update a node’s property.

update_edge(source: str, target: str, **kwargs)

Update an edge’s property.

fit_view()

Fit VueFlow’s view to show the entire graph (excluding hidden nodes)

clear_graph()

Remove every edges and then every nodes.

class trame.widgets.flow.NodeResizer(**kwargs)

Bases: AbstractElement

NodeResizer for CustomNode.

class trame.widgets.flow.NodeToolbar(**kwargs)

Bases: AbstractElement

NodeToolbar for NodeEditor.