Fiaz Technologies
Usage

Add Node

Learn how to add nodes in PyWebflow and understand all available parameters.

Adding a Node

The add_node method in PyWebflow allows you to create and add a new node to your graph.

Usage

First, import the WebFlow library:

import webflow as wf

Then, use the add_node method as follows:

wf.add_node(node_id, label, position, **kwargs)

Parameters

ParameterTypeDescription
node_idstrA unique identifier for the node.
labelstrA human-readable name for the node.
positionDict[str, float]Defines the x and y coordinates of the node.
dragHandleOptional[bool]If True, the node can be dragged using a handle.
typeOptional[str]Defines the type of node (e.g., "default", "custom").
selectedOptional[bool]If True, the node starts as selected.
isConnectableOptional[bool]If True, the node can be connected to edges.
zIndexOptional[int]The z-index of the node, affecting stacking order.
positionAbsoluteXOptional[float]Absolute X position of the node in the graph.
positionAbsoluteYOptional[float]Absolute Y position of the node in the graph.
draggingOptional[bool]If True, the node is currently being dragged.
targetPositionOptional[str]Defines where edges should connect to the node ("top", "bottom", "left", "right").
sourcePositionOptional[str]Defines where edges originate from the node ("top", "bottom", "left", "right").

Example

wf.add_node(
    node_id="node1",
    label="Start Node",
    position={"x": 50, "y": 50},
    type="custom",
    selected=True,
    isConnectable=True,
    sourcePosition="bottom",
    targetPosition="top"
)

Additional Notes

  • positionAbsoluteX and positionAbsoluteY are calculated automatically unless manually set.
  • dragging=True should only be used for real-time drag interactions.
  • Use type="custom" for nodes that require special rendering.
Edit on GitHub

Last updated on

On this page