Drop files onto the graph

file drop prompt node

Source: examples/panels/visnetwork/drop_file.py Test: tests/panels/visnetwork/examples/test_drop_file.py

The graph starts with a single prompt node inviting you to drop a file onto the canvas. Dragging an image or CSV file onto the widget spawns a new node from the dropped content, so the canvas doubles as a drop target.

The drop interaction is exercised by dragging a file onto the graph; the widget reads the file and adds a corresponding node without any extra wiring.

The code

import panel as pn

from panelini.panels.visnetwork import VisNetwork

nodes = [
    {
        "id": 1,
        "label": "Drop an Image File into the graph-widget",
        "shape": "ellipse",
        "color": "green",
    },
]

edges = []

visnetwork_panel = VisNetwork(nodes=nodes, edges=edges)
pn.serve(visnetwork_panel, threaded=True)

Run it live

This example runs entirely in your browser via Pyodide. The first load downloads packages, so give it a few seconds.

Open fullscreen

See also