__init__ Module#
__init__
Module#
Panel is a high level app and dashboarding framework#
Panel is an open-source Python library that lets you create custom interactive web apps and dashboards by connecting user-defined widgets to plots, images, tables, or text.
Panel works with the tools you know and ❤️.
Check out https://panel.holoviz.org/
How to develop a Panel app in 3 simple steps#
Write the app
>>> import panel as pn
>>> pn.extension(sizing_mode="stretch_width", template="fast")
>>> pn.state.template.param.update(title="My Data App")
>>> pn.panel(some_python_object).servable()
Run your app
$ panel serve my_script.py –autoreload –show
or
$ panel serve my_notebook.ipynb –autoreload –show
The app will be available in your browser!
Change your code and save it
The app will reload with your changes!
You can also add automatic reload to jupyterlab. Check out https://blog.holoviz.org/panel_0.12.0.html#JupyterLab-previews
To learn more about Panel check out https://panel.holoviz.org/getting_started/index.html
- class panel.__init__.Accordion(*objects, **params)[source]#
Bases:
NamedListPanel
The Accordion layout is a type of Card layout that allows switching between multiple objects by clicking on the corresponding card header.
The labels for each card will default to the name parameter of the card’s contents, but may also be defined explicitly as part of a tuple.
Like Column and Row, Accordion has a list-like API that allows interactively updating and modifying the cards using the methods append, extend, clear, insert, pop, remove and __setitem__.
Reference: https://panel.holoviz.org/reference/layouts/Accordion.html
- Example:
>>> pn.Accordion(some_pane_with_a_name, ("Plot", some_plot))
Parameters inherited from:
panel.viewable.Layoutable
: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, margin, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.layout.base.NamedListLike
: objectspanel.layout.base.NamedListPanel
: scrollactive
= param.List(allow_refs=False, bounds=(0, None), default=[], label=’Active’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131ebb310>)List of indexes of active cards.
active_header_background
= param.String(allow_refs=False, default=’#ddd’, label=’Active header background’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131eba790>)Color for currently active headers.
header_color
= param.String(allow_refs=False, default=’’, label=’Header color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131ebb990>)A valid CSS color to apply to the expand button.
header_background
= param.String(allow_refs=False, default=’’, label=’Header background’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131eb9e50>)A valid CSS color for the header background.
toggle
= param.Boolean(allow_refs=False, default=False, label=’Toggle’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131ebba90>)Whether to toggle between active cards or allow multiple cards
- clone(*objects: Any, **params: Any) NamedListLike [source]#
Makes a copy of the Tabs sharing the same parameters.
- Parameters:
objects (Objects to add to the cloned Tabs object.) –
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned Tabs object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel [source]#
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None [source]#
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- Parameters:
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for JSON filename
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=False)) – Whether to report progress
states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
- extend(panes: Iterable[Any]) None [source]#
Extends the the tabs with a list.
- Parameters:
(list) (objects) –
- get_root(doc: Optional[Document] = None, comm: Optional[Comm] = None, preprocess: bool = True) Model [source]#
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.Document) – Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (boolean (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- insert(index: int, pane: Any) None [source]#
Inserts an object in the tabs at the specified index.
- Parameters:
(int) (index) –
(object) (object) –
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback [source]#
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link [source]#
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: Parameterized, callbacks: Optional[Dict[str, Union[str, Callable]]] = None, bidirectional: bool = False, **links: str) Watcher [source]#
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources: bokeh.resources.Resources | None = None, template: str | jinja2.environment.Template | None = None, template_variables: Dict[str, Any] = {}, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None [source]#
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector: type | Callable[[Viewable], bool] | None = None) List[Viewable] [source]#
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin [source]#
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document [source]#
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server [source]#
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- class panel.__init__.Card(*objects, **params)[source]#
Bases:
Column
A Card layout allows arranging multiple panel objects in a collapsible, vertical container with a header bar.
Reference: https://panel.holoviz.org/reference/layouts/Card.html
- Example:
>>> pn.Card( ... some_widget, some_pane, some_python_object, ... title='Card', styles=dict(background='WhiteSmoke'), ... )
Parameters inherited from:
panel.viewable.Layoutable
: align, aspect_ratio, design, height, min_width, min_height, max_width, max_height, margin, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.layout.base.ListLike
: objectspanel.layout.base.ListPanel
: scrollpanel.layout.base.Column
: auto_scroll_limit, scroll_button_threshold, scroll_position, view_latestcss_classes
= param.List(allow_refs=False, bounds=(0, None), default=[‘card’], label=’Css classes’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x131b63d10>)CSS classes to apply to the overall Card.
active_header_background
= param.String(allow_refs=False, default=’’, label=’Active header background’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131de8850>)A valid CSS color for the header background when not collapsed.
button_css_classes
= param.List(allow_refs=False, bounds=(0, None), default=[‘card-button’], label=’Button css classes’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131b63710>)CSS classes to apply to the button element.
collapsible
= param.Boolean(allow_refs=False, default=True, label=’Collapsible’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131de68d0>)Whether the Card should be expandable and collapsible.
collapsed
= param.Boolean(allow_refs=False, default=False, label=’Collapsed’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131b609d0>)Whether the contents of the Card are collapsed.
header
= param.Parameter(allow_None=True, allow_refs=False, label=’Header’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131dea010>)A Panel component to display in the header bar of the Card. Will override the given title if defined.
header_background
= param.String(allow_refs=False, default=’’, label=’Header background’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131b609d0>)A valid CSS color for the header background.
header_color
= param.String(allow_refs=False, default=’’, label=’Header color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131de9050>)A valid CSS color to apply to the header text.
header_css_classes
= param.List(allow_refs=False, bounds=(0, None), default=[‘card-header’], label=’Header css classes’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131b63d10>)CSS classes to apply to the header element.
hide_header
= param.Boolean(allow_refs=False, default=False, label=’Hide header’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131dea7d0>)Whether to skip rendering the header.
title_css_classes
= param.List(allow_refs=False, bounds=(0, None), default=[‘card-title’], label=’Title css classes’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131b63d10>)CSS classes to apply to the header title.
title
= param.String(allow_refs=False, default=’’, label=’Title’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131dea5d0>)A title to be displayed in the Card header, will be overridden by the header if defined.
- clear() List[Viewable] [source]#
Clears the objects on this layout.
- Returns:
objects (list[Viewable])
- Return type:
List of cleared objects.
- clone(*objects: Any, **params: Any) ListLike [source]#
Makes a copy of the layout sharing the same parameters.
- Parameters:
objects (Objects to add to the cloned layout.) –
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned layout object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel [source]#
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None [source]#
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- Parameters:
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for JSON filename
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=False)) – Whether to report progress
states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
- extend(objects: Iterable[Any]) None [source]#
Extends the objects on this layout with a list.
- Parameters:
(list) (objects) –
- get_root(doc: Optional[Document] = None, comm: Optional[Comm] = None, preprocess: bool = True) Model [source]#
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.Document) – Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (boolean (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- index(object) int [source]#
Returns the integer index of the supplied object in the list of objects.
- Parameters:
(object) (obj) –
- Returns:
index (int)
- Return type:
Integer index of the object in the layout.
- insert(index: int, obj: Any) None [source]#
Inserts an object in the layout at the specified index.
- Parameters:
(int) (index) –
(object) (object) –
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback [source]#
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link [source]#
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: Parameterized, callbacks: Optional[Dict[str, Union[str, Callable]]] = None, bidirectional: bool = False, **links: str) Watcher [source]#
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- pop(index: int) Viewable [source]#
Pops an item from the layout by index.
- Parameters:
(int) (index) –
- remove(obj: Viewable) None [source]#
Removes an object from the layout.
- Parameters:
(object) (obj) –
- save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources: bokeh.resources.Resources | None = None, template: str | jinja2.environment.Template | None = None, template_variables: Dict[str, Any] = {}, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None [source]#
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector: type | Callable[[Viewable], bool] | None = None) List[Viewable] [source]#
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin [source]#
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document [source]#
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server [source]#
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- class panel.__init__.Column(*objects: Any, **params: Any)[source]#
Bases:
ListPanel
The Column layout allows arranging multiple panel objects in a vertical container.
It has a list-like API with methods to append, extend, clear, insert, pop, remove and __setitem__, which makes it possible to interactively update and modify the layout.
Reference: https://panel.holoviz.org/reference/layouts/Column.html
- Example:
>>> pn.Column(some_widget, some_pane, some_python_object)
Parameters inherited from:
panel.viewable.Layoutable
: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, margin, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.layout.base.ListLike
: objectspanel.layout.base.ListPanel
: scrollauto_scroll_limit
= param.Integer(allow_refs=False, bounds=(0, None), default=0, inclusive_bounds=(True, True), label=’Auto scroll limit’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131b2b010>)Max pixel distance from the latest object in the Column to activate automatic scrolling upon update. Setting to 0 disables auto-scrolling.
scroll_button_threshold
= param.Integer(allow_refs=False, bounds=(0, None), default=0, inclusive_bounds=(True, True), label=’Scroll button threshold’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131b28590>)Min pixel distance from the latest object in the Column to display the scroll button. Setting to 0 disables the scroll button.
scroll_position
= param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Scroll position’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131b2b150>)Current scroll position of the Column. Setting this value will update the scroll position of the Column. Setting to 0 will scroll to the top.
view_latest
= param.Boolean(allow_refs=False, default=False, label=’View latest’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131b295d0>)Whether to scroll to the latest object on init. If not enabled the view will be on the first object.
- clear() List[Viewable] [source]#
Clears the objects on this layout.
- Returns:
objects (list[Viewable])
- Return type:
List of cleared objects.
- clone(*objects: Any, **params: Any) ListLike [source]#
Makes a copy of the layout sharing the same parameters.
- Parameters:
objects (Objects to add to the cloned layout.) –
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned layout object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel [source]#
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None [source]#
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- Parameters:
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for JSON filename
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=False)) – Whether to report progress
states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
- extend(objects: Iterable[Any]) None [source]#
Extends the objects on this layout with a list.
- Parameters:
(list) (objects) –
- get_root(doc: Optional[Document] = None, comm: Optional[Comm] = None, preprocess: bool = True) Model [source]#
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.Document) – Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (boolean (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- index(object) int [source]#
Returns the integer index of the supplied object in the list of objects.
- Parameters:
(object) (obj) –
- Returns:
index (int)
- Return type:
Integer index of the object in the layout.
- insert(index: int, obj: Any) None [source]#
Inserts an object in the layout at the specified index.
- Parameters:
(int) (index) –
(object) (object) –
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback [source]#
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link [source]#
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: Parameterized, callbacks: Optional[Dict[str, Union[str, Callable]]] = None, bidirectional: bool = False, **links: str) Watcher [source]#
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- pop(index: int) Viewable [source]#
Pops an item from the layout by index.
- Parameters:
(int) (index) –
- remove(obj: Viewable) None [source]#
Removes an object from the layout.
- Parameters:
(object) (obj) –
- save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources: bokeh.resources.Resources | None = None, template: str | jinja2.environment.Template | None = None, template_variables: Dict[str, Any] = {}, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None [source]#
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector=None)[source]#
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin [source]#
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document [source]#
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server [source]#
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- class panel.__init__.Feed(*objects, **params)[source]#
Bases:
Column
The Feed class inherits from the Column layout, thereby enabling the arrangement of multiple panel objects within a vertical container. However, it restrictively manages the number of objects displayed at any moment. This layout is particularly useful for efficiently rendering a substantial number of objects.
Similar to Column, the Feed provides a list-like API, including methods such as append, extend, clear, insert, pop, remove, and __setitem__. These methods facilitate interactive updates and modifications to the layout.
Reference: https://panel.holoviz.org/reference/layouts/Feed.html
- Example:
>>> pn.Feed(some_widget, some_pane, some_python_object, ..., python_object_1002)
Parameters inherited from:
panel.viewable.Layoutable
: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, margin, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.layout.base.ListLike
: objectspanel.layout.base.Column
: auto_scroll_limit, scroll_button_threshold, scroll_position, view_latestscroll
= param.Selector(allow_refs=False, default=’y’, label=’Scroll’, names={}, nested_refs=False, objects=[False, True, ‘both-auto’, ‘y-auto’, ‘x-auto’, ‘both’, ‘x’, ‘y’], rx=<param.reactive.reactive_ops object at 0x131b03610>)Whether to add scrollbars if the content overflows the size of the container. If “both-auto”, will only add scrollbars if the content overflows in either directions. If “x-auto” or “y-auto”, will only add scrollbars if the content overflows in the respective direction. If “both”, will always add scrollbars. If “x” or “y”, will always add scrollbars in the respective direction. If False, overflowing content will be clipped. If True, will only add scrollbars in the direction of the container, (e.g. Column: vertical, Row: horizontal).
load_buffer
= param.Integer(allow_refs=False, bounds=(0, None), default=50, inclusive_bounds=(True, True), label=’Load buffer’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131b12390>)The number of objects loaded on each side of the visible objects. When scrolled halfway into the buffer, the feed will automatically load additional objects while unloading objects on the opposite side.
visible_range
= param.Range(allow_None=True, allow_refs=False, constant=True, inclusive_bounds=(True, True), label=’Visible range’, length=2, nested_refs=False, readonly=True, rx=<param.reactive.reactive_ops object at 0x131b03690>)Read-only upper and lower bounds of the currently visible feed objects. This list is automatically updated based on scrolling.
- clear() List[Viewable] [source]#
Clears the objects on this layout.
- Returns:
objects (list[Viewable])
- Return type:
List of cleared objects.
- clone(*objects: Any, **params: Any) ListLike [source]#
Makes a copy of the layout sharing the same parameters.
- Parameters:
objects (Objects to add to the cloned layout.) –
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned layout object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel [source]#
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None [source]#
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- Parameters:
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for JSON filename
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=False)) – Whether to report progress
states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
- extend(objects: Iterable[Any]) None [source]#
Extends the objects on this layout with a list.
- Parameters:
(list) (objects) –
- get_root(doc: Optional[Document] = None, comm: Optional[Comm] = None, preprocess: bool = True) Model [source]#
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.Document) – Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (boolean (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- index(object) int [source]#
Returns the integer index of the supplied object in the list of objects.
- Parameters:
(object) (obj) –
- Returns:
index (int)
- Return type:
Integer index of the object in the layout.
- insert(index: int, obj: Any) None [source]#
Inserts an object in the layout at the specified index.
- Parameters:
(int) (index) –
(object) (object) –
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback [source]#
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link [source]#
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: Parameterized, callbacks: Optional[Dict[str, Union[str, Callable]]] = None, bidirectional: bool = False, **links: str) Watcher [source]#
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- pop(index: int) Viewable [source]#
Pops an item from the layout by index.
- Parameters:
(int) (index) –
- remove(obj: Viewable) None [source]#
Removes an object from the layout.
- Parameters:
(object) (obj) –
- save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources: bokeh.resources.Resources | None = None, template: str | jinja2.environment.Template | None = None, template_variables: Dict[str, Any] = {}, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None [source]#
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector=None)[source]#
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin [source]#
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document [source]#
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server [source]#
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- class panel.__init__.FlexBox(*objects, **params)[source]#
Bases:
ListLike
,ReactiveHTML
The FlexBox is a list-like layout (unlike GridSpec) that wraps objects into a CSS flex container.
It has a list-like API with methods to append, extend, clear, insert, pop, remove and __setitem__, which makes it possible to interactively update and modify the layout. It exposes all the CSS options for controlling the behavior and layout of the flex box.
Reference: https://panel.holoviz.org/reference/layouts/FlexBox.html
- Example:
>>> pn.FlexBox( ... some_python_object, another_python_object, ..., ... the_last_python_object ... )
Parameters inherited from:
panel.viewable.Layoutable
: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, margin, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.layout.base.ListLike
: objectsalign_content
= param.Selector(allow_refs=False, default=’flex-start’, label=’Align content’, names={}, nested_refs=False, objects=[‘normal’, ‘flex-start’, ‘flex-end’, ‘center’, ‘space-between’, ‘space-around’, ‘space-evenly’, ‘stretch’, ‘start’, ‘end’, ‘baseline’, ‘first baseline’, ‘last baseline’], rx=<param.reactive.reactive_ops object at 0x131af7790>)Defines how a flex container’s lines align when there is extra space in the cross-axis.
align_items
= param.Selector(allow_refs=False, default=’flex-start’, label=’Align items’, names={}, nested_refs=False, objects=[‘stretch’, ‘flex-start’, ‘flex-end’, ‘center’, ‘baseline’, ‘first baseline’, ‘last baseline’, ‘start’, ‘end’, ‘self-start’, ‘self-end’], rx=<param.reactive.reactive_ops object at 0x131d8b850>)Defines the default behavior for how flex items are laid out along the cross axis on the current line.
flex_direction
= param.Selector(allow_refs=False, default=’row’, label=’Flex direction’, names={}, nested_refs=False, objects=[‘row’, ‘row-reverse’, ‘column’, ‘column-reverse’], rx=<param.reactive.reactive_ops object at 0x131af54d0>)This establishes the main-axis, thus defining the direction flex items are placed in the flex container.
flex_wrap
= param.Selector(allow_refs=False, default=’wrap’, label=’Flex wrap’, names={}, nested_refs=False, objects=[‘nowrap’, ‘wrap’, ‘wrap-reverse’], rx=<param.reactive.reactive_ops object at 0x131d88d50>)Whether and how to wrap items in the flex container.
gap
= param.String(allow_refs=False, default=’’, label=’Gap’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131af6f50>)Defines the spacing between flex items, supporting various units (px, em, rem, %, vw/vh).
justify_content
= param.Selector(allow_refs=False, default=’flex-start’, label=’Justify content’, names={}, nested_refs=False, objects=[‘flex-start’, ‘flex-end’, ‘center’, ‘space-between’, ‘space-around’, ‘space-evenly’, ‘start’, ‘end’, ‘left’, ‘right’], rx=<param.reactive.reactive_ops object at 0x131d8bd90>)Defines the alignment along the main axis.
- clear() List[Viewable] [source]#
Clears the objects on this layout.
- Returns:
objects (list[Viewable])
- Return type:
List of cleared objects.
- clone(*objects: Any, **params: Any) ListLike [source]#
Makes a copy of the layout sharing the same parameters.
- Parameters:
objects (Objects to add to the cloned layout.) –
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned layout object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel [source]#
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None [source]#
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- Parameters:
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for JSON filename
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=False)) – Whether to report progress
states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
- extend(objects: Iterable[Any]) None [source]#
Extends the objects on this layout with a list.
- Parameters:
(list) (objects) –
- get_root(doc: Optional[Document] = None, comm: Optional[Comm] = None, preprocess: bool = True) Model [source]#
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.Document) – Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (boolean (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- index(object) int [source]#
Returns the integer index of the supplied object in the list of objects.
- Parameters:
(object) (obj) –
- Returns:
index (int)
- Return type:
Integer index of the object in the layout.
- insert(index: int, obj: Any) None [source]#
Inserts an object in the layout at the specified index.
- Parameters:
(int) (index) –
(object) (object) –
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback [source]#
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link [source]#
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: Parameterized, callbacks: Optional[Dict[str, Union[str, Callable]]] = None, bidirectional: bool = False, **links: str) Watcher [source]#
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- on_event(node: str, event: str, callback: Callable) None [source]#
Registers a callback to be executed when the specified DOM event is triggered on the named node. Note that the named node must be declared in the HTML. To create a named node you must give it an id of the form id=”name”, where name will be the node identifier.
- Parameters:
node (str) – Named node in the HTML identifiable via id of the form id=”name”.
event (str) – Name of the DOM event to add an event listener to.
callback (callable) – A callable which will be given the DOMEvent object.
- pop(index: int) Viewable [source]#
Pops an item from the layout by index.
- Parameters:
(int) (index) –
- remove(obj: Viewable) None [source]#
Removes an object from the layout.
- Parameters:
(object) (obj) –
- save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources: bokeh.resources.Resources | None = None, template: str | jinja2.environment.Template | None = None, template_variables: Dict[str, Any] = {}, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None [source]#
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector=None)[source]#
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin [source]#
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document [source]#
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server [source]#
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- class panel.__init__.FloatPanel(*objects, name='', **params)[source]#
Bases:
ListLike
,ReactiveHTML
Float provides a floating panel layout.
Parameters inherited from:
panel.viewable.Layoutable
: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, margin, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.layout.base.ListLike
: objectsconfig
= param.Dict(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Config’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131af0710>)Additional jsPanel configuration with precedence over parameter values.
contained
= param.Boolean(allow_refs=False, default=True, label=’Contained’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131e46310>)Whether the component is contained within parent container or completely free floating.
position
= param.Selector(allow_refs=False, default=’right-top’, label=’Position’, names={}, nested_refs=False, objects=[‘center’, ‘left-top’, ‘center-top’, ‘right-top’, ‘right-center’, ‘right-bottom’, ‘center-bottom’, ‘left-bottom’, ‘left-center’], rx=<param.reactive.reactive_ops object at 0x131af0710>)The initial position if the container is free-floating.
offsetx
= param.Integer(allow_None=True, allow_refs=False, bounds=(0, None), inclusive_bounds=(True, True), label=’Offsetx’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131d81290>)Horizontal offset in pixels.
offsety
= param.Integer(allow_None=True, allow_refs=False, bounds=(0, None), inclusive_bounds=(True, True), label=’Offsety’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131d82790>)Vertical offset in pixels.
theme
= param.String(allow_refs=False, default=’primary’, label=’Theme’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131d82d90>)The theme which can be one of: - Built-ins: ‘default’, ‘primary’, ‘secondary’, ‘info’, ‘success’, ‘warning’, ‘danger’, ‘light’, ‘dark’ and ‘none’ - HEX, RGB and HSL color values like ‘#123456’ Any standardized color name like ‘forestgreen’ and color names from the Material Design Color System like ‘purple900’ - Additionally a theme string may include one of the modifiers ‘filled’, ‘filledlight’, ‘filleddark’ or ‘fillcolor’ separated from the theme color by a space like ‘primary
status
= param.Selector(allow_refs=False, default=’normalized’, label=’Status’, names={}, nested_refs=False, objects=[‘normalized’, ‘maximized’, ‘minimized’, ‘smallified’, ‘smallifiedmax’, ‘closed’], rx=<param.reactive.reactive_ops object at 0x131af0710>)The current status of the panel.
- clear() List[Viewable] [source]#
Clears the objects on this layout.
- Returns:
objects (list[Viewable])
- Return type:
List of cleared objects.
- clone(*objects: Any, **params: Any) ListLike [source]#
Makes a copy of the layout sharing the same parameters.
- Parameters:
objects (Objects to add to the cloned layout.) –
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned layout object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel [source]#
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None [source]#
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- Parameters:
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for JSON filename
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=False)) – Whether to report progress
states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
- extend(objects: Iterable[Any]) None [source]#
Extends the objects on this layout with a list.
- Parameters:
(list) (objects) –
- get_root(doc: Optional[Document] = None, comm: Optional[Comm] = None, preprocess: bool = True) Model [source]#
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.Document) – Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (boolean (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- index(object) int [source]#
Returns the integer index of the supplied object in the list of objects.
- Parameters:
(object) (obj) –
- Returns:
index (int)
- Return type:
Integer index of the object in the layout.
- insert(index: int, obj: Any) None [source]#
Inserts an object in the layout at the specified index.
- Parameters:
(int) (index) –
(object) (object) –
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback [source]#
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link [source]#
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: Parameterized, callbacks: Optional[Dict[str, Union[str, Callable]]] = None, bidirectional: bool = False, **links: str) Watcher [source]#
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- on_event(node: str, event: str, callback: Callable) None [source]#
Registers a callback to be executed when the specified DOM event is triggered on the named node. Note that the named node must be declared in the HTML. To create a named node you must give it an id of the form id=”name”, where name will be the node identifier.
- Parameters:
node (str) – Named node in the HTML identifiable via id of the form id=”name”.
event (str) – Name of the DOM event to add an event listener to.
callback (callable) – A callable which will be given the DOMEvent object.
- pop(index: int) Viewable [source]#
Pops an item from the layout by index.
- Parameters:
(int) (index) –
- remove(obj: Viewable) None [source]#
Removes an object from the layout.
- Parameters:
(object) (obj) –
- save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources: bokeh.resources.Resources | None = None, template: str | jinja2.environment.Template | None = None, template_variables: Dict[str, Any] = {}, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None [source]#
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector=None)[source]#
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin [source]#
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document [source]#
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server [source]#
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- class panel.__init__.GridBox(*objects: Any, **params: Any)[source]#
Bases:
ListPanel
The GridBox is a list-like layout (unlike GridSpec) that wraps objects into a grid according to the specified nrows and ncols parameters.
It has a list-like API with methods to append, extend, clear, insert, pop, remove and __setitem__, which makes it possible to interactively update and modify the layout.
Reference: https://panel.holoviz.org/reference/layouts/GridBox.html
- Example:
>>> pn.GridBox( ... python_object_1, python_object_2, ..., ... python_object_24, ncols=6 ... )
Parameters inherited from:
panel.viewable.Layoutable
: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, margin, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.layout.base.ListLike
: objectspanel.layout.base.ListPanel
: scrollnrows
= param.Integer(allow_None=True, allow_refs=False, bounds=(0, None), inclusive_bounds=(True, True), label=’Nrows’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131a5ec90>)Number of rows to reflow the layout into.
ncols
= param.Integer(allow_None=True, allow_refs=False, bounds=(0, None), inclusive_bounds=(True, True), label=’Ncols’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131a5f9d0>)Number of columns to reflow the layout into.
- clear() List[Viewable] [source]#
Clears the objects on this layout.
- Returns:
objects (list[Viewable])
- Return type:
List of cleared objects.
- clone(*objects: Any, **params: Any) ListLike [source]#
Makes a copy of the layout sharing the same parameters.
- Parameters:
objects (Objects to add to the cloned layout.) –
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned layout object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel [source]#
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None [source]#
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- Parameters:
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for JSON filename
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=False)) – Whether to report progress
states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
- extend(objects: Iterable[Any]) None [source]#
Extends the objects on this layout with a list.
- Parameters:
(list) (objects) –
- get_root(doc: Optional[Document] = None, comm: Optional[Comm] = None, preprocess: bool = True) Model [source]#
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.Document) – Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (boolean (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- index(object) int [source]#
Returns the integer index of the supplied object in the list of objects.
- Parameters:
(object) (obj) –
- Returns:
index (int)
- Return type:
Integer index of the object in the layout.
- insert(index: int, obj: Any) None [source]#
Inserts an object in the layout at the specified index.
- Parameters:
(int) (index) –
(object) (object) –
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback [source]#
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link [source]#
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: Parameterized, callbacks: Optional[Dict[str, Union[str, Callable]]] = None, bidirectional: bool = False, **links: str) Watcher [source]#
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- pop(index: int) Viewable [source]#
Pops an item from the layout by index.
- Parameters:
(int) (index) –
- remove(obj: Viewable) None [source]#
Removes an object from the layout.
- Parameters:
(object) (obj) –
- save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources: bokeh.resources.Resources | None = None, template: str | jinja2.environment.Template | None = None, template_variables: Dict[str, Any] = {}, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None [source]#
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector=None)[source]#
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin [source]#
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document [source]#
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server [source]#
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- class panel.__init__.GridSpec(*, mode, ncols, nrows, objects, loading, align, aspect_ratio, css_classes, design, height, height_policy, margin, max_height, max_width, min_height, min_width, sizing_mode, styles, stylesheets, tags, visible, width, width_policy, name)[source]#
Bases:
Panel
The GridSpec is an array like layout that allows arranging multiple Panel objects in a grid using a simple API to assign objects to individual grid cells or to a grid span.
Other layout containers function like lists, but a GridSpec has an API similar to a 2D array, making it possible to use 2D assignment to populate, index, and slice the grid.
See GridStack for a similar layout that allows the user to resize and drag the cells.
Reference: https://panel.holoviz.org/reference/layouts/GridSpec.html
- Example:
>>> import panel as pn >>> gspec = pn.GridSpec(width=800, height=600) >>> gspec[:, 0 ] = pn.Spacer(styles=dict(background='red')) >>> gspec[0, 1:3] = pn.Spacer(styles=dict(background='green')) >>> gspec[1, 2:4] = pn.Spacer(styles=dict(background='orange')) >>> gspec[2, 1:4] = pn.Spacer(styles=dict(background='blue')) >>> gspec[0:1, 3:4] = pn.Spacer(styles=dict(background='purple')) >>> gspec
Parameters inherited from:
panel.viewable.Layoutable
: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, margin, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingobjects
= param.Dict(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Objects’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131a78f90>)The dictionary of child objects that make up the grid.
mode
= param.ObjectSelector(allow_refs=False, default=’warn’, label=’Mode’, names={}, nested_refs=False, objects=[‘warn’, ‘error’, ‘override’], rx=<param.reactive.reactive_ops object at 0x131e68b90>)Whether to warn, error or simply override on overlapping assignment.
ncols
= param.Integer(allow_None=True, allow_refs=False, bounds=(0, None), inclusive_bounds=(True, True), label=’Ncols’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131e6a750>)Limits the number of columns that can be assigned.
nrows
= param.Integer(allow_None=True, allow_refs=False, bounds=(0, None), inclusive_bounds=(True, True), label=’Nrows’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131e68590>)Limits the number of rows that can be assigned.
- clone(**params)[source]#
Makes a copy of the GridSpec sharing the same parameters.
- Parameters:
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned GridSpec object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel [source]#
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None [source]#
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- Parameters:
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for JSON filename
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=False)) – Whether to report progress
states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
- get_root(doc: Optional[Document] = None, comm: Optional[Comm] = None, preprocess: bool = True) Model [source]#
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.Document) – Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (boolean (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback [source]#
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link [source]#
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: Parameterized, callbacks: Optional[Dict[str, Union[str, Callable]]] = None, bidirectional: bool = False, **links: str) Watcher [source]#
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources: bokeh.resources.Resources | None = None, template: str | jinja2.environment.Template | None = None, template_variables: Dict[str, Any] = {}, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None [source]#
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector=None)[source]#
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin [source]#
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document [source]#
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server [source]#
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- class panel.__init__.GridStack(*, allow_drag, allow_resize, state, mode, ncols, nrows, objects, loading, align, aspect_ratio, css_classes, design, height, height_policy, margin, max_height, max_width, min_height, min_width, sizing_mode, styles, stylesheets, tags, visible, width, width_policy, name)[source]#
Bases:
ReactiveHTML
,GridSpec
The GridStack layout allows arranging multiple Panel objects in a grid using a simple API to assign objects to individual grid cells or to a grid span.
Other layout containers function like lists, but a GridSpec has an API similar to a 2D array, making it possible to use 2D assignment to populate, index, and slice the grid.
Reference: https://panel.holoviz.org/reference/layouts/GridStack.html
- Example:
>>> pn.extension('gridstack') >>> gstack = GridStack(sizing_mode='stretch_both') >>> gstack[ : , 0: 3] = pn.Spacer(styles=dict(background='red')) >>> gstack[0:2, 3: 9] = pn.Spacer(styles=dict(background='green')) >>> gstack[2:4, 6:12] = pn.Spacer(styles=dict(background='orange')) >>> gstack[4:6, 3:12] = pn.Spacer(styles=dict(background='blue')) >>> gstack[0:2, 9:12] = pn.Spacer(styles=dict(background='purple'))
Parameters inherited from:
panel.viewable.Layoutable
: align, aspect_ratio, css_classes, design, min_width, min_height, max_width, max_height, margin, styles, stylesheets, tags, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.layout.grid.GridSpec
: objects, mode, ncols, nrowsheight
= param.Integer(allow_None=True, allow_refs=False, bounds=(0, None), inclusive_bounds=(True, True), label=’Height’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131a0e690>)The height of the component (in pixels). This can be either fixed or preferred height, depending on height sizing policy.
width
= param.Integer(allow_None=True, allow_refs=False, bounds=(0, None), inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131e6afd0>)The width of the component (in pixels). This can be either fixed or preferred width, depending on width sizing policy.
allow_resize
= param.Boolean(allow_refs=False, default=True, label=’Allow resize’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131a0f010>)Allow resizing the grid cells.
allow_drag
= param.Boolean(allow_refs=False, default=True, label=’Allow drag’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131a0d150>)Allow dragging the grid cells.
state
= param.List(allow_refs=False, bounds=(0, None), default=[], label=’State’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131eea9d0>)Current state of the grid (updated as items are resized and dragged).
- clone(**params)[source]#
Makes a copy of the GridSpec sharing the same parameters.
- Parameters:
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned GridSpec object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel [source]#
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None [source]#
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- Parameters:
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for JSON filename
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=False)) – Whether to report progress
states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
- get_root(doc: Optional[Document] = None, comm: Optional[Comm] = None, preprocess: bool = True) Model [source]#
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.Document) – Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (boolean (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback [source]#
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link [source]#
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: Parameterized, callbacks: Optional[Dict[str, Union[str, Callable]]] = None, bidirectional: bool = False, **links: str) Watcher [source]#
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- on_event(node: str, event: str, callback: Callable) None [source]#
Registers a callback to be executed when the specified DOM event is triggered on the named node. Note that the named node must be declared in the HTML. To create a named node you must give it an id of the form id=”name”, where name will be the node identifier.
- Parameters:
node (str) – Named node in the HTML identifiable via id of the form id=”name”.
event (str) – Name of the DOM event to add an event listener to.
callback (callable) – A callable which will be given the DOMEvent object.
- save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources: bokeh.resources.Resources | None = None, template: str | jinja2.environment.Template | None = None, template_variables: Dict[str, Any] = {}, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None [source]#
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector=None)[source]#
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin [source]#
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document [source]#
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server [source]#
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- class panel.__init__.HSpacer(refs=None, **params)[source]#
Bases:
Spacer
The HSpacer layout provides responsive horizontal spacing.
Using this component we can space objects equidistantly in a layout and allow the empty space to shrink when the browser is resized.
How-to: https://panel.holoviz.org/how_to/layout/spacing.html#spacer-components
- Example:
>>> pn.Row( ... pn.layout.HSpacer(), 'Item 1', ... pn.layout.HSpacer(), 'Item 2', ... pn.layout.HSpacer() ... )
Parameters inherited from:
panel.viewable.Layoutable
: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, margin, styles, stylesheets, tags, width, width_policy, height_policy, visiblepanel.viewable.Viewable
: loadingsizing_mode
= param.Parameter(allow_refs=False, constant=True, default=’stretch_width’, label=’Sizing mode’, nested_refs=False, readonly=True, rx=<param.reactive.reactive_ops object at 0x131997e90>)How the component should size itself. This is a high-level setting for maintaining width and height of the component. To gain more fine grained control over sizing, use
width_policy
,height_policy
andaspect_ratio
instead (those take precedence oversizing_mode
)."fixed"
Component is not responsive. It will retain its original width and height regardless of any subsequent browser window resize events."stretch_width"
Component will responsively resize to stretch to the available width, without maintaining any aspect ratio. The height of the component depends on the type of the component and may be fixed or fit to component’s contents."stretch_height"
Component will responsively resize to stretch to the available height, without maintaining any aspect ratio. The width of the component depends on the type of the component and may be fixed or fit to component’s contents."stretch_both"
Component is completely responsive, independently in width and height, and will occupy all the available horizontal and vertical space, even if this changes the aspect ratio of the component."scale_width"
Component will responsively resize to stretch to the available width, while maintaining the original or provided aspect ratio."scale_height"
Component will responsively resize to stretch to the available height, while maintaining the original or provided aspect ratio."scale_both"
Component will responsively resize to both the available width and height, while maintaining the original or provided aspect ratio.
- clone(**params) Viewable [source]#
Makes a copy of the object sharing the same parameters.
- Parameters:
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned Viewable object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel [source]#
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None [source]#
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- Parameters:
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for JSON filename
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=False)) – Whether to report progress
states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
- get_root(doc: Optional[Document] = None, comm: Optional[Comm] = None, preprocess: bool = True) Model [source]#
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.Document) – Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (boolean (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback [source]#
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link [source]#
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: Parameterized, callbacks: Optional[Dict[str, Union[str, Callable]]] = None, bidirectional: bool = False, **links: str) Watcher [source]#
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources: bokeh.resources.Resources | None = None, template: str | jinja2.environment.Template | None = None, template_variables: Dict[str, Any] = {}, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None [source]#
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector: Optional[Union[type, Callable[[Viewable], bool]]] = None) List[Viewable] [source]#
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin [source]#
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document [source]#
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server [source]#
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- class panel.__init__.Param(object=None, **params)[source]#
Bases:
PaneBase
Param panes render a Parameterized class to a set of widgets which are linked to the parameter values on the class.
Parameters inherited from:
panel.viewable.Layoutable
: align, aspect_ratio, css_classes, design, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.pane.base.PaneBase
: marginheight
= param.Integer(allow_None=True, allow_refs=False, bounds=(0, None), inclusive_bounds=(True, True), label=’Height’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131d42610>)Height of widgetbox the parameter widgets are displayed in.
width
= param.Integer(allow_None=True, allow_refs=False, bounds=(0, None), inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131d40cd0>)Width of widgetbox the parameter widgets are displayed in.
default_layout
= param.ClassSelector(allow_refs=False, class_=<class ‘panel.layout.base.Panel’>, default=<class ‘panel.layout.base.Column’>, label=’Default layout’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131d51890>)Defines the layout the model(s) returned by the pane will be placed in.
object
= param.Parameter(allow_None=True, allow_refs=False, label=’Object’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131d432d0>)The object being wrapped, which will be converted to a Bokeh model.
display_threshold
= param.Number(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Display threshold’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131d40c90>)Parameters with precedence below this value are not displayed.
default_precedence
= param.Number(allow_refs=False, default=1e-08, inclusive_bounds=(True, True), label=’Default precedence’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131d426d0>)Precedence value to use for parameters with no declared precedence. By default, zero predecence is available for forcing some parameters to the top of the list, and other values above the default_precedence values can be used to sort or group parameters arbitrarily.
expand
= param.Boolean(allow_refs=False, default=False, label=’Expand’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131d51dd0>)Whether parameterized subobjects are expanded or collapsed on instantiation.
expand_button
= param.Boolean(allow_None=True, allow_refs=False, label=’Expand button’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131d43a50>)Whether to add buttons to expand and collapse sub-objects.
expand_layout
= param.Parameter(allow_refs=False, default=<class ‘panel.layout.base.Column’>, label=’Expand layout’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131d51890>)Layout to expand sub-objects into.
hide_constant
= param.Boolean(allow_refs=False, default=False, label=’Hide constant’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131d40250>)Whether to hide widgets of constant parameters.
initializer
= param.Callable(allow_None=True, allow_refs=False, label=’Initializer’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131d51c90>)User-supplied function that will be called on initialization, usually to update the default Parameter values of the underlying parameterized object.
parameters
= param.List(allow_None=True, allow_refs=False, bounds=(0, None), default=[], label=’Parameters’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131d40250>)If set this serves as a allowlist of parameters to display on the supplied Parameterized object.
show_labels
= param.Boolean(allow_refs=False, default=True, label=’Show labels’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131d51c90>)Whether to show labels for each widget
show_name
= param.Boolean(allow_refs=False, default=True, label=’Show name’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131d43310>)Whether to show the parameterized object’s name
sort
= param.ClassSelector(allow_refs=False, class_=(<class ‘bool’>, <class ‘collections.abc.Callable’>), default=False, label=’Sort’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131d42f50>)If True the widgets will be sorted alphabetically by label. If a callable is provided it will be used to sort the Parameters, for example lambda x: x[1].label[::-1] will sort by the reversed label.
widgets
= param.Dict(allow_None=True, allow_refs=False, class_=<class ‘dict’>, label=’Widgets’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131d41ad0>)Dictionary of widget overrides, mapping from parameter name to widget class.
- classmethod applies(obj: Any) float | bool | None [source]#
Returns boolean or float indicating whether the Pane can render the object.
If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.
- clone(object: Optional[Any] = None, **params) T [source]#
Makes a copy of the Pane sharing the same parameters.
- Parameters:
object (Optional new object to render) –
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned Pane object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel [source]#
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None [source]#
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- Parameters:
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for JSON filename
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=False)) – Whether to report progress
states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
- classmethod get_pane_type(obj: Any, **kwargs) Type[PaneBase] [source]#
Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.
- Parameters:
(object) (obj) –
- Return type:
The applicable Pane type with the highest precedence.
- get_root(doc: Optional[Document] = None, comm: Comm | None = None, preprocess: bool = True) Model [source]#
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.document.Document) – Optional Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (bool (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback [source]#
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link [source]#
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: Parameterized, callbacks: Optional[Dict[str, Union[str, Callable]]] = None, bidirectional: bool = False, **links: str) Watcher [source]#
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources: bokeh.resources.Resources | None = None, template: str | jinja2.environment.Template | None = None, template_variables: Dict[str, Any] = {}, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None [source]#
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector=None)[source]#
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin [source]#
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document [source]#
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server [source]#
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- class panel.__init__.ReactiveExpr(object=None, **params)[source]#
Bases:
PaneBase
ReactiveExpr generates a UI for param.rx objects by rendering the widgets and outputs.
Parameters inherited from:
panel.viewable.Layoutable
: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.pane.base.PaneBase
: margin, default_layoutobject
= param.Parameter(allow_None=True, allow_refs=False, label=’Object’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131d51210>)The object being wrapped, which will be converted to a Bokeh model.
center
= param.Boolean(allow_refs=False, default=False, label=’Center’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131848990>)Whether to center the output.
show_widgets
= param.Boolean(allow_refs=False, default=True, label=’Show widgets’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131d52910>)Whether to display the widget inputs.
widget_layout
= param.Selector(allow_refs=False, constant=True, default=<class ‘panel.layout.base.WidgetBox’>, label=’Widget layout’, names={}, nested_refs=False, objects=[<class ‘panel.layout.base.WidgetBox’>, <class ‘panel.layout.base.Row’>, <class ‘panel.layout.base.Column’>], rx=<param.reactive.reactive_ops object at 0x131848c50>)The layout object to display the widgets in.
widget_location
= param.Selector(allow_refs=False, default=’left_top’, label=’Widget location’, names={}, nested_refs=False, objects=[‘left’, ‘right’, ‘top’, ‘bottom’, ‘top_left’, ‘top_right’, ‘bottom_left’, ‘bottom_right’, ‘left_top’, ‘right_top’, ‘right_bottom’], rx=<param.reactive.reactive_ops object at 0x131849b50>)The location of the widgets relative to the output of the reactive expression.
- classmethod applies(object)[source]#
Returns boolean or float indicating whether the Pane can render the object.
If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.
- clone(object: Optional[Any] = None, **params) T [source]#
Makes a copy of the Pane sharing the same parameters.
- Parameters:
object (Optional new object to render) –
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned Pane object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel [source]#
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None [source]#
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- Parameters:
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for JSON filename
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=False)) – Whether to report progress
states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
- classmethod get_pane_type(obj: Any, **kwargs) Type[PaneBase] [source]#
Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.
- Parameters:
(object) (obj) –
- Return type:
The applicable Pane type with the highest precedence.
- get_root(doc: Optional[Document] = None, comm: Comm | None = None, preprocess: bool = True) Model [source]#
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.document.Document) – Optional Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (bool (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback [source]#
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link [source]#
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: Parameterized, callbacks: Optional[Dict[str, Union[str, Callable]]] = None, bidirectional: bool = False, **links: str) Watcher [source]#
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources: bokeh.resources.Resources | None = None, template: str | jinja2.environment.Template | None = None, template_variables: Dict[str, Any] = {}, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None [source]#
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector: Optional[Union[type, Callable[[Viewable], bool]]] = None) List[Viewable] [source]#
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin [source]#
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document [source]#
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server [source]#
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- class panel.__init__.Row(*objects: Any, **params: Any)[source]#
Bases:
ListPanel
The Row layout allows arranging multiple panel objects in a horizontal container.
It has a list-like API with methods to append, extend, clear, insert, pop, remove and __setitem__, which makes it possible to interactively update and modify the layout.
Reference: https://panel.holoviz.org/reference/layouts/Row.html
- Example:
>>> pn.Row(some_widget, some_pane, some_python_object)
Parameters inherited from:
panel.viewable.Layoutable
: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, margin, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.layout.base.ListLike
: objectspanel.layout.base.ListPanel
: scroll- clear() List[Viewable] [source]#
Clears the objects on this layout.
- Returns:
objects (list[Viewable])
- Return type:
List of cleared objects.
- clone(*objects: Any, **params: Any) ListLike [source]#
Makes a copy of the layout sharing the same parameters.
- Parameters:
objects (Objects to add to the cloned layout.) –
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned layout object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel [source]#
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None [source]#
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- Parameters:
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for JSON filename
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=False)) – Whether to report progress
states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
- extend(objects: Iterable[Any]) None [source]#
Extends the objects on this layout with a list.
- Parameters:
(list) (objects) –
- get_root(doc: Optional[Document] = None, comm: Optional[Comm] = None, preprocess: bool = True) Model [source]#
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.Document) – Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (boolean (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- index(object) int [source]#
Returns the integer index of the supplied object in the list of objects.
- Parameters:
(object) (obj) –
- Returns:
index (int)
- Return type:
Integer index of the object in the layout.
- insert(index: int, obj: Any) None [source]#
Inserts an object in the layout at the specified index.
- Parameters:
(int) (index) –
(object) (object) –
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback [source]#
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link [source]#
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: Parameterized, callbacks: Optional[Dict[str, Union[str, Callable]]] = None, bidirectional: bool = False, **links: str) Watcher [source]#
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- pop(index: int) Viewable [source]#
Pops an item from the layout by index.
- Parameters:
(int) (index) –
- remove(obj: Viewable) None [source]#
Removes an object from the layout.
- Parameters:
(object) (obj) –
- save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources: bokeh.resources.Resources | None = None, template: str | jinja2.environment.Template | None = None, template_variables: Dict[str, Any] = {}, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None [source]#
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector=None)[source]#
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin [source]#
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document [source]#
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server [source]#
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- class panel.__init__.Spacer(refs=None, **params)[source]#
Bases:
Reactive
The Spacer layout is a very versatile component which makes it easy to put fixed or responsive spacing between objects.
Like all other components spacers support both absolute and responsive sizing modes.
How-to: https://panel.holoviz.org/how_to/layout/spacing.html#spacer-components
- Example:
>>> pn.Row( ... 1, pn.Spacer(width=200), ... 2, pn.Spacer(width=100), ... 3 ... )
Parameters inherited from:
panel.viewable.Layoutable
: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, margin, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loading- clone(**params) Viewable [source]#
Makes a copy of the object sharing the same parameters.
- Parameters:
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned Viewable object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel [source]#
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None [source]#
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- Parameters:
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for JSON filename
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=False)) – Whether to report progress
states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
- get_root(doc: Optional[Document] = None, comm: Optional[Comm] = None, preprocess: bool = True) Model [source]#
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.Document) – Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (boolean (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback [source]#
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link [source]#
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: Parameterized, callbacks: Optional[Dict[str, Union[str, Callable]]] = None, bidirectional: bool = False, **links: str) Watcher [source]#
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources: bokeh.resources.Resources | None = None, template: str | jinja2.environment.Template | None = None, template_variables: Dict[str, Any] = {}, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None [source]#
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector: Optional[Union[type, Callable[[Viewable], bool]]] = None) List[Viewable] [source]#
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin [source]#
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document [source]#
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server [source]#
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- class panel.__init__.Swipe(*objects, **params)[source]#
Bases:
ListLike
,ReactiveHTML
The Swipe layout enables you to quickly compare two panels laid out on top of each other with a part of the before panel shown on one side of a slider and a part of the after panel shown on the other side.
Parameters inherited from:
panel.viewable.Layoutable
: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, margin, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingobjects
= param.List(allow_refs=False, bounds=(0, 2), default=[], label=’Objects’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131863250>)The list of child objects that make up the layout.
slider_width
= param.Integer(allow_refs=False, bounds=(0, 25), default=5, inclusive_bounds=(True, True), label=’Slider width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1319944d0>)The width of the slider in pixels
slider_color
= param.Color(allow_named=True, allow_refs=False, default=’black’, label=’Slider color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131b12a90>)The color of the slider
value
= param.Integer(allow_refs=False, bounds=(0, 100), default=50, inclusive_bounds=(True, True), label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1318621d0>)The percentage of the after panel to show.
_before
= param.Parameter(allow_None=True, allow_refs=False, label=’ before’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131863b50>)_after
= param.Parameter(allow_None=True, allow_refs=False, label=’ after’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x13187e1d0>)- clear() List[Viewable] [source]#
Clears the objects on this layout.
- Returns:
objects (list[Viewable])
- Return type:
List of cleared objects.
- clone(*objects: Any, **params: Any) ListLike [source]#
Makes a copy of the layout sharing the same parameters.
- Parameters:
objects (Objects to add to the cloned layout.) –
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned layout object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel [source]#
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None [source]#
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- Parameters:
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for JSON filename
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=False)) – Whether to report progress
states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
- extend(objects: Iterable[Any]) None [source]#
Extends the objects on this layout with a list.
- Parameters:
(list) (objects) –
- get_root(doc: Optional[Document] = None, comm: Optional[Comm] = None, preprocess: bool = True) Model [source]#
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.Document) – Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (boolean (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- index(object) int [source]#
Returns the integer index of the supplied object in the list of objects.
- Parameters:
(object) (obj) –
- Returns:
index (int)
- Return type:
Integer index of the object in the layout.
- insert(index: int, obj: Any) None [source]#
Inserts an object in the layout at the specified index.
- Parameters:
(int) (index) –
(object) (object) –
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback [source]#
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link [source]#
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: Parameterized, callbacks: Optional[Dict[str, Union[str, Callable]]] = None, bidirectional: bool = False, **links: str) Watcher [source]#
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- on_event(node: str, event: str, callback: Callable) None [source]#
Registers a callback to be executed when the specified DOM event is triggered on the named node. Note that the named node must be declared in the HTML. To create a named node you must give it an id of the form id=”name”, where name will be the node identifier.
- Parameters:
node (str) – Named node in the HTML identifiable via id of the form id=”name”.
event (str) – Name of the DOM event to add an event listener to.
callback (callable) – A callable which will be given the DOMEvent object.
- pop(index: int) Viewable [source]#
Pops an item from the layout by index.
- Parameters:
(int) (index) –
- remove(obj: Viewable) None [source]#
Removes an object from the layout.
- Parameters:
(object) (obj) –
- save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources: bokeh.resources.Resources | None = None, template: str | jinja2.environment.Template | None = None, template_variables: Dict[str, Any] = {}, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None [source]#
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector=None)[source]#
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin [source]#
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document [source]#
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server [source]#
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- class panel.__init__.Tabs(*objects, **params)[source]#
Bases:
NamedListPanel
The Tabs layout allows switching between multiple objects by clicking on the corresponding tab header.
Tab labels may be defined explicitly as part of a tuple or will be inferred from the name parameter of the tab’s contents.
Like Column and Row, Tabs has a list-like API with methods to append, extend, clear, insert, pop, remove and __setitem__, which make it possible to interactively update and modify the tabs.
Reference: https://panel.holoviz.org/reference/layouts/Tabs.html
- Example:
>>> pn.Tabs(('Scatter', plot1), some_pane_with_a_name)
Parameters inherited from:
panel.viewable.Layoutable
: align, aspect_ratio, css_classes, design, min_width, min_height, max_width, max_height, margin, styles, stylesheets, tags, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.layout.base.NamedListLike
: objectspanel.layout.base.NamedListPanel
: active, scrollheight
= param.Integer(allow_None=True, allow_refs=False, bounds=(0, None), inclusive_bounds=(True, True), label=’Height’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x13187ef10>)The height of the component (in pixels). This can be either fixed or preferred height, depending on height sizing policy.
width
= param.Integer(allow_None=True, allow_refs=False, bounds=(0, None), inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131ceaa10>)The width of the component (in pixels). This can be either fixed or preferred width, depending on width sizing policy.
closable
= param.Boolean(allow_refs=False, default=False, label=’Closable’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131cf0410>)Whether it should be possible to close tabs.
dynamic
= param.Boolean(allow_refs=False, default=False, label=’Dynamic’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131cea710>)Dynamically populate only the active tab.
tabs_location
= param.ObjectSelector(allow_refs=False, default=’above’, label=’Tabs location’, names={}, nested_refs=False, objects=[‘above’, ‘below’, ‘left’, ‘right’], rx=<param.reactive.reactive_ops object at 0x131cf0410>)The location of the tabs relative to the tab contents.
- clone(*objects: Any, **params: Any) NamedListLike [source]#
Makes a copy of the Tabs sharing the same parameters.
- Parameters:
objects (Objects to add to the cloned Tabs object.) –
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned Tabs object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel [source]#
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None [source]#
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- Parameters:
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for JSON filename
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=False)) – Whether to report progress
states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
- extend(panes: Iterable[Any]) None [source]#
Extends the the tabs with a list.
- Parameters:
(list) (objects) –
- get_root(doc: Optional[Document] = None, comm: Optional[Comm] = None, preprocess: bool = True) Model [source]#
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.Document) – Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (boolean (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- insert(index: int, pane: Any) None [source]#
Inserts an object in the tabs at the specified index.
- Parameters:
(int) (index) –
(object) (object) –
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback [source]#
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link [source]#
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: Parameterized, callbacks: Optional[Dict[str, Union[str, Callable]]] = None, bidirectional: bool = False, **links: str) Watcher [source]#
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources: bokeh.resources.Resources | None = None, template: str | jinja2.environment.Template | None = None, template_variables: Dict[str, Any] = {}, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None [source]#
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector=None)[source]#
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin [source]#
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document [source]#
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server [source]#
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- class panel.__init__.Template(template: str | _Template, nb_template: str | _Template | None = None, items: Optional[Dict[str, Any]] = None, **params)[source]#
Bases:
BaseTemplate
A Template is a high-level component to render multiple Panel objects into a single HTML document defined through a Jinja2 template. The Template object is given a Jinja2 template and then allows populating this template by adding Panel objects, which are given unique names. These unique names may then be referenced in the template to insert the rendered Panel object at a specific location. For instance, given a Jinja2 template that defines roots A and B like this:
<div> {{ embed(roots.A) }} </div> <div> {{ embed(roots.B) }} </div>
We can then populate the template by adding panel ‘A’ and ‘B’ to the Template object:
template.add_panel(‘A’, pn.panel(‘A’)) template.add_panel(‘B’, pn.panel(‘B’))
Once a template has been fully populated it can be rendered using the same API as other Panel objects. Note that all roots that have been declared using the {{ embed(roots.A) }} syntax in the Jinja2 template must be defined when rendered.
Since embedding complex CSS frameworks inside a notebook can have undesirable side-effects and a notebook does not afford the same amount of screen space a Template may given separate template and nb_template objects. This allows for different layouts when served as a standalone server and when used in the notebook.
Parameters inherited from:
panel.template.base.BaseTemplate
: config, design, location, theme- add_panel(name: str, panel: Viewable, tags: List[str] = []) None [source]#
Add panels to the Template, which may then be referenced by the given name using the jinja2 embed macro.
- Parameters:
name (str) – The name to refer to the panel by in the template
panel (panel.Viewable) – A Panel component to embed in the template.
- add_variable(name: str, value: Any) None [source]#
Add parameters to the template, which may then be referenced by the given name in the Jinja2 template.
- Parameters:
name (str) – The name to refer to the panel by in the template
value (object) – Any valid Jinja2 variable type.
- resolve_resources(cdn: bool | Literal['auto'] = 'auto', extras: dict[str, dict[str, str]] | None = None) ResourcesType [source]#
Resolves the resources required for this template component.
- Parameters:
cdn (bool | Literal['auto']) – Whether to load resources from CDN or local server. If set to ‘auto’ value will be automatically determine based on global settings.
extras (dict[str, dict[str, str]] | None) – Additional resources to add to the bundle. Valid resource types include js, js_modules and css.
- Return type:
Dictionary containing JS and CSS resources.
- save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources=None, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None) None [source]#
Saves Panel objects to file.
- Parameters:
filename (string or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
- select(selector=None)[source]#
Iterates over the Template and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) BaseTemplate [source]#
Serves the template and returns self to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The template
- server_doc(doc: Optional[Document] = None, title: str = None, location: bool | Location = True) Document [source]#
Returns a servable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The Bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The Bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server [source]#
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- theme[source]#
alias of
DefaultTheme
- class panel.__init__.VSpacer(refs=None, **params)[source]#
Bases:
Spacer
The VSpacer layout provides responsive vertical spacing.
Using this component we can space objects equidistantly in a layout and allow the empty space to shrink when the browser is resized.
Reference: https://panel.holoviz.org/user_guide/Customization.html#spacers
- Example:
>>> pn.Column( ... pn.layout.VSpacer(), 'Item 1', ... pn.layout.VSpacer(), 'Item 2', ... pn.layout.VSpacer() ... )
Parameters inherited from:
panel.viewable.Layoutable
: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, margin, styles, stylesheets, tags, width, width_policy, height_policy, visiblepanel.viewable.Viewable
: loadingsizing_mode
= param.Parameter(allow_refs=False, constant=True, default=’stretch_height’, label=’Sizing mode’, nested_refs=False, readonly=True, rx=<param.reactive.reactive_ops object at 0x131579190>)How the component should size itself. This is a high-level setting for maintaining width and height of the component. To gain more fine grained control over sizing, use
width_policy
,height_policy
andaspect_ratio
instead (those take precedence oversizing_mode
)."fixed"
Component is not responsive. It will retain its original width and height regardless of any subsequent browser window resize events."stretch_width"
Component will responsively resize to stretch to the available width, without maintaining any aspect ratio. The height of the component depends on the type of the component and may be fixed or fit to component’s contents."stretch_height"
Component will responsively resize to stretch to the available height, without maintaining any aspect ratio. The width of the component depends on the type of the component and may be fixed or fit to component’s contents."stretch_both"
Component is completely responsive, independently in width and height, and will occupy all the available horizontal and vertical space, even if this changes the aspect ratio of the component."scale_width"
Component will responsively resize to stretch to the available width, while maintaining the original or provided aspect ratio."scale_height"
Component will responsively resize to stretch to the available height, while maintaining the original or provided aspect ratio."scale_both"
Component will responsively resize to both the available width and height, while maintaining the original or provided aspect ratio.
- clone(**params) Viewable [source]#
Makes a copy of the object sharing the same parameters.
- Parameters:
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned Viewable object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel [source]#
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None [source]#
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- Parameters:
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for JSON filename
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=False)) – Whether to report progress
states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
- get_root(doc: Optional[Document] = None, comm: Optional[Comm] = None, preprocess: bool = True) Model [source]#
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.Document) – Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (boolean (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback [source]#
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link [source]#
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: Parameterized, callbacks: Optional[Dict[str, Union[str, Callable]]] = None, bidirectional: bool = False, **links: str) Watcher [source]#
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources: bokeh.resources.Resources | None = None, template: str | jinja2.environment.Template | None = None, template_variables: Dict[str, Any] = {}, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None [source]#
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector: Optional[Union[type, Callable[[Viewable], bool]]] = None) List[Viewable] [source]#
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin [source]#
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document [source]#
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server [source]#
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- class panel.__init__.WidgetBox(*objects: Any, **params: Any)[source]#
Bases:
ListPanel
The WidgetBox layout allows arranging multiple panel objects in a vertical (or horizontal) container.
It is largely identical to the Column layout, but has some default styling that makes widgets be clearly grouped together visually.
It has a list-like API with methods to append, extend, clear, insert, pop, remove and __setitem__, which make it possible to interactively update and modify the layout.
Reference: https://panel.holoviz.org/reference/layouts/WidgetBox.html
- Example:
>>> pn.WidgetBox(some_widget, another_widget)
Parameters inherited from:
panel.viewable.Layoutable
: align, aspect_ratio, design, height, min_width, min_height, max_width, max_height, margin, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.layout.base.ListLike
: objectspanel.layout.base.ListPanel
: scrollcss_classes
= param.List(allow_refs=False, bounds=(0, None), default=[‘panel-widget-box’], label=’Css classes’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x131d819d0>)CSS classes to apply to the layout.
disabled
= param.Boolean(allow_refs=False, default=False, label=’Disabled’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131aa9150>)Whether the widget is disabled.
horizontal
= param.Boolean(allow_refs=False, default=False, label=’Horizontal’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x131d83e90>)Whether to lay out the widgets in a Row layout as opposed to a Column layout.
- clear() List[Viewable] [source]#
Clears the objects on this layout.
- Returns:
objects (list[Viewable])
- Return type:
List of cleared objects.
- clone(*objects: Any, **params: Any) ListLike [source]#
Makes a copy of the layout sharing the same parameters.
- Parameters:
objects (Objects to add to the cloned layout.) –
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned layout object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel [source]#
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None [source]#
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- Parameters:
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for JSON filename
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=False)) – Whether to report progress
states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
- extend(objects: Iterable[Any]) None [source]#
Extends the objects on this layout with a list.
- Parameters:
(list) (objects) –
- get_root(doc: Optional[Document] = None, comm: Optional[Comm] = None, preprocess: bool = True) Model [source]#
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.Document) – Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (boolean (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- index(object) int [source]#
Returns the integer index of the supplied object in the list of objects.
- Parameters:
(object) (obj) –
- Returns:
index (int)
- Return type:
Integer index of the object in the layout.
- insert(index: int, obj: Any) None [source]#
Inserts an object in the layout at the specified index.
- Parameters:
(int) (index) –
(object) (object) –
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback [source]#
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link [source]#
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: Parameterized, callbacks: Optional[Dict[str, Union[str, Callable]]] = None, bidirectional: bool = False, **links: str) Watcher [source]#
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- pop(index: int) Viewable [source]#
Pops an item from the layout by index.
- Parameters:
(int) (index) –
- remove(obj: Viewable) None [source]#
Removes an object from the layout.
- Parameters:
(object) (obj) –
- save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources: bokeh.resources.Resources | None = None, template: str | jinja2.environment.Template | None = None, template_variables: Dict[str, Any] = {}, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None [source]#
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector=None)[source]#
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin [source]#
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document [source]#
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server [source]#
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- panel.__init__.bind(function, *args, watch=False, **kwargs)[source]#
Given a function, returns a wrapper function that binds the values of some or all arguments to Parameter values and expresses Param dependencies on those values, so that the function can be invoked whenever the underlying values change and the output will reflect those updated values.
As for functools.partial, arguments can also be bound to constants, which allows all of the arguments to be bound, leaving a simple callable object.
- Parameters:
function (callable) – The function to bind constant or dynamic args and kwargs to.
args (object, param.Parameter) – Positional arguments to bind to the function.
watch (boolean) – Whether to evaluate the function automatically whenever one of the bound parameters changes.
kwargs (object, param.Parameter) – Keyword arguments to bind to the function.
- Returns:
Returns a new function with the args and kwargs bound to it and
annotated with all dependencies.
- panel.__init__.cache(func=None, hash_funcs=None, max_items=None, policy='LRU', ttl=None, to_disk=False, cache_path='./cache', per_session=False)[source]#
Memoizes functions for a user session. Can be used as function annotation or just directly.
For global caching across user sessions use pn.state.as_cached.
- Parameters:
func (callable) – The function to cache.
hash_funcs (dict or None) – A dictionary mapping from a type to a function which returns a hash for an object of that type. If provided this will override the default hashing function provided by Panel.
max_items (int or None) – The maximum items to keep in the cache. Default is None, which does not limit number of items stored in the cache.
policy (str) –
- A caching policy when max_items is set, must be one of:
FIFO: First in - First out
LRU: Least recently used
LFU: Least frequently used
ttl (float or None) – The number of seconds to keep an item in the cache, or None if the cache should not expire. The default is None.
to_disk (bool) – Whether to cache to disk using diskcache.
cache_dir (str) – Directory to cache to on disk.
per_session (bool) – Whether to cache data only for the current session.
- panel.__init__.depends(func, *dependencies, watch=False, on_init=False, **kw)[source]#
Annotates a function or Parameterized method to express its dependencies.
The specified dependencies can be either be Parameter instances or if a method is supplied they can be defined as strings referring to Parameters of the class, or Parameters of subobjects (Parameterized objects that are values of this object’s parameters). Dependencies can either be on Parameter values, or on other metadata about the Parameter.
- Parameters:
watch (bool, optional) – Whether to invoke the function/method when the dependency is updated, by default False
on_init (bool, optional) – Whether to invoke the function/method when the instance is created, by default False
- panel.__init__.extension[source]#
alias of
panel_extension
- panel.__init__.ipywidget(obj: Any, doc=None, **kwargs: Any)[source]#
Returns an ipywidget model which renders the Panel object.
Requires jupyter_bokeh to be installed.
- Parameters:
obj (object) – Any Panel object or object which can be rendered with Panel
doc (bokeh.Document) – Bokeh document the bokeh model will be attached to.
**kwargs (dict) – Keyword arguments passed to the pn.panel utility function
- Return type:
Returns an ipywidget model which renders the Panel object.
- panel.__init__.panel(obj: Any, **kwargs) Viewable [source]#
Creates a displayable Panel object given any valid Python object.
The appropriate Pane to render a specific object is determined by iterating over all defined Pane types and querying it’s .applies method for a priority value.
Any keyword arguments are passed down to the applicable Pane.
Setting loading_indicator=True will display a loading indicator while the function is being evaluated.
To lazily render components when the application loads, you may also provide a Python function, with or without bound parameter dependencies and set defer_load=True.
Reference: https://panel.holoviz.org/explanation/components/components_overview.html#panes
>>> pn.panel(some_python_object, width=500)
- Parameters:
obj (object) – Any object to be turned into a Panel
**kwargs (dict) – Any keyword arguments to be passed to the applicable Pane
- Returns:
layout – A Viewable representation of the input object
- Return type:
- class panel.__init__.rx(obj=None, **kwargs)[source]#
Bases:
object
rx allows wrapping objects and then operating on them interactively while recording any operations applied to them. By recording all arguments or operands in the operations the recorded pipeline can be replayed if an operand represents a dynamic value.
- Parameters:
obj (any) – A supported data structure object
Examples
Instantiate it from an object:
>>> ifloat = rx(3.14) >>> ifloat * 2 6.28
Then update the original value and see the new result: >>> ifloat.value = 1 2
- classmethod register_accessor(name: str, accessor: Callable[[rx], Any], predicate: Optional[Callable[[Any], bool]] = None)[source]#
Registers an accessor that extends rx with custom behavior.
- Parameters:
name (str) – The name of the accessor will be attribute-accessible under.
accessor (Callable[[rx], any]) – A callable that will return the accessor namespace object given the rx object it is registered on.
predicate (Callable[[Any], bool] | None) –
- classmethod register_display_handler(obj_type, handler, **kwargs)[source]#
Registers a display handler for a specific type of object, making it possible to define custom display options for specific objects.
- Parameters:
obj_type (type | callable) – The type to register a custom display handler on.
handler (Viewable | callable) – A Viewable or callable that is given the object to be displayed and the custom keyword arguments.
kwargs (dict[str, Any]) – Additional display options to register for this type.
- panel.__init__.serve(panels: TViewableFuncOrPath | Mapping[str, TViewableFuncOrPath], port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str | list[str]] = None, loop: Optional[IOLoop] = None, show: bool = True, start: bool = True, title: Optional[str] = None, verbose: bool = True, location: bool = True, threaded: bool = False, admin: bool = False, **kwargs) StoppableThread | Server [source]#
Allows serving one or more panel objects on a single server. The panels argument should be either a Panel object or a function returning a Panel object or a dictionary of these two. If a dictionary is supplied the keys represent the slugs at which each app is served, e.g. serve({‘app’: panel1, ‘app2’: panel2}) will serve apps at /app and /app2 on the server.
Reference: https://panel.holoviz.org/user_guide/Server_Configuration.html#serving-multiple-apps
- Parameters:
panel (Viewable, function or {str: Viewable or function}) – A Panel object, a function returning a Panel object or a dictionary mapping from the URL slug to either.
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) –
A list of hosts that can connect to the websocket.
This is typically required when embedding a server app in an external web site.
If None, “localhost” is used.
loop (tornado.ioloop.IOLoop (optional, default=IOLoop.current())) – The tornado IOLoop to run the Server on
show (boolean (optional, default=True)) – Whether to open the server in a new browser tab on start
start (boolean(optional, default=True)) – Whether to start the Server
title (str or {str: str} (optional, default=None)) – An HTML title for the application or a dictionary mapping from the URL slug to a customized title
verbose (boolean (optional, default=True)) – Whether to print the address and port
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
threaded (boolean (default=False)) – Whether to start the server on a new Thread
admin (boolean (default=False)) – Whether to enable the admin panel
kwargs (dict) – Additional keyword arguments to pass to Server instance
- class panel.__init__.widget(*, name)[source]#
Bases:
ParameterizedFunction
Attempts to find a widget appropriate for a given value.
- Parameters:
name (str) – The name of the resulting widget.
value (Any) – The value to deduce a widget from.
default (Any) – The default value for the resulting widget.
**params (Any) – Additional keyword arguments to pass to the widget.
- Return type:
- classmethod instance(**params)[source]#
Return an instance of this class, copying parameters from any existing instance provided.
- static widget_from_iterable(o, name)[source]#
Make widgets from an iterable. This should not be done for a string or tuple.