Skip to content

Events and public types

On this page

Custom Event

st_graph_workbench.component.events.Event

Event(name: str, event_type: str, selector: str)

Define a custom Cytoscape event listener returned to Python.

Create a listener definition.

Parameters:

  • name (str) –

    Application-specific action name included in the returned event.

  • event_type (str) –

    Space-separated Cytoscape event names, for example "click tap".

  • selector (str) –

    Cytoscape selector that scopes the listener, for example "node".

Examples:

>>> event = Event("clicked_node", "click tap", "node")
>>> event.dump()["name"]
'clicked_node'
Source code in st_graph_workbench/component/events.py
def __init__(
    self,
    name: str,
    event_type: str,
    selector: str,
) -> None:
    """Create a listener definition.

    Parameters
    ----------
    name
        Application-specific action name included in the returned event.
    event_type
        Space-separated Cytoscape event names, for example ``"click tap"``.
    selector
        Cytoscape selector that scopes the listener, for example ``"node"``.

    Examples
    --------
    >>> event = Event("clicked_node", "click tap", "node")
    >>> event.dump()["name"]
    'clicked_node'
    """
    self.name = _required_text(name, "name")
    self.event_type = _required_text(event_type, "event_type")
    self.selector = _required_text(selector, "selector")
    if self.name in RESERVED_NAMES:
        raise ValueError(
            f"`{self.name}` is reserved by st-graph-workbench. "
            "Choose an application-specific event name."
        )

dump

dump() -> dict[str, str]

Return the listener as a JSON-ready component dictionary.

Source code in st_graph_workbench/component/events.py
def dump(self) -> dict[str, str]:
    """Return the listener as a JSON-ready component dictionary."""
    return {
        "name": self.name,
        "event_type": self.event_type,
        "selector": self.selector,
    }

GraphEvent

st_graph_workbench.component.types.GraphEvent module-attribute

GraphEvent: TypeAlias = dict[str, Any]

An event dictionary returned from the browser component.

ProgressiveLoadConfig

st_graph_workbench.component.types.ProgressiveLoadConfig

Bases: TypedDict

Configuration for requesting incremental graph batches.

page_size is the requested number of domain records in the next batch. loaded_count and total_count drive the progress shown in the graph. cursor is an opaque JSON scalar returned unchanged in the next load_more event. Set has_more to false when no further batch exists. acknowledged_request_id echoes the completed event's request_id, including after a handled fetch failure, to enable another request without changing the cursor or counts. Omit it for legacy progress-driven completion.

ConnectedDragConfig

st_graph_workbench.component.types.ConnectedDragConfig

Bases: TypedDict

Configuration for rigidly dragging visible connected nodes.

enabled and depth are initial browser preferences. max_depth bounds the toolbar choices to one, two, or three visible hops, while max_nodes limits automatic followers for one gesture. Explicitly selected and compound-descendant nodes retain Cytoscape's native behavior.

ToolbarConfig

st_graph_workbench.component.types.ToolbarConfig

Bases: TypedDict

Configuration for the responsive controls above the graph.

mode chooses adaptive, expanded, compact, or initially minimized presentation. position currently supports the top of the graph. collapsible lets the reader minimize and restore the controls, while sticky reserves their measured height so they never cover the canvas.

Action type aliases

st_graph_workbench.component.component.AnalysisAction module-attribute

AnalysisAction = Literal['shortest_path', 'bfs', 'dfs', 'connected_components', 'degree']

Browser-side graph algorithms exposed by the analysis toolbox.

st_graph_workbench.component.component.CrudAction module-attribute

CrudAction = Literal['create_node', 'create_edge', 'read_selected', 'update_selected', 'delete_selected', 'request_node_data']

CRUD intents that the browser can return for Python handling.

st_graph_workbench.component.component.EditAction module-attribute

EditAction = Literal['add_node', 'connect_selected', 'delete_selected', 'lock_selected', 'unlock_selected', 'make_ungrabbable', 'make_grabbable', 'snap_to_grid', 'undo', 'redo']

Immediate browser-local graph editing actions.

st_graph_workbench.component.component.ElementsSync module-attribute

ElementsSync = Literal['always', 'initial']

Full reconciliation or command-driven element synchronization.

st_graph_workbench.component.component.NodeAction module-attribute

NodeAction = Literal['remove', 'expand', 'show_neighbors', 'show_incoming', 'show_outgoing', 'hide_unselected', 'restore_hidden']

Node context/toolbox actions supported by graph_workbench.

st_graph_workbench.component.component.PerformanceProfile module-attribute

PerformanceProfile = Literal['default', 'large', 'dense']

Rendering profiles that tune graph behavior for different scales.

st_graph_workbench.component.component.SelectionMode module-attribute

SelectionMode = Literal['single', 'multiple', 'box']

Supported Cytoscape selection interaction modes.

st_graph_workbench.component.component.ViewportAction module-attribute

ViewportAction = Literal['toggle_zoom', 'toggle_pan', 'save_viewport', 'restore_viewport', 'reset_viewport']

Interactive viewport actions exposed by the graph toolbox.