render_pygwalker
render_pygwalker class
Reactively render a PyGWalker data exploration app.
Usage Source
render_pygwalker(
_fn: Optional[ValueFn[ValueT]] = None,
*,
width: Optional[str] = None,
height: Optional[str] = None,
fill: Optional[bool] = None,
fillable: Optional[bool] = None,
rate_policy: Optional[RatePolicy] = None,
rate_delay: Optional[float] = None,
listen_to: Optional[Sequence[str]] = None,
)@render_pygwalker is a decorator that creates a render function – a function that returns the data to explore and re-runs when the reactive values it reads change:
import pandas as pd
import pygwalker
from shinywidgets import render_pygwalker
# Optional: stop PyGWalker's update checks (server and browser)
pygwalker.GlobalVarManager.set_privacy("offline")
df = pd.DataFrame({"a": [1, 2, 3], "b": ["x", "y", "z"]})
@render_pygwalker
def walker():
return dfThe render function may return either a pandas DataFrame (which is coerced to a PyGWalker widget; requires pip install 'shinywidgets[pygwalker]') or a widget created by pygwalker.api.anywidget.walk() (use this to pass options like theme_key). A polars DataFrame is coerced too, but only when the installed pygwalker can read it (pygwalker releases prior to 0.6 can’t read polars >= 1.0); unsupported combinations are rejected with a hint to convert it (df.to_pandas()). Don’t use the top-level pygwalker.walk(): outside of Jupyter, it starts a blocking web server instead of returning a widget.
Note
Accessing the rendered widget: the render function gains two read-only attributes: .value, the value it most recently returned, and .widget, the rendered PyGWalker widget.
Responding to user interaction: the widget has no traits that track the explorer’s state, so there’s nothing to reactive_read().
Mutating the widget: changing the explorer means re-rendering it. Each render sends PyGWalker’s large JavaScript bundle to the browser, so avoid unnecessary re-renders.
Outside of filling layouts, give it a height (e.g., "800px") that fits PyGWalker’s UI.
Security: PyGWalker computes charts by running SQL that the browser sends, sandboxed so visitors can only query the widget’s own data. Nothing limits how expensive a query is, though, and a slow one blocks every session while it runs, so PyGWalker is best suited to trusted users.
Parameters
width : Optional[str] = None-
A CSS length unit (e.g.,
"400px"or"100%") for the output’s width. height : Optional[str] = None-
A CSS length unit for the output’s height. When
None(the default), the output is designed to fill the height of its parent container (seefillandfillable). fill : Optional[bool] = None-
Whether the output should grow or shrink to fit its parent container. When
None(the default), this isTrueifheightis not specified. fillable : Optional[bool] = None-
Whether the output container should fill available space (scrolling its contents on overflow). When
None(the default), this isTrueifheightis not specified.
See also
output_widget(): in Shiny Core, the UI needs this to hold the output (Shiny Express displays it where the render function is defined).