phenotypic.tools_.panel_ module#
Shared Panel toolkit for interactive dashboards.
Centralises Panel availability checks, Jupyter environment detection,
and pn.extension() initialization so that every module using Panel
imports from one place instead of reimplementing these patterns.
- phenotypic.tools_.panel_.display_or_return(layout, *, show: bool = True)[source]#
Display a Panel layout in Jupyter or return it for programmatic use.
When show is
Trueand the session is a Jupyter notebook the layout is passed toIPython.display.display(after ensuring the Panel extension is loaded). Otherwise the layout is returned as-is.- Parameters:
layout – A Panel layout object (e.g.
pn.Column).show (bool) – If
True, attempt to display interactively.
- Returns:
The layout object (always returned, even after display).
- phenotypic.tools_.panel_.ensure_panel_extension(*extensions: str, **kwargs) None[source]#
Initialise
pn.extension()once, only when inside IPython.Safe to call multiple times — the extension is loaded at most once per process. Outside IPython the call is a silent no-op. When
plotlyis importable it is automatically included as an extension so Plotly figures render correctly in Panel layouts. Thecommskwarg is auto-detected via_detect_comms()unless the caller supplies one explicitly.- Parameters:
*extensions (str) – Extra Panel extensions to load (e.g.
"tabulator")."plotly"is added automatically when Plotly is installed.**kwargs – Forwarded to
pn.extension()on the first call (e.g.inline=True). An explicitcommsvalue wins over the auto-detected default.
- Return type:
None
- phenotypic.tools_.panel_.in_ipython() bool[source]#
Detect whether code is running inside any IPython session.
- Returns:
Truewhen an IPython kernel or terminal is active.- Return type:
- phenotypic.tools_.panel_.in_jupyter() bool[source]#
Detect whether code is running inside a Jupyter notebook.
This is stricter than
in_ipython()— it returnsTrueonly for notebook kernels (ZMQInteractiveShell), not plain IPython terminals.- Returns:
Truewhen running in a Jupyter notebook kernel.- Return type:
- phenotypic.tools_.panel_.require_panel() None[source]#
Raise
ImportErrorwith an actionable message if Panel is missing.- Raises:
ImportError – If
panelis not installed.- Return type:
None