The powerful data exploration & web app framework for Python.
—
Essential functions for configuration, serving, binding, and converting objects to Panel components. These functions form the foundation of Panel applications and provide the basic functionality needed to get started.
Automatically converts Python objects to appropriate Panel components.
def panel(obj, **params):
"""
Convert Python objects to Panel components automatically.
Parameters:
- obj: Any Python object to convert
- **params: Additional parameters to pass to the component
Returns:
Appropriate Panel component (Pane, Widget, or Layout)
"""Serves Panel applications on a web server with various configuration options.
def serve(panels, port=5006, show=False, **kwargs):
"""
Serve Panel applications on web server.
Parameters:
- panels: Panel object or dict of Panel objects to serve
- port: Port number for server (default: 5006)
- show: Whether to open browser automatically (default: False)
- allow_websocket_origin: List of allowed websocket origins
- autoreload: Enable automatic reloading on file changes
- **kwargs: Additional server configuration options
Returns:
Server object
"""Configures Panel extensions and global settings.
def extension(*args, **kwargs):
"""
Configure Panel extensions and settings.
Parameters:
- *args: Extension names to load ('bokeh', 'plotly', 'tabulator', etc.)
- template: Default template to use
- theme: Theme name ('default', 'dark')
- sizing_mode: Default sizing mode
- **kwargs: Additional configuration options
"""Functions for creating reactive dependencies and binding parameters.
def bind(function, *args, **kwargs):
"""
Bind function parameters for reactive programming.
Parameters:
- function: Function to bind
- *args: Positional arguments (can include Panel parameters)
- **kwargs: Keyword arguments (can include Panel parameters)
Returns:
Bound function that updates when parameters change
"""
def depends(*parameters):
"""
Declare parameter dependencies for functions.
Parameters:
- *parameters: Parameter objects or strings naming parameters
Returns:
Decorator function for dependency declaration
"""Utilities for creating interactive UIs and caching function results.
def interact(function, **kwargs):
"""
Create interactive UI from function parameters.
Parameters:
- function: Function to create UI for
- **kwargs: Parameter specifications for widgets
Returns:
Interactive Panel component
"""
def cache(func=None, **kwargs):
"""
Cache function results for performance.
Parameters:
- func: Function to cache (when used as decorator)
- **kwargs: Caching configuration options
Returns:
Cached function or decorator
"""Convert Panel objects to other widget formats.
def ipywidget(obj, **kwargs):
"""
Convert Panel objects to IPython widgets.
Parameters:
- obj: Panel object to convert
- **kwargs: Additional conversion parameters
Returns:
IPython widget equivalent
"""class Config:
"""Global Panel configuration object with settings for themes, templates, and behavior"""
# Theme settings
theme: str
"""Current theme ('default', 'dark')"""
# Template settings
template: str
"""Default template name"""
# Sizing settings
sizing_mode: str
"""Default sizing mode ('fixed', 'stretch_width', 'stretch_height', 'stretch_both', 'scale_width', 'scale_height', 'scale_both')"""
class State:
"""Global application state manager for server-side state and caching"""
def add_periodic_callback(self, callback, period):
"""Add periodic callback to application"""
def remove_periodic_callback(self, callback):
"""Remove periodic callback from application"""
@property
def cache(self):
"""Access to application cache"""