Python stdlib import graph
Networks
Click a module in an ipysigma graph (built by statically parsing the interpreter’s own standard library with ast) and it recolors to show what it imports and what imports it.
A directed graph of ~80 curated Python standard-library modules, built entirely by statically parsing each module’s own source with ast.walk() – no downloads, no network, just the interpreter running the app. Clicking a node (or typing into the sidebar) recolors the graph: red/halo for the focused module, orange for what it imports, blue for what imports it. Node size is in-degree (how many other modules depend on it). The camera is carried across every re-render, so clicking around doesn’t reset your pan/zoom.


Run it
git clone --depth 1 https://github.com/posit-dev/py-shinywidgets
cd py-shinywidgets/website/gallery/showcases/stdlib-import-graph
uv run shiny run app.pySource: app.py · Open in Shinylive
Try this
- Click a node: the sidebar updates to match, and the graph recolors around it.
- Type a module name into the sidebar’s Module selectize (or use ipysigma’s own built-in search box): same effect, the other direction.
- Pan and zoom freely – it survives every click, since each click just re-renders with a different
raw_node_colormap and the samecamera_statefed back in from Python.
Accessors demonstrated
graph.read("selected_node")– ipysigma’s own trait for “what node is currently selected,” read here (sincerender_ipysigmahas no dedicated click accessor) to drive the sidebar’s selectize two-way..read()is the taught fallback for a renderer output’s bare synced traits, replacingreactive_read(graph.widget, ...).graph.read("camera_state")– read on every render and fed back into the nextSigma(..., camera_state=cam)construction, which is what makes re-renders preserve pan/zoom instead of resetting the view.