panel.widgets Package#


widgets Package#

Panel widgets makes your data exploration and apps interactive#

Panel provides a long range of basic and specialized widgets.

Check out the widget gallery https://panel.holoviz.org/reference/index.html#widgets for inspiration.

How to use Panel widgets in 4 simple steps#

  1. Define your function

>>> def my_func(value1, value2):
...    ...
...    return some_python_object
  1. Define your widgets

>>> widget1 = pn.widgets.SomeWidget(value=..., ...).servable(area='sidebar')
>>> widget2 = pn.widgets.AnotherWidget(value=..., ...).servable(area='sidebar')
  1. Bind the function to your widgets

>>> interactive_func = pn.bind(my_func, value1=widget1, value2=widget2)
  1. Layout your interactive function in a panel, Column, Row or similar

>>> pn.panel(interactive_func).servable()

For more detail see the Getting Started Guide https://panel.holoviz.org/getting_started/index.html

class panel.widgets.ArrayInput(*, max_array_size, description, placeholder, serializer, type, value, disabled, 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: LiteralInput

The ArrayInput allows rendering and editing NumPy arrays in a text input widget.

Arrays larger than the max_array_size will be summarized and editing will be disabled.

Reference: https://panel.holoviz.org/reference/widgets/ArrayInput.html

Example:

>>> To be determined ...

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

panel.widgets.input.LiteralInput: width, description, placeholder, serializer, type, value

max_array_size = param.Number(allow_refs=False, default=1000, inclusive_bounds=(True, True), label=’Max array size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304bd6990>)

Arrays larger than this limit will be allowed in Python but will not be serialized into JavaScript. Although such large arrays will thus not be editable in the widget, such a restriction helps avoid overwhelming the browser and lets other widgets remain usable.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.AutocompleteInput(*, case_sensitive, description, min_characters, options, placeholder, restrict, search_strategy, value, value_input, disabled, 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: Widget

The MultiChoice widget allows selecting multiple values from a list of options.

It falls into the broad category of multi-value, option-selection widgets that provide a compatible API and include the MultiSelect, CrossSelector, CheckBoxGroup and CheckButtonGroup widgets.

The MultiChoice widget provides a much more compact UI than MultiSelect.

Reference: https://panel.holoviz.org/reference/widgets/AutocompleteInput.html

Example:

>>> AutocompleteInput(
...     name='Study', options=['Biology', 'Chemistry', 'Physics'],
...     placeholder='Write your study here ...'
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

width = param.Integer(allow_None=True, allow_refs=False, bounds=(0, None), default=300, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30513b190>)

Width of this component. If sizing_mode is set to stretch or scale mode this will merely be used as a suggestion.

case_sensitive = param.Boolean(allow_refs=False, default=True, label=’Case sensitive’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30513b990>)

Enable or disable case sensitivity.

min_characters = param.Integer(allow_refs=False, default=2, inclusive_bounds=(True, True), label=’Min characters’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30513b9d0>)

The number of characters a user must type before completions are presented.

options = param.List(allow_refs=False, bounds=(0, None), default=[], label=’Options’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x305138290>)

A list of completion strings. This will be used to guide the user upon typing the beginning of a desired value.

placeholder = param.String(allow_refs=False, default=’’, label=’Placeholder’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30507ba50>)

Placeholder for empty input field.

restrict = param.Boolean(allow_refs=False, default=True, label=’Restrict’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x305139a50>)

Set to False in order to allow users to enter text that is not present in the list of completion strings.

search_strategy = param.Selector(allow_refs=False, default=’starts_with’, label=’Search strategy’, names={}, nested_refs=False, objects=[‘starts_with’, ‘includes’], rx=<param.reactive.reactive_ops object at 0x30513ab90>)

Define how to search the list of completion strings. The default option “starts_with” means that the user’s text must match the start of a completion string. Using “includes” means that the user’s text can match any substring of a completion string.

value = param.String(allow_None=True, allow_refs=False, default=’’, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3051396d0>)

Initial or entered text value updated when <enter> key is pressed.

value_input = param.String(allow_None=True, allow_refs=False, default=’’, label=’Value input’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30513aa10>)

Initial or entered text value updated on every key press.

description = param.String(allow_None=True, allow_refs=False, label=’Description’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30513ab10>)

An HTML string describing the function of this component.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.BooleanStatus(*, color, throttle, value, disabled, 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: BooleanIndicator

The BooleanStatus is a boolean indicator providing a visual representation of a boolean status as filled or non-filled circle.

If the value is set to True the indicator will be filled while setting it to False will cause it to be non-filled.

Reference: https://panel.holoviz.org/reference/indicators/BooleanStatus.html

Example:

>>> BooleanStatus(value=True, color='primary', width=100, height=100)

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: margin, disabled

panel.widgets.indicators.Indicator: sizing_mode

panel.widgets.indicators.BooleanIndicator: throttle

height = param.Integer(allow_refs=False, bounds=(0, None), default=20, inclusive_bounds=(True, True), label=’Height’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30503c550>)

height of the circle.

width = param.Integer(allow_refs=False, bounds=(0, None), default=20, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x305033d50>)

Width of the circle.

value = param.Boolean(allow_refs=False, default=False, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30503c290>)

Whether the indicator is active or not.

color = param.ObjectSelector(allow_refs=False, default=’dark’, label=’Color’, names={}, nested_refs=False, objects=[‘primary’, ‘secondary’, ‘success’, ‘info’, ‘danger’, ‘warning’, ‘light’, ‘dark’], rx=<param.reactive.reactive_ops object at 0x30503dad0>)

The color of the circle, one of ‘primary’, ‘secondary’, ‘success’, ‘info’, ‘danger’, ‘warning’, ‘light’, ‘dark’

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.Button(*, clicks, value, button_style, button_type, icon, icon_size, description, description_delay, disabled, 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: _ButtonBase, _ClickButton, IconMixin, TooltipMixin

The Button widget allows triggering events when the button is clicked.

The Button provides a value parameter, which will toggle from False to True while the click event is being processed

It also provides an additional clicks parameter, that can be watched to subscribe to click events.

Reference: https://panel.holoviz.org/reference/widgets/Button.html#widgets-gallery-button

Example:

>>> pn.widgets.Button(name='Click me', icon='caret-right', button_type='primary')

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets._mixin.TooltipMixin: description, description_delay

panel.widgets.button.IconMixin: icon, icon_size

panel.widgets.button._ButtonBase: button_type, button_style

clicks = param.Integer(allow_refs=True, default=0, inclusive_bounds=(True, True), label=’Clicks’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304fd0350>)

Number of clicks (can be listened to)

value = param.Event(allow_refs=True, default=False, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3010a3fd0>)

Toggles from False to True while the event is being processed.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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

js_on_click(args: Dict[str, Any] = {}, code: str = '') Callback[source]#

Allows defining a JS callback to be triggered when the button is clicked.

Parameters:
  • args (dict) – A mapping of objects to make available to the JS callback

  • code (str) – The Javascript code to execute when the button is clicked.

Returns:

callback – The Callback which can be used to disable the callback.

Return type:

Callback

jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback[source]#

Allows defining a Javascript (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:

Callback

Links properties on the this Button to those on the target object in Javascript (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(s) 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. Default is False.

  • **links (dict[str,str]) – A mapping between properties on the source model and the target model property to link it to.

Returns:

The Link can be used unlink the widget and the target model.

Return type:

Link

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_click(callback: Callable[[Event], Union[None, Awaitable[None]]]) Watcher[source]#

Register a callback to be executed when the Button is clicked.

The callback is given an Event argument declaring the number of clicks

Example

>>> button = pn.widgets.Button(name='Click me')
>>> def handle_click(event):
...    print("I was clicked!")
>>> button.on_click(handle_click)
Parameters:

callback – The function to run on click events. Must accept a positional Event argument. Can be a sync or async function

Returns:

watcher – A Watcher that executes the callback when the button is clicked.

Return type:

param.Parameterized.Watcher

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.widgets.ButtonIcon(*, clicks, toggle_duration, active_icon, icon, size, value, description, description_delay, disabled, 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: _ClickableIcon, _ClickButton, TooltipMixin

The ButtonIcon widget facilitates event triggering upon button clicks.

This widget displays a default icon initially. Upon being clicked, an active_icon appears for a specified toggle_duration.

For instance, the ButtonIcon can be effectively utilized to implement a feature akin to ChatGPT’s copy-to-clipboard button.

The button incorporates a value attribute, which alternates between False and True as the click event is processed.

Furthermore, it includes an clicks attribute, enabling subscription to click events for further actions or monitoring.

Reference: https://panel.holoviz.org/reference/widgets/ButtonIcon.html

Example:

>>> button_icon = pn.widgets.ButtonIcon(
...     icon='clipboard',
...     active_icon='check',
...     description='Copy',
...     toggle_duration=2000
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets._mixin.TooltipMixin: description, description_delay

panel.widgets.icon._ClickableIcon: active_icon, icon, size

value = param.Boolean(allow_refs=False, default=False, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x305165f10>)

Toggles from False to True while the event is being processed.

clicks = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Clicks’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x305167290>)

The number of times the button has been clicked.

toggle_duration = param.Integer(allow_refs=False, default=75, inclusive_bounds=(True, True), label=’Toggle duration’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x305164310>)

The number of milliseconds the active_icon should be shown for and how long the button should be disabled for.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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

js_on_click(args: Dict[str, Any] = {}, code: str = '') Callback[source]#

Allows defining a JS callback to be triggered when the button is clicked.

Parameters:
  • args (dict) – A mapping of objects to make available to the JS callback

  • code (str) – The Javascript code to execute when the button is clicked.

Returns:

callback – The Callback which can be used to disable the callback.

Return type:

Callback

jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback[source]#

Allows defining a Javascript (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:

Callback

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

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_click(callback: Callable[[Event], None]) Watcher[source]#

Register a callback to be executed when the button is clicked.

The callback is given an Event argument declaring the number of clicks.

Parameters:

callback ((Callable[[param.parameterized.Event], None])) – The function to run on click events. Must accept a positional Event argument

Returns:

watcher – A Watcher that executes the callback when the MenuButton is clicked.

Return type:

param.Parameterized.Watcher

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.widgets.CheckBoxGroup(*, inline, value, options, disabled, 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: _CheckGroupBase

The CheckBoxGroup widget allows selecting between a list of options by ticking the corresponding checkboxes.

It falls into the broad category of multi-option selection widgets that provide a compatible API and include the MultiSelect, CrossSelector and CheckButtonGroup widgets.

Reference: https://panel.holoviz.org/reference/widgets/CheckBoxGroup.html

Example:

>>> CheckBoxGroup(
...     name='Fruits', value=['Apple', 'Pear'], options=['Apple', 'Banana', 'Pear', 'Strawberry'],
...     inline=True
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.select.SelectBase: options

panel.widgets.select._CheckGroupBase: value

inline = param.Boolean(allow_refs=False, default=False, label=’Inline’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3050de410>)

Whether the items be arrange vertically (False) or horizontally in-line (True).

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.CheckButtonGroup(*, orientation, value, options, button_style, button_type, description, description_delay, disabled, 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: _CheckGroupBase, _ButtonBase, TooltipMixin

The CheckButtonGroup widget allows selecting between a list of options by toggling the corresponding buttons.

It falls into the broad category of multi-option selection widgets that provide a compatible API and include the MultiSelect, CrossSelector and CheckBoxGroup widgets.

Reference: https://panel.holoviz.org/reference/widgets/CheckButtonGroup.html

Example:

>>> CheckButtonGroup(
...     name='Regression Models', value=['Lasso', 'Ridge'],
...     options=['Lasso', 'Linear', 'Ridge', 'Polynomial']
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets._mixin.TooltipMixin: description, description_delay

panel.widgets.button._ButtonBase: button_type, button_style

panel.widgets.select.SelectBase: options

panel.widgets.select._CheckGroupBase: value

orientation = param.Selector(allow_refs=False, default=’horizontal’, label=’Orientation’, names={}, nested_refs=False, objects=[‘horizontal’, ‘vertical’], rx=<param.reactive.reactive_ops object at 0x165398bd0>)

Button group orientation, either ‘horizontal’ (default) or ‘vertical’.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.Checkbox(*, value, disabled, 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: _BooleanWidget

The Checkbox allows toggling a single condition between True/False states by ticking a checkbox.

This widget is interchangeable with the Toggle widget.

Reference: https://panel.holoviz.org/reference/widgets/Checkbox.html

Example:

>>> Checkbox(name='Works with the tools you know and love', value=True)

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.input._BooleanWidget: value

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.CodeEditor(*, annotations, filename, language, print_margin, readonly, theme, value, disabled, 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: Widget

The CodeEditor widget allows displaying and editing code in the powerful Ace editor.

Reference: https://panel.holoviz.org/reference/widgets/CodeEditor.html

Example:

>>> CodeEditor(value=py_code, language='python', theme='monokai')

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

annotations = param.List(allow_refs=False, bounds=(0, None), default=[], label=’Annotations’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304e47e10>)

List of annotations to add to the editor.

filename = param.String(allow_refs=False, default=’’, label=’Filename’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3050e4310>)

Filename from which to deduce language

language = param.String(allow_refs=False, default=’text’, label=’Language’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304e2f550>)

Language of the editor

print_margin = param.Boolean(allow_refs=False, default=False, label=’Print margin’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3050e5c10>)

Whether to show the a print margin.

readonly = param.Boolean(allow_refs=False, default=False, label=’Readonly’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304e2ef90>)

Define if editor content can be modified. Alias for disabled.

theme = param.ObjectSelector(allow_refs=False, default=’chrome’, label=’Theme’, names={}, nested_refs=False, objects=[‘ambiance’, ‘chaos’, ‘chrome’, ‘clouds’, ‘clouds_midnight’, ‘cobalt’, ‘crimson_editor’, ‘dawn’, ‘dracula’, ‘dreamweaver’, ‘eclipse’, ‘github’, ‘gob’, ‘gruvbox’, ‘idle_fingers’, ‘iplastic’, ‘katzenmilch’, ‘kr_theme’, ‘kuroir’, ‘merbivore’, ‘merbivore_soft’, ‘mono_industrial’, ‘monokai’, ‘pastel_on_dark’, ‘solarized_dark’, ‘solarized_light’, ‘sqlserver’, ‘terminal’, ‘textmate’, ‘tomorrow’, ‘tomorrow_night’, ‘tomorrow_night_blue’, ‘tomorrow_night_bright’, ‘tomorrow_night_eighties’, ‘twilight’, ‘vibrant_ink’, ‘xcode’], rx=<param.reactive.reactive_ops object at 0x3050e4290>)

Theme of the editor

value = param.String(allow_refs=False, default=’’, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304e2ef90>)

State of the current code in the editor

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.ColorPicker(*, description, value, disabled, 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: Widget

The ColorPicker widget allows selecting a hexadecimal RGB color value using the browser’s color-picking widget.

Reference: https://panel.holoviz.org/reference/widgets/ColorPicker.html

Example:

>>> ColorPicker(name='Color', value='#99ef78')

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

width = param.Integer(allow_None=True, allow_refs=False, bounds=(0, None), default=52, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304c53b90>)

Width of this component. If sizing_mode is set to stretch or scale mode this will merely be used as a suggestion.

description = param.String(allow_None=True, allow_refs=False, label=’Description’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304f78210>)

An HTML string describing the function of this component.

value = param.Color(allow_None=True, allow_named=True, allow_refs=False, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304f513d0>)

The selected color

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.CompositeWidget(*, disabled, 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: Widget

A baseclass for widgets which are made up of two or more other widgets

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.CrossSelector(*, definition_order, filter_fn, size, description, value, options, disabled, 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: CompositeWidget, MultiSelect

A composite widget which allows selecting from a list of items by moving them between two lists. Supports filtering values by name to select them in bulk.

Reference: https://panel.holoviz.org/reference/widgets/CrossSelector.html

Example:

>>> CrossSelector(
...     name='Fruits', value=['Apple', 'Pear'],
...     options=['Apple', 'Banana', 'Pear', 'Strawberry']
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: margin, disabled

panel.widgets.select.SelectBase: options

panel.widgets.select._MultiSelectBase: value, description

height = param.Integer(allow_None=True, allow_refs=False, bounds=(0, None), default=200, inclusive_bounds=(True, True), label=’Height’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304ce5710>)

The number of options shown at once (note this is the only way to control the height of this widget)

width = param.Integer(allow_None=True, allow_refs=False, bounds=(0, None), default=600, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304c71210>)

The number of options shown at once (note this is the only way to control the height of this widget)

size = param.Integer(allow_refs=False, default=10, inclusive_bounds=(True, True), label=’Size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304ce5690>)

The number of options shown at once (note this is the only way to control the height of this widget)

filter_fn = param.Callable(allow_refs=False, label=’Filter fn’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3050906d0>)

The filter function applied when querying using the text fields, defaults to re.search. Function is two arguments, the query or pattern and the item label.

definition_order = param.Integer(allow_refs=False, default=True, inclusive_bounds=(True, True), label=’Definition order’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304ce53d0>)

Whether to preserve definition order after filtering. Disable to allow the order of selection to define the order of the selected list.

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

filter_fn(string, flags=0)[source]#

Scan through string looking for a match to the pattern, returning a Match object, or None if no match was found.

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.DataFrame(value=None, **params)[source]#

Bases: BaseTable

The DataFrame widget allows displaying and editing a pandas DataFrame.

Note that editing is not possible for multi-indexed DataFrames, in which case you will need to reduce the DataFrame to a single index.

Also note that the DataFrame widget will eventually be replaced with the Tabulator widget, and so new code should be written to use Tabulator instead.

Reference: https://panel.holoviz.org/reference/widgets/DataFrame.html

Example:

>>> DataFrame(df, name='DataFrame')

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.tables.BaseTable: selection, aggregators, editors, formatters, hierarchical, row_height, show_index, sorters, text_align, titles, widths, value

auto_edit = param.Boolean(allow_refs=False, default=False, label=’Auto edit’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304be3550>)

Whether clicking on a table cell automatically starts edit mode.

autosize_mode = param.ObjectSelector(allow_refs=False, default=’force_fit’, label=’Autosize mode’, names={}, nested_refs=False, objects=[‘none’, ‘fit_columns’, ‘fit_viewport’, ‘force_fit’], rx=<param.reactive.reactive_ops object at 0x304bcf0d0>)

Determines the column autosizing mode, as one of the following options: "fit_columns" Compute column widths based on cell contents while ensuring the table fits into the available viewport. This results in no horizontal scrollbar showing up, but data can get unreadable if there is not enough space available. "fit_viewport" Adjust the viewport size after computing column widths based on cell contents. "force_fit" Fit columns into available space dividing the table width across the columns equally (equivalent to fit_columns=True). This results in no horizontal scrollbar showing up, but data can get unreadable if there is not enough space available. "none" Do not automatically compute column widths.

fit_columns = param.Boolean(allow_None=True, allow_refs=False, label=’Fit columns’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304be1890>)

Whether columns should expand to the available width. This results in no horizontal scrollbar showing up, but data can get unreadable if there is no enough space available.

frozen_columns = param.Integer(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Frozen columns’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304bce190>)

Integer indicating the number of columns to freeze. If set, the first N columns will be frozen, which prevents them from scrolling out of frame.

frozen_rows = param.Integer(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Frozen rows’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304c4da10>)

Integer indicating the number of rows to freeze. If set, the first N rows will be frozen, which prevents them from scrolling out of frame; if set to a negative value the last N rows will be frozen.

reorderable = param.Boolean(allow_refs=False, default=True, label=’Reorderable’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304bcf990>)

Allows the reordering of a table’s columns. To reorder a column, click and drag a table’s header to the desired location in the table. The columns on either side will remain in their previous order.

sortable = param.Boolean(allow_refs=False, default=True, label=’Sortable’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304be1890>)

Allows to sort table’s contents. By default natural order is preserved. To sort a column, click on its header. Clicking one more time changes sort direction. Use Ctrl + click to return to natural order. Use Shift + click to sort multiple columns simultaneously.

add_filter(filter, column=None)[source]#

Adds a filter to the table which can be a static value or dynamic parameter based object which will automatically update the table when changed..

When a static value, widget or parameter is supplied the filtering will follow a few well defined behaviors:

  • scalar: Filters by checking for equality

  • tuple: A tuple will be interpreted as range.

  • list: A list will be interpreted as a set of discrete

    scalars and the filter will check if the values in the column match any of the items in the list.

Parameters:
  • filter (Widget, param.Parameter or FunctionType) – The value by which to filter the DataFrame along the declared column, or a function accepting the DataFrame to be filtered and returning a filtered copy of the DataFrame.

  • column (str or None) – Column to which the filter will be applied, if the filter is a constant value, widget or parameter.

Raises:

ValueError – If the filter type is not supported or no column: was declared.

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

property current_view#

Returns the current view of the table after filtering and sorting are applied.

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 from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.

patch(patch_value, as_index=True)[source]#

Efficiently patches (updates) the existing value with the patch_value.

Parameters:
  • patch_value ((pd.DataFrame | pd.Series | Dict)) – The value(s) to patch the existing value with.

  • as_index (boolean) – Whether to treat the patch index as DataFrame indexes (True) or as simple integer index.

Raises:

ValueError – Raised if the patch_value is not a supported type.:

Examples

Patch a DataFrame with a Dictionary row. >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> patch_value = {“x”: [(0, 3)]} >>> tabulator.patch(patch_value) >>> tabulator.value.to_dict(“list”) {‘x’: [3, 2], ‘y’: [‘a’, ‘b’]}

Patch a Dataframe with a Dictionary of Columns. >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> patch_value = {“x”: [(slice(2), (3,4))], “y”: [(1,’d’)]} >>> tabulator.patch(patch_value) >>> tabulator.value.to_dict(“list”) {‘x’: [3, 4], ‘y’: [‘a’, ‘d’]}

Patch a DataFrame with a Series. Please note the index is used in the update. >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> patch_value = pd.Series({“index”: 1, “x”: 4, “y”: “d”}) >>> tabulator.patch(patch_value) >>> tabulator.value.to_dict(“list”) {‘x’: [1, 4], ‘y’: [‘a’, ‘d’]}

Patch a Dataframe with a Dataframe. Please note the index is used in the update. >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> patch_value = pd.DataFrame({“x”: [3, 4], “y”: [“c”, “d”]}) >>> tabulator.patch(patch_value) >>> tabulator.value.to_dict(“list”) {‘x’: [3, 4], ‘y’: [‘c’, ‘d’]}

remove_filter(filter)[source]#

Removes a filter which was previously added.

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)

property selected_dataframe#

Returns a DataFrame of the currently selected rows.

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

stream(stream_value, rollover=None, reset_index=True)[source]#

Streams (appends) the stream_value provided to the existing value in an efficient manner.

Parameters:
  • stream_value ((pd.DataFrame | pd.Series | Dict)) – The new value(s) to append to the existing value.

  • rollover (int) – A maximum column size, above which data from the start of the column begins to be discarded. If None, then columns will continue to grow unbounded.

  • reset_index ((bool, default=True)) – If True and the stream_value is a DataFrame, then its index is reset. Helps to keep the index unique and named index

Raises:

ValueError – Raised if the stream_value is not a supported type.:

Examples

Stream a Series to a DataFrame >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> stream_value = pd.Series({“x”: 4, “y”: “d”}) >>> tabulator.stream(stream_value) >>> tabulator.value.to_dict(“list”) {‘x’: [1, 2, 4], ‘y’: [‘a’, ‘b’, ‘d’]}

Stream a Dataframe to a Dataframe >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> stream_value = pd.DataFrame({“x”: [3, 4], “y”: [“c”, “d”]}) >>> tabulator.stream(stream_value) >>> tabulator.value.to_dict(“list”) {‘x’: [1, 2, 3, 4], ‘y’: [‘a’, ‘b’, ‘c’, ‘d’]}

Stream a Dictionary row to a DataFrame >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> stream_value = {“x”: 4, “y”: “d”} >>> tabulator.stream(stream_value) >>> tabulator.value.to_dict(“list”) {‘x’: [1, 2, 4], ‘y’: [‘a’, ‘b’, ‘d’]}

Stream a Dictionary of Columns to a Dataframe >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> stream_value = {“x”: [3, 4], “y”: [“c”, “d”]} >>> tabulator.stream(stream_value) >>> tabulator.value.to_dict(“list”) {‘x’: [1, 2, 3, 4], ‘y’: [‘a’, ‘b’, ‘c’, ‘d’]}

class panel.widgets.DatePicker(*, description, disabled_dates, enabled_dates, end, start, value, disabled, 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: Widget

The DatePicker allows selecting a date value using a text box and a date-picking utility.

Reference: https://panel.holoviz.org/reference/widgets/DatePicker.html

Example:

>>> DatePicker(
...     value=date(2025,1,1),
...     start=date(2025,1,1), end=date(2025,12,31),
...     name='Date'
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

width = param.Integer(allow_None=True, allow_refs=False, bounds=(0, None), default=300, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304ac43d0>)

Width of this component. If sizing_mode is set to stretch or scale mode this will merely be used as a suggestion.

value = param.CalendarDate(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304ad3110>)

The current value

start = param.CalendarDate(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Start’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304ad0a50>)

Inclusive lower bound of the allowed date selection

end = param.CalendarDate(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’End’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304ad1350>)

Inclusive upper bound of the allowed date selection

disabled_dates = param.List(allow_None=True, allow_refs=False, bounds=(0, None), class_=(<class ‘datetime.date’>, <class ‘str’>), item_type=(<class ‘datetime.date’>, <class ‘str’>), label=’Disabled dates’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304ad0dd0>)

enabled_dates = param.List(allow_None=True, allow_refs=False, bounds=(0, None), class_=(<class ‘datetime.date’>, <class ‘str’>), item_type=(<class ‘datetime.date’>, <class ‘str’>), label=’Enabled dates’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304ad3190>)

description = param.String(allow_None=True, allow_refs=False, label=’Description’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304ad0c10>)

An HTML string describing the function of this component.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.DateRangePicker(*, description, disabled_dates, enabled_dates, end, start, value, disabled, 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: Widget

The DateRangePicker allows selecting a date range using a text box and a date-picking utility.

Reference: https://panel.holoviz.org/reference/widgets/DateRangePicker.html

Example:

>>> DateRangePicker(
...     value=(date(2025,1,1), date(2025,1,5)),
...     start=date(2025,1,1), end=date(2025,12,31),
...     name='Date range'
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

width = param.Integer(allow_None=True, allow_refs=False, bounds=(0, None), default=300, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3049ee050>)

Width of this component. If sizing_mode is set to stretch or scale mode this will merely be used as a suggestion.

value = param.DateRange(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Value’, length=2, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304a02450>)

The current value

start = param.CalendarDate(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Start’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3049ed550>)

Inclusive lower bound of the allowed date selection

end = param.CalendarDate(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’End’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304a01050>)

Inclusive upper bound of the allowed date selection

disabled_dates = param.List(allow_None=True, allow_refs=False, bounds=(0, None), class_=(<class ‘datetime.date’>, <class ‘str’>), item_type=(<class ‘datetime.date’>, <class ‘str’>), label=’Disabled dates’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304ad4750>)

enabled_dates = param.List(allow_None=True, allow_refs=False, bounds=(0, None), class_=(<class ‘datetime.date’>, <class ‘str’>), item_type=(<class ‘datetime.date’>, <class ‘str’>), label=’Enabled dates’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304a01910>)

description = param.String(allow_None=True, allow_refs=False, label=’Description’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304ad41d0>)

An HTML string describing the function of this component.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.DateRangeSlider(*, end, format, start, step, value, value_throttled, bar_color, direction, orientation, show_value, tooltips, disabled, 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: _SliderBase

The DateRangeSlider widget allows selecting a date range using a slider with two handles. Supports datetime.datetime, datetime.date and np.datetime64 ranges.

Reference: https://panel.holoviz.org/reference/widgets/DateRangeSlider.html

Example:

>>> import datetime as dt
>>> DateRangeSlider(
...     value=(dt.datetime(2025, 1, 9), dt.datetime(2025, 1, 16)),
...     start=dt.datetime(2025, 1, 1),
...     end=dt.datetime(2025, 1, 31),
...     step=2,
...     name="A tuple of datetimes"
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.slider._SliderBase: bar_color, direction, orientation, show_value, tooltips

value = param.DateRange(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Value’, length=2, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3046b23d0>)

The selected range as a tuple of values. Updated when one of the handles is dragged. Supports datetime.datetime, datetime.date, and np.datetime64 ranges.

value_start = param.Date(allow_None=True, allow_refs=False, constant=True, inclusive_bounds=(True, True), label=’Value start’, nested_refs=False, readonly=True, rx=<param.reactive.reactive_ops object at 0x304a27850>)

The lower value of the selected range.

value_end = param.Date(allow_None=True, allow_refs=False, constant=True, inclusive_bounds=(True, True), label=’Value end’, nested_refs=False, readonly=True, rx=<param.reactive.reactive_ops object at 0x304cebd10>)

The upper value of the selected range.

value_throttled = param.DateRange(allow_None=True, allow_refs=False, constant=True, inclusive_bounds=(True, True), label=’Value throttled’, length=2, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x304a27b90>)

The selected range as a tuple of values. Updated one of the handles is released. Supports datetime.datetime, datetime.date and np.datetime64 ranges

start = param.Date(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Start’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3046b23d0>)

The lower bound.

end = param.Date(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’End’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304a246d0>)

The upper bound.

step = param.Number(allow_refs=False, default=1, inclusive_bounds=(True, True), label=’Step’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3046b0b50>)

The step size in days. Default is 1 day.

format = param.String(allow_None=True, allow_refs=False, label=’Format’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3046b1cd0>)

Datetime format used for parsing and formatting the date.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.DateSlider(*, as_datetime, end, format, start, step, value, value_throttled, bar_color, direction, orientation, show_value, tooltips, disabled, 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: _SliderBase

The DateSlider widget allows selecting a value within a set of bounds using a slider. Supports datetime.datetime, datetime.date and np.datetime64 values. The step size is fixed at 1 day.

Reference: https://panel.holoviz.org/reference/widgets/DateSlider.html

Example:

>>> import datetime as dt
>>> DateSlider(
...     value=dt.datetime(2025, 1, 1),
...     start=dt.datetime(2025, 1, 1),
...     end=dt.datetime(2025, 1, 7),
...     name="A datetime value"
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.slider._SliderBase: bar_color, direction, orientation, show_value, tooltips

value = param.Date(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30495e3d0>)

The selected date value of the slider. Updated when the slider handle is dragged. Supports datetime.datetime, datetime.date or np.datetime64 types.

value_throttled = param.Date(allow_None=True, allow_refs=False, constant=True, inclusive_bounds=(True, True), label=’Value throttled’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3049bd050>)

The value of the slider. Updated when the slider handle is released.

start = param.Date(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Start’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30495e3d0>)

The lower bound.

end = param.Date(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’End’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30491db90>)

The upper bound.

as_datetime = param.Boolean(allow_refs=False, default=False, label=’As datetime’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3049a2890>)

Whether to store the date as a datetime.

step = param.Number(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Step’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30495e890>)

The step parameter in milliseconds.

format = param.String(allow_None=True, allow_refs=False, label=’Format’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3049a2890>)

Datetime format used for parsing and formatting the date.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.DatetimeInput(*, end, format, start, description, placeholder, serializer, type, value, disabled, 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: LiteralInput

The DatetimeInput allows specifying Python datetime like values using a text input widget.

An optional type may be declared.

Reference: https://panel.holoviz.org/reference/widgets/DatetimeInput.html

Example:

>>> DatetimeInput(name='Datetime', value=datetime(2019, 2, 8))

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

panel.widgets.input.LiteralInput: width, description, placeholder, serializer, type

value = param.Date(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304911f50>)

The current value

start = param.Date(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Start’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3047d5b90>)

Inclusive lower bound of the allowed date selection

end = param.Date(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’End’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304911f50>)

Inclusive upper bound of the allowed date selection

format = param.String(allow_refs=False, default=’%Y-%m-%d %H:%M:%S’, label=’Format’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3047b7f90>)

Datetime format used for parsing and formatting the datetime.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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

type[source]#

alias of datetime

class panel.widgets.DatetimePicker(*, mode, value, as_numpy_datetime64, description, disabled_dates, enable_seconds, enable_time, enabled_dates, end, military_time, start, disabled, 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: _DatetimePickerBase

The DatetimePicker allows selecting selecting a datetime value using a textbox and a datetime-picking utility.

Reference: https://panel.holoviz.org/reference/widgets/DatetimePicker.html

Example:

>>> DatetimePicker(
...    value=datetime(2025,1,1,22,0),
...    start=date(2025,1,1), end=date(2025,12,31),
...    military_time=True, name='Date and time'
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

panel.widgets.input._DatetimePickerBase: width, disabled_dates, enabled_dates, enable_time, enable_seconds, end, military_time, start, description, as_numpy_datetime64

value = param.Date(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3047c1550>)

mode = param.String(allow_refs=False, constant=True, default=’single’, label=’Mode’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304796350>)

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.DatetimeRangeInput(*, end, format, start, value, disabled, 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: CompositeWidget

The DatetimeRangeInput widget allows selecting a datetime range using two DatetimeInput widgets, which return a tuple range.

Reference: https://panel.holoviz.org/reference/widgets/DatetimeRangeInput.html

Example:

>>> DatetimeRangeInput(
...     name='Datetime Range',
...     value=(datetime(2017, 1, 1), datetime(2018, 1, 10)),
...     start=datetime(2017, 1, 1), end=datetime(2019, 1, 1),
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

value = param.Tuple(allow_refs=False, default=(None, None), label=’Value’, length=2, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3049707d0>)

The current value

start = param.Date(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Start’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30496cb90>)

Inclusive lower bound of the allowed date selection

end = param.Date(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’End’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3047a7ed0>)

Inclusive upper bound of the allowed date selection

format = param.String(allow_refs=False, default=’%Y-%m-%d %H:%M:%S’, label=’Format’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30496e990>)

Datetime format used for parsing and formatting the datetime.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.DatetimeRangePicker(*, mode, value, as_numpy_datetime64, description, disabled_dates, enable_seconds, enable_time, enabled_dates, end, military_time, start, disabled, 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: _DatetimePickerBase

The DatetimeRangePicker allows selecting selecting a datetime range using a text box and a datetime-range-picking utility.

Reference: https://panel.holoviz.org/reference/widgets/DatetimeRangePicker.html

Example:

>>> DatetimeRangePicker(
...    value=(datetime(2025,1,1,22,0), datetime(2025,1,2,22,0)),
...    start=date(2025,1,1), end=date(2025,12,31),
...    military_time=True, name='Datetime Range'
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

panel.widgets.input._DatetimePickerBase: width, disabled_dates, enabled_dates, enable_time, enable_seconds, end, military_time, start, description, as_numpy_datetime64

value = param.DateRange(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Value’, length=2, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3047a7410>)

The current value

mode = param.String(allow_refs=False, constant=True, default=’range’, label=’Mode’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304746510>)

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.DatetimeRangeSlider(*, end, format, start, step, value, value_throttled, bar_color, direction, orientation, show_value, tooltips, disabled, 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: DateRangeSlider

The DatetimeRangeSlider widget allows selecting a datetime range using a slider with two handles. Supports datetime.datetime and np.datetime64 ranges.

Reference: https://panel.holoviz.org/reference/widgets/DatetimeRangeSlider.html

Example:

>>> import datetime as dt
>>> DatetimeRangeSlider(
...     value=(dt.datetime(2025, 1, 9), dt.datetime(2025, 1, 16)),
...     start=dt.datetime(2025, 1, 1),
...     end=dt.datetime(2025, 1, 31),
...     step=10000,
...     name="A tuple of datetimes"
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.slider._SliderBase: bar_color, direction, orientation, show_value, tooltips

panel.widgets.slider.DateRangeSlider: value, value_start, value_end, value_throttled, start, end, format

step = param.Number(allow_refs=False, default=60000, inclusive_bounds=(True, True), label=’Step’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3045c9c50>)

The step size in ms. Default is 1 min.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.Debugger(*, _number_of_errors, _number_of_infos, _number_of_warnings, formatter_args, level, logger_names, only_last, active_header_background, button_css_classes, collapsed, collapsible, header, header_background, header_color, header_css_classes, hide_header, title, title_css_classes, auto_scroll_limit, scroll_button_threshold, scroll_position, view_latest, scroll, 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: Card

A uneditable Card layout holding a terminal printing out logs from your callbacks. By default, it will only print exceptions. If you want to add your own log, use the panel.callbacks logger within your callbacks: logger = logging.getLogger(‘panel.callbacks’)

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, visible

panel.viewable.Viewable: loading

panel.layout.base.ListLike: objects

panel.layout.base.ListPanel: scroll

panel.layout.base.Column: auto_scroll_limit, scroll_button_threshold, scroll_position, view_latest

panel.layout.card.Card: css_classes, active_header_background, button_css_classes, collapsible, collapsed, header, header_background, header_color, header_css_classes, hide_header, title_css_classes, title

_number_of_errors = param.Integer(allow_refs=False, bounds=(0, None), default=0, inclusive_bounds=(True, True), label=’ number of errors’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3049f66d0>)

Number of logged errors since last acknowledged.

_number_of_warnings = param.Integer(allow_refs=False, bounds=(0, None), default=0, inclusive_bounds=(True, True), label=’ number of warnings’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3045a99d0>)

Number of logged warnings since last acknowledged.

_number_of_infos = param.Integer(allow_refs=False, bounds=(0, None), default=0, inclusive_bounds=(True, True), label=’ number of infos’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304618710>)

Number of logged information since last acknowledged.

only_last = param.Boolean(allow_refs=False, default=True, label=’Only last’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3047c28d0>)

Whether only the last stack is printed or the full.

level = param.Integer(allow_refs=False, default=40, inclusive_bounds=(True, True), label=’Level’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304618710>)

Logging level to print in the debugger terminal.

formatter_args = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={‘fmt’: ‘%(asctime)s [%(name)s - %(levelname)s]: %(message)s’}, label=’Formatter args’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3045ca0d0>)

Arguments to pass to the logging formatter. See the standard python logging libraries.

logger_names = param.List(allow_refs=False, bounds=(1, None), class_=<class ‘str’>, default=[‘panel’], item_type=<class ‘str’>, label=’Logger names’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3049f9110>)

Loggers which will be prompted in the debugger terminal.

append(obj: Any) None[source]#

Appends an object to the layout.

Parameters:

(object) (obj) –

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:

Callback

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

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) –

reverse() None[source]#

Reverses the objects in the layout.

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.widgets.Dial(*, annulus_width, background, bounds, colors, default_color, end_angle, format, label_color, nan_format, needle_color, needle_width, start_angle, tick_size, title_size, unfilled_color, value_size, value, disabled, 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: ValueIndicator

A Dial represents a value in some range as a position on an annular dial. It is similar to a Gauge but more minimal visually.

Reference: https://panel.holoviz.org/reference/indicators/Dial.html

Example:

>>> Dial(name='Speed', value=79, format="{value} km/h", bounds=(0, 200), colors=[(0.4, 'green'), (1, 'red')])

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: margin, disabled

panel.widgets.indicators.Indicator: sizing_mode

height = param.Integer(allow_refs=False, bounds=(1, None), default=250, inclusive_bounds=(True, True), label=’Height’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304a9ddd0>)

The height of the component (in pixels). This can be either fixed or preferred height, depending on height sizing policy.

width = param.Integer(allow_refs=False, bounds=(1, None), default=250, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3049eb1d0>)

The width of the component (in pixels). This can be either fixed or preferred width, depending on width sizing policy.

value = param.Number(allow_None=True, allow_refs=False, default=25, inclusive_bounds=(True, True), label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3046424d0>)

Value to indicate on the dial a value within the declared bounds.

annulus_width = param.Number(allow_refs=False, default=0.2, inclusive_bounds=(True, True), label=’Annulus width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3049eb810>)

Width of the radial annulus as a fraction of the total.

background = param.Parameter(allow_None=True, allow_refs=False, label=’Background’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304a49ad0>)

Background color of the component.

bounds = param.Range(allow_refs=False, default=(0, 100), inclusive_bounds=(True, True), label=’Bounds’, length=2, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304588610>)

The upper and lower bound of the dial.

colors = param.List(allow_None=True, allow_refs=False, bounds=(0, None), label=’Colors’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304643050>)

Color thresholds for the Dial, specified as a list of tuples of the fractional threshold and the color to switch to.

default_color = param.String(allow_refs=False, default=’lightblue’, label=’Default color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304c36010>)

Color of the radial annulus if not color thresholds are supplied.

end_angle = param.Number(allow_refs=False, default=25, inclusive_bounds=(True, True), label=’End angle’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3046400d0>)

Angle at which the dial ends.

format = param.String(allow_refs=False, default=’{value}%’, label=’Format’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304c36010>)

Formatting string for the value indicator and lower/upper bounds.

label_color = param.String(allow_refs=False, default=’black’, label=’Label color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304a49ad0>)

Color for all extraneous labels.

nan_format = param.String(allow_refs=False, default=’-’, label=’Nan format’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304c36010>)

How to format nan values.

needle_color = param.String(allow_refs=False, default=’black’, label=’Needle color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304a494d0>)

Color of the Dial needle.

needle_width = param.Number(allow_refs=False, default=0.1, inclusive_bounds=(True, True), label=’Needle width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304588e50>)

Radial width of the needle.

start_angle = param.Number(allow_refs=False, default=-205, inclusive_bounds=(True, True), label=’Start angle’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3049ea850>)

Angle at which the dial starts.

tick_size = param.String(allow_None=True, allow_refs=False, label=’Tick size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304c36010>)

Font size of the Dial min/max labels.

title_size = param.String(allow_None=True, allow_refs=False, label=’Title size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304a494d0>)

Font size of the Dial title.

unfilled_color = param.String(allow_refs=False, default=’whitesmoke’, label=’Unfilled color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304c36010>)

Color of the unfilled region of the Dial.

value_size = param.String(allow_None=True, allow_refs=False, label=’Value size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304a494d0>)

Font size of the Dial value label.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.DiscretePlayer(*, value, value_throttled, direction, interval, loop_policy, show_loop_controls, step, options, disabled, 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: PlayerBase, SelectBase

The DiscretePlayer provides controls to iterate through a list of discrete options. The speed at which the widget plays is defined by the interval (in milliseconds), but it is also possible to skip items using the step parameter.

Reference: https://panel.holoviz.org/reference/widgets/DiscretePlayer.html

Example:

>>> DiscretePlayer(
...     name='Discrete Player',
...     options=[2, 4, 8, 16, 32, 64, 128], value=32,
...     loop_policy='loop'
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: margin, disabled

panel.widgets.select.SelectBase: options

panel.widgets.player.PlayerBase: height, width, direction, loop_policy, show_loop_controls, step

interval = param.Integer(allow_refs=False, default=500, inclusive_bounds=(True, True), label=’Interval’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30453ac10>)

Interval between updates

value = param.Parameter(allow_None=True, allow_refs=False, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304338550>)

Current player value

value_throttled = param.Parameter(allow_None=True, allow_refs=False, constant=True, label=’Value throttled’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304555910>)

Current player value

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.DiscreteSlider(*, formatter, options, value, value_throttled, bar_color, direction, orientation, show_value, tooltips, disabled, 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: CompositeWidget, _SliderBase

The DiscreteSlider widget allows selecting a value from a discrete list or dictionary of values using a slider.

Reference: https://panel.holoviz.org/reference/widgets/DiscreteSlider.html

Example:

>>> DiscreteSlider(
...     value=0,
...     options=list([0, 1, 2, 4, 8, 16, 32, 64]),
...     name="A discrete value",
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.slider._SliderBase: bar_color, direction, orientation, show_value, tooltips

value = param.Parameter(allow_None=True, allow_refs=False, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304404510>)

The selected value of the slider. Updated when the handle is dragged. Must be one of the options.

value_throttled = param.Parameter(allow_None=True, allow_refs=False, constant=True, label=’Value throttled’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3045546d0>)

The value of the slider. Updated when the handle is released.

options = param.ClassSelector(allow_refs=False, class_=(<class ‘dict’>, <class ‘list’>), default=[], label=’Options’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304404210>)

A list or dictionary of valid options.

formatter = param.String(allow_refs=False, default=’%.3g’, label=’Formatter’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304555590>)

A custom format string. Separate from format parameter since formatting is applied in Python, not via the bokeh TickFormatter.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

property labels#

The list of labels to display

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

property values#

The list of option values

class panel.widgets.EditableFloatSlider(*, fixed_end, fixed_start, editable, end, start, step, value, value_throttled, format, bar_color, direction, orientation, show_value, tooltips, disabled, 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: _EditableContinuousSlider, FloatSlider

The EditableFloatSlider widget allows selecting selecting a numeric floating-point value within a set of bounds using a slider and for more precise control offers an editable number input box.

Reference: https://panel.holoviz.org/reference/widgets/EditableFloatSlider.html

Example:

>>> EditableFloatSlider(
...     value=1.0, start=0.0, end=2.0, step=0.25, name="A float value"
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.slider._SliderBase: bar_color, direction, orientation, tooltips

panel.widgets.slider.ContinuousSlider: format

panel.widgets.slider.FloatSlider: start, end, step, value, value_throttled

panel.widgets.slider._EditableContinuousSlider: editable, show_value

fixed_start = param.Number(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Fixed start’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304426c50>)

A fixed lower bound for the slider and input.

fixed_end = param.Number(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Fixed end’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304445150>)

A fixed upper bound for the slider and input.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.EditableIntSlider(*, fixed_end, fixed_start, editable, end, start, step, value, value_throttled, format, bar_color, direction, orientation, show_value, tooltips, disabled, 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: _EditableContinuousSlider, IntSlider

The EditableIntSlider widget allows selecting selecting an integer value within a set of bounds using a slider and for more precise control offers an editable integer input box.

Reference: https://panel.holoviz.org/reference/widgets/EditableIntSlider.html

Example:

>>> EditableIntSlider(
...     value=2, start=0, end=5, step=1, name="An integer value"
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.slider._SliderBase: bar_color, direction, orientation, tooltips

panel.widgets.slider.ContinuousSlider: format

panel.widgets.slider.IntSlider: start, end, step, value, value_throttled

panel.widgets.slider._EditableContinuousSlider: editable, show_value

fixed_start = param.Integer(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Fixed start’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304468fd0>)

A fixed lower bound for the slider and input.

fixed_end = param.Integer(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Fixed end’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3043ea450>)

A fixed upper bound for the slider and input.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.EditableRangeSlider(*, editable, end, fixed_end, fixed_start, format, start, step, value, value_throttled, bar_color, direction, orientation, show_value, tooltips, disabled, 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: CompositeWidget, _SliderBase

The EditableRangeSlider widget allows selecting a floating-point range using a slider with two handles and for more precise control also offers a set of number input boxes.

Reference: https://panel.holoviz.org/reference/widgets/EditableRangeSlider.html

Example:

>>> EditableRangeSlider(
...      value=(1.0, 1.5), start=0.0, end=2.0, step=0.25, name="A tuple of floats"
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.slider._SliderBase: bar_color, direction, orientation, tooltips

show_value = param.Boolean(allow_refs=False, constant=True, default=False, label=’Show value’, nested_refs=False, readonly=True, rx=<param.reactive.reactive_ops object at 0x3043bc3d0>)

Whether to show the widget value.

value = param.Range(allow_refs=False, default=(0, 1), inclusive_bounds=(True, True), label=’Value’, length=2, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304336b50>)

Current range value. Updated when a handle is dragged.

value_throttled = param.Range(allow_None=True, allow_refs=False, constant=True, inclusive_bounds=(True, True), label=’Value throttled’, length=2, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304337d50>)

The value of the slider. Updated when the handle is released.

start = param.Number(allow_refs=False, default=0.0, inclusive_bounds=(True, True), label=’Start’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3042341d0>)

Lower bound of the range.

end = param.Number(allow_refs=False, default=1.0, inclusive_bounds=(True, True), label=’End’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304337b50>)

Upper bound of the range.

fixed_start = param.Number(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Fixed start’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3042341d0>)

A fixed lower bound for the slider and input.

fixed_end = param.Number(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Fixed end’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3043359d0>)

A fixed upper bound for the slider and input.

step = param.Number(allow_refs=False, default=0.1, inclusive_bounds=(True, True), label=’Step’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3042341d0>)

Slider and number input step.

editable = param.Tuple(allow_refs=False, default=(True, True), label=’Editable’, length=2, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3043bdf90>)

Whether the lower and upper values are editable.

format = param.ClassSelector(allow_refs=False, class_=(<class ‘str’>, <class ‘bokeh.models.formatters.TickFormatter’>), default=’0.0[0000]’, label=’Format’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304237cd0>)

Allows defining a custom format string or bokeh TickFormatter.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.FileDownload(file=None, **params)[source]#

Bases: IconMixin

The FileDownload widget allows a user to download a file.

It works either by sending the file data to the browser on initialization (`embed`=True), or when the button is clicked.

Reference: https://panel.holoviz.org/reference/widgets/FileDownload.html

Example:

>>> FileDownload(file='IntroductionToPanel.ipynb', filename='intro.ipynb')

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.button.IconMixin: icon, icon_size

auto = param.Boolean(allow_refs=False, default=True, label=’Auto’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30425d710>)

Whether to download on the initial click or allow for right-click save as.

button_type = param.ObjectSelector(allow_refs=False, default=’default’, label=’Button type’, names={}, nested_refs=False, objects=[‘default’, ‘primary’, ‘success’, ‘warning’, ‘danger’, ‘light’], rx=<param.reactive.reactive_ops object at 0x30453f750>)

A button theme; should be one of ‘default’ (white), ‘primary’ (blue), ‘success’ (green), ‘info’ (yellow), ‘light’ (light), or ‘danger’ (red).

button_style = param.ObjectSelector(allow_refs=False, default=’solid’, label=’Button style’, names={}, nested_refs=False, objects=[‘solid’, ‘outline’], rx=<param.reactive.reactive_ops object at 0x30425e590>)

A button style to switch between ‘solid’, ‘outline’.

callback = param.Callable(allow_None=True, allow_refs=False, label=’Callback’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3042f8710>)

A callable that returns the file path or file-like object.

data = param.String(allow_None=True, allow_refs=False, label=’Data’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304314a90>)

The data being transferred.

embed = param.Boolean(allow_refs=False, default=False, label=’Embed’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30425dad0>)

Whether to embed the file on initialization.

file = param.Parameter(allow_None=True, allow_refs=False, label=’File’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30425cc10>)

The file, Path, file-like object or file contents to transfer. If the file is not pointing to a file on disk a filename must also be provided.

filename = param.String(allow_None=True, allow_refs=False, label=’Filename’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30425dad0>)

A filename which will also be the default name when downloading the file.

label = param.String(allow_refs=False, default=’Download file’, label=’Label’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30425cc10>)

The label of the download button

description = param.String(allow_None=True, allow_refs=False, label=’Description’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30425da50>)

An HTML string describing the function of this component.

_clicks = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’ clicks’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304476dd0>)

_transfers = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’ transfers’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3044759d0>)

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.FileInput(*, accept, description, filename, mime_type, multiple, value, disabled, 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: Widget

The FileInput allows the user to upload one or more files to the server.

It makes the filename, MIME type and (bytes) content available in Python.

Please note

  • you can in fact drag and drop files onto the FileInput.

  • you easily save the files using the save method.

Reference: https://panel.holoviz.org/reference/widgets/FileInput.html

Example:

>>> FileInput(accept='.png,.jpeg', multiple=True)

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

accept = param.String(allow_None=True, allow_refs=False, label=’Accept’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3041eed90>)

description = param.String(allow_None=True, allow_refs=False, label=’Description’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3042a3490>)

An HTML string describing the function of this component.

filename = param.ClassSelector(allow_None=True, allow_refs=False, class_=(<class ‘str’>, <class ‘list’>), label=’Filename’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3041eed90>)

mime_type = param.ClassSelector(allow_None=True, allow_refs=False, class_=(<class ‘str’>, <class ‘list’>), label=’Mime type’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3042a29d0>)

multiple = param.Boolean(allow_refs=False, default=False, label=’Multiple’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3041eed90>)

value = param.Parameter(allow_None=True, allow_refs=False, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3042a3490>)

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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)[source]#

Saves the uploaded FileInput data object(s) to file(s) or BytesIO object(s).

Parameters:

list[str]) (filename (str or) –

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.widgets.FileSelector(directory: Optional[Union[AnyStr, PathLike]] = None, **params)[source]#

Bases: CompositeWidget

The FileSelector widget allows browsing the filesystem on the server and selecting one or more files in a directory.

Reference: https://panel.holoviz.org/reference/widgets/FileSelector.html

Example:

>>> FileSelector(directory='~', file_pattern='*.png')

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

directory = param.String(allow_refs=False, default=’/Users/runner/work/panel/panel/doc’, label=’Directory’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30431dad0>)

The directory to explore.

file_pattern = param.String(allow_refs=False, default=’*’, label=’File pattern’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30445f510>)

A glob-like pattern to filter the files.

only_files = param.Boolean(allow_refs=False, default=False, label=’Only files’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30431cf10>)

Whether to only allow selecting files.

show_hidden = param.Boolean(allow_refs=False, default=False, label=’Show hidden’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30431d6d0>)

Whether to show hidden files and directories (starting with a period).

size = param.Integer(allow_refs=False, default=10, inclusive_bounds=(True, True), label=’Size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30445f450>)

The number of options shown at once (note this is the only way to control the height of this widget)

refresh_period = param.Integer(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Refresh period’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30428eed0>)

If set to non-None value indicates how frequently to refresh the directory contents in milliseconds.

root_directory = param.String(allow_None=True, allow_refs=False, label=’Root directory’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30431dad0>)

If set, overrides directory parameter as the root directory beyond which users cannot navigate.

value = param.List(allow_refs=False, bounds=(0, None), default=[], label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30431f150>)

List of selected files.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.FloatInput(*, step, value_throttled, page_step_multiplier, wheel_wait, mode, description, end, format, placeholder, start, value, disabled, 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: _SpinnerBase, _FloatInputBase

The FloatInput allows selecting a floating point value using a spinbox.

It behaves like a slider except that the lower and upper bounds are optional and a specific value can be entered. The value can be changed using the keyboard (up, down, page up, page down), mouse wheel and arrow buttons.

Reference: https://panel.holoviz.org/reference/widgets/FloatInput.html

Example:

>>> FloatInput(name='Value', value=5., step=1e-1, start=0, end=10)

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

panel.widgets.input._NumericInputBase: description, format

panel.widgets.input._FloatInputBase: value, start, end, mode

panel.widgets.input._SpinnerBase: width, page_step_multiplier, wheel_wait

placeholder = param.String(allow_refs=False, default=’’, label=’Placeholder’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30426e110>)

Placeholder when the value is empty.

step = param.Number(allow_refs=False, default=0.1, inclusive_bounds=(True, True), label=’Step’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3041cf990>)

The step size.

value_throttled = param.Number(allow_None=True, allow_refs=False, constant=True, inclusive_bounds=(True, True), label=’Value throttled’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3041cf5d0>)

The current value. Updates only on <enter> or when the widget looses focus.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.FloatSlider(*, end, start, step, value, value_throttled, format, bar_color, direction, orientation, show_value, tooltips, disabled, 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: ContinuousSlider

The FloatSlider widget allows selecting a floating-point value within a set of bounds using a slider.

Reference: https://panel.holoviz.org/reference/widgets/FloatSlider.html

Example:

>>> FloatSlider(value=0.5, start=0.0, end=1.0, step=0.1, name="Float value")

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.slider._SliderBase: bar_color, direction, orientation, show_value, tooltips

panel.widgets.slider.ContinuousSlider: format

start = param.Number(allow_refs=False, default=0.0, inclusive_bounds=(True, True), label=’Start’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3041cffd0>)

The lower bound.

end = param.Number(allow_refs=False, default=1.0, inclusive_bounds=(True, True), label=’End’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3041de110>)

The upper bound.

step = param.Number(allow_refs=False, default=0.1, inclusive_bounds=(True, True), label=’Step’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3041cf5d0>)

The step size.

value = param.Number(allow_None=True, allow_refs=False, default=0.0, inclusive_bounds=(True, True), label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3041df250>)

The selected floating-point value of the slider. Updated when the handle is dragged.

value_throttled = param.Number(allow_None=True, allow_refs=False, constant=True, inclusive_bounds=(True, True), label=’Value throttled’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3041ced10>)

The value of the slider. Updated when the handle is released.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.Gauge(*, annulus_width, bounds, colors, custom_opts, end_angle, format, num_splits, show_labels, show_ticks, start_angle, title_size, tooltip_format, value, disabled, 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: ValueIndicator

A Gauge represents a value in some range as a position on speedometer or gauge. It is similar to a Dial but visually a lot busier.

Reference: https://panel.holoviz.org/reference/indicators/Gauge.html

Example:

>>> Gauge(name='Speed', value=79, bounds=(0, 200), colors=[(0.4, 'green'), (1, 'red')])

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: margin, disabled

panel.widgets.indicators.Indicator: sizing_mode

height = param.Integer(allow_refs=False, bounds=(0, None), default=300, inclusive_bounds=(True, True), label=’Height’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3040a5dd0>)

The height of the component (in pixels). This can be either fixed or preferred height, depending on height sizing policy.

width = param.Integer(allow_refs=False, bounds=(0, None), default=300, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3040a9a10>)

The width of the component (in pixels). This can be either fixed or preferred width, depending on width sizing policy.

value = param.Number(allow_refs=False, default=25, inclusive_bounds=(True, True), label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3040a5c10>)

Value to indicate on the gauge a value within the declared bounds.

annulus_width = param.Integer(allow_refs=False, default=10, inclusive_bounds=(True, True), label=’Annulus width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3040a9bd0>)

Width of the gauge annulus.

bounds = param.Range(allow_refs=False, default=(0, 100), inclusive_bounds=(True, True), label=’Bounds’, length=2, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3041de750>)

The upper and lower bound of the dial.

colors = param.List(allow_None=True, allow_refs=False, bounds=(0, None), label=’Colors’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3040a9210>)

Color thresholds for the Gauge, specified as a list of tuples of the fractional threshold and the color to switch to.

custom_opts = param.Dict(allow_None=True, allow_refs=False, class_=<class ‘dict’>, label=’Custom opts’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3044a6090>)

Additional options to pass to the ECharts Gauge definition.

end_angle = param.Number(allow_refs=False, default=-45, inclusive_bounds=(True, True), label=’End angle’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3040a9210>)

Angle at which the gauge ends.

format = param.String(allow_refs=False, default=’{value}%’, label=’Format’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3044a6090>)

Formatting string for the value indicator.

num_splits = param.Integer(allow_refs=False, default=10, inclusive_bounds=(True, True), label=’Num splits’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3040a9390>)

Number of splits along the gauge.

show_ticks = param.Boolean(allow_refs=False, default=True, label=’Show ticks’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3041de750>)

Whether to show ticks along the dials.

show_labels = param.Boolean(allow_refs=False, default=True, label=’Show labels’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3040a6b90>)

Whether to show tick labels along the dials.

start_angle = param.Number(allow_refs=False, default=225, inclusive_bounds=(True, True), label=’Start angle’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3040a96d0>)

Angle at which the gauge starts.

tooltip_format = param.String(allow_refs=False, default=’{b}{c}%’, label=’Tooltip format’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3040a6b90>)

Formatting string for the hover tooltip.

title_size = param.Integer(allow_refs=False, default=18, inclusive_bounds=(True, True), label=’Title size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3040a8b90>)

Size of title font.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.Grammar(*, src, uri, weight, name)[source]#

Bases: Parameterized

A set of words or patterns of words that we want the speech recognition service to recognize

For example

grammar = Grammar(

src=’#JSGF V1.0; grammar colors; public <color> = aqua | azure | beige;’, weight=0.7

)

Wraps the HTML SpeechGrammar API. See https://developer.mozilla.org/en-US/docs/Web/API/SpeechGrammar

src = param.String(allow_refs=False, default=’’, label=’Src’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303fbfdd0>)

A set of words or patterns of words that we want the recognition service to recognize. Defined using JSpeech Grammar Format. See https://www.w3.org/TR/jsgf/.

uri = param.String(allow_refs=False, default=’’, label=’Uri’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303fbf150>)

An uri pointing to the definition. If src is available it will be used. Otherwise uri. The uri will be loaded on the client side only.

weight = param.Number(allow_refs=False, bounds=(0.0, 1.0), default=1, inclusive_bounds=(True, True), label=’Weight’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303e77dd0>, step=0.01)

The weight of the grammar. A number in the range 0–1. Default is 1.

serialize()[source]#

Returns the grammar as dict

class panel.widgets.GrammarList(iterable=(), /)[source]#

Bases: list

A list of Grammar objects containing words or patterns of words that we want the recognition service to recognize.

Example:

grammar = ‘#JSGF V1.0; grammar colors; public <color> = aqua | azure | beige | bisque ;’ grammar_list = GrammarList() grammar_list.add_from_string(grammar, 1)

Wraps the HTML 5 SpeechGrammarList API

See https://developer.mozilla.org/en-US/docs/Web/API/SpeechGrammarList

add_from_string(src, weight=1.0)[source]#

Takes a src and weight and adds it to the GrammarList as a new Grammar object. The new Grammar object is returned.

add_from_uri(uri, weight=1.0)[source]#

Takes a grammar present at a specific uri, and adds it to the GrammarList as a new Grammar object. The new Grammar object is returned.

append(object, /)#

Append object to the end of the list.

clear()#

Remove all items from list.

copy()#

Return a shallow copy of the list.

count(value, /)#

Return number of occurrences of value.

extend(iterable, /)#

Extend list by appending elements from the iterable.

index(value, start=0, stop=9223372036854775807, /)#

Return first index of value.

Raises ValueError if the value is not present.

insert(index, object, /)#

Insert object before index.

pop(index=-1, /)#

Remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove(value, /)#

Remove first occurrence of value.

Raises ValueError if the value is not present.

reverse()#

Reverse IN PLACE.

serialize()[source]#

Returns a list of serialized grammars

sort(*, key=None, reverse=False)#

Sort the list in ascending order and return None.

The sort is in-place (i.e. the list itself is modified) and stable (i.e. the order of two equal elements is maintained).

If a key function is given, apply it once to each list item and sort them, ascending or descending, according to their function values.

The reverse flag can be set to sort in descending order.

class panel.widgets.IntInput(*, step, value_throttled, page_step_multiplier, wheel_wait, mode, description, end, format, placeholder, start, value, disabled, 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: _SpinnerBase, _IntInputBase

The IntInput allows selecting an integer value using a spinbox.

It behaves like a slider except that lower and upper bounds are optional and a specific value can be entered. The value can be changed using the keyboard (up, down, page up, page down), mouse wheel and arrow buttons.

Reference: https://panel.holoviz.org/reference/widgets/IntInput.html

Example:

>>> IntInput(name='Value', value=100, start=0, end=1000, step=10)

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

panel.widgets.input._NumericInputBase: description, placeholder, format

panel.widgets.input._IntInputBase: value, start, end, mode

panel.widgets.input._SpinnerBase: width, page_step_multiplier, wheel_wait

step = param.Integer(allow_refs=False, default=1, inclusive_bounds=(True, True), label=’Step’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303f8d0d0>)

The step size.

value_throttled = param.Integer(allow_None=True, allow_refs=False, constant=True, inclusive_bounds=(True, True), label=’Value throttled’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303fac710>)

The current value. Updates only on <enter> or when the widget looses focus.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.IntRangeSlider(*, end, format, start, step, value_throttled, value, bar_color, direction, orientation, show_value, tooltips, disabled, 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: RangeSlider

The IntRangeSlider widget allows selecting an integer range using a slider with two handles.

Reference: https://panel.holoviz.org/reference/widgets/IntRangeSlider.html

Example:

>>> IntRangeSlider(
...     value=(2, 4), start=0, end=10, step=2, name="A tuple of integers"
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.slider._SliderBase: bar_color, direction, orientation, show_value, tooltips

panel.widgets.slider.RangeSlider: value, value_start, value_end, value_throttled, format

start = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Start’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303ec2090>)

The lower bound.

end = param.Integer(allow_refs=False, default=1, inclusive_bounds=(True, True), label=’End’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303fac690>)

The upper bound.

step = param.Integer(allow_refs=False, default=1, inclusive_bounds=(True, True), label=’Step’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303ec3e50>)

The step size

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.IntSlider(*, end, start, step, value, value_throttled, format, bar_color, direction, orientation, show_value, tooltips, disabled, 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: ContinuousSlider

The IntSlider widget allows selecting an integer value within a set of bounds using a slider.

Reference: https://panel.holoviz.org/reference/widgets/IntSlider.html

Example:

>>> IntSlider(value=5, start=0, end=10, step=1, name="Integer Value")

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.slider._SliderBase: bar_color, direction, orientation, show_value, tooltips

panel.widgets.slider.ContinuousSlider: format

start = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Start’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303ef8050>)

The lower bound.

end = param.Integer(allow_refs=False, default=1, inclusive_bounds=(True, True), label=’End’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303eb0590>)

The upper bound.

step = param.Integer(allow_refs=False, default=1, inclusive_bounds=(True, True), label=’Step’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303efa0d0>)

The step size.

value = param.Integer(allow_None=True, allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303eb0290>)

The selected integer value of the slider. Updated when the handle is dragged.

value_throttled = param.Integer(allow_None=True, allow_refs=False, constant=True, inclusive_bounds=(True, True), label=’Value throttled’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303ef8210>)

The value of the slider. Updated when the handle is released

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.JSONEditor(*, menu, mode, schema, search, selection, templates, value, disabled, 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: Widget

The JSONEditor provides a visual editor for JSON-serializable datastructures, e.g. Python dictionaries and lists, with functionality for different editing modes, inserting objects and validation using JSON Schema.

Reference: https://panel.holoviz.org/reference/widgets/JSONEditor.html

Example:

>>> JSONEditor(value={
...     'dict'  : {'key': 'value'},
...     'float' : 3.14,
...     'int'   : 1,
...     'list'  : [1, 2, 3],
...     'string': 'A string',
... }, mode='code')

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

menu = param.Boolean(allow_refs=False, default=True, label=’Menu’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303fe7850>)

Adds main menu bar - Contains format, sort, transform, search etc. functionality. true by default. Applicable in all types of mode.

mode = param.Selector(allow_refs=False, default=’tree’, label=’Mode’, names={}, nested_refs=False, objects=[‘tree’, ‘view’, ‘form’, ‘text’, ‘preview’], rx=<param.reactive.reactive_ops object at 0x303d9d310>)

Sets the editor mode. In ‘view’ mode, the data and datastructure is read-only. In ‘form’ mode, only the value can be changed, the data structure is read-only. Mode ‘code’ requires the Ace editor to be loaded on the page. Mode ‘text’ shows the data as plain text. The ‘preview’ mode can handle large JSON documents up to 500 MiB. It shows a preview of the data, and allows to transform, sort, filter, format, or compact the data.

search = param.Boolean(allow_refs=False, default=True, label=’Search’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303fe7850>)

Enables a search box in the upper right corner of the JSONEditor. true by default. Only applicable when mode is ‘tree’, ‘view’, or ‘form’.

selection = param.List(allow_refs=False, bounds=(0, None), default=[], label=’Selection’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303d9e310>)

Current selection.

schema = param.Dict(allow_None=True, allow_refs=False, class_=<class ‘dict’>, label=’Schema’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303fe7e90>)

Validate the JSON object against a JSON schema. A JSON schema describes the structure that a JSON object must have, like required properties or the type that a value must have. See http://json-schema.org/ for more information.

templates = param.List(allow_refs=False, bounds=(0, None), default=[], label=’Templates’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303d9d310>)

Array of templates that will appear in the context menu, Each template is a json object precreated that can be added as a object value to any node in your document.

value = param.Parameter(allow_refs=False, default={}, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303fe7e10>)

JSON data to be edited.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.LinearGauge(*, bounds, colors, default_color, format, horizontal, nan_format, needle_color, show_boundaries, tick_size, title_size, unfilled_color, value_size, value, disabled, 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: ValueIndicator

A LinearGauge represents a value in some range as a position on an linear scale. It is similar to a Dial/Gauge but visually more compact.

Reference: https://panel.holoviz.org/reference/indicators/LinearGauge.html

Example:

>>> LinearGauge(value=30, default_color='red', bounds=(0, 100))

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: margin, disabled

panel.widgets.indicators.Indicator: sizing_mode

height = param.Integer(allow_refs=False, bounds=(1, None), default=300, inclusive_bounds=(True, True), label=’Height’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3040a8a90>)

The height of the component (in pixels). This can be either fixed or preferred height, depending on height sizing policy.

width = param.Integer(allow_refs=False, bounds=(1, None), default=125, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30401d250>)

The width of the component (in pixels). This can be either fixed or preferred width, depending on width sizing policy.

value = param.Number(allow_None=True, allow_refs=False, default=25, inclusive_bounds=(True, True), label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303e5f390>)

Value to indicate on the dial a value within the declared bounds.

bounds = param.Range(allow_refs=False, default=(0, 100), inclusive_bounds=(True, True), label=’Bounds’, length=2, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30401f810>)

The upper and lower bound of the gauge.

default_color = param.String(allow_refs=False, default=’lightblue’, label=’Default color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3040ab150>)

Color of the radial annulus if not color thresholds are supplied.

colors = param.Parameter(allow_None=True, allow_refs=False, label=’Colors’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30401f790>)

Color thresholds for the gauge, specified as a list of tuples of the fractional threshold and the color to switch to.

format = param.String(allow_refs=False, default=’{value:.2f}%’, label=’Format’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3040a9110>)

Formatting string for the value indicator and lower/upper bounds.

horizontal = param.Boolean(allow_refs=False, default=False, label=’Horizontal’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30401c390>)

Whether to display the linear gauge horizontally.

nan_format = param.String(allow_refs=False, default=’-’, label=’Nan format’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3040a9110>)

How to format nan values.

needle_color = param.String(allow_refs=False, default=’black’, label=’Needle color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30401c390>)

Color of the gauge needle.

show_boundaries = param.Boolean(allow_refs=False, default=False, label=’Show boundaries’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3040a9590>)

Whether to show the boundaries between colored regions.

unfilled_color = param.String(allow_refs=False, default=’whitesmoke’, label=’Unfilled color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30401d1d0>)

Color of the unfilled region of the LinearGauge.

title_size = param.String(allow_None=True, allow_refs=False, label=’Title size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3040ab190>)

Font size of the gauge title.

tick_size = param.String(allow_None=True, allow_refs=False, label=’Tick size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30401ec50>)

Font size of the gauge tick labels.

value_size = param.String(allow_None=True, allow_refs=False, label=’Value size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3040ab190>)

Font size of the gauge value label.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.LiteralInput(*, description, placeholder, serializer, type, value, disabled, 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: Widget

The LiteralInput allows declaring Python literals using a text input widget.

A literal is some specific primitive value of type str , int, float, bool etc or a dict, list, tuple, set etc of primitive values.

Optionally the literal type may be declared.

Reference: https://panel.holoviz.org/reference/widgets/LiteralInput.html

Example:

>>> LiteralInput(name='Dictionary', value={'key': [1, 2, 3]}, type=dict)

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

width = param.Integer(allow_None=True, allow_refs=False, bounds=(0, None), default=300, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303e80bd0>)

Width of this component. If sizing_mode is set to stretch or scale mode this will merely be used as a suggestion.

description = param.String(allow_None=True, allow_refs=False, label=’Description’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304160650>)

An HTML string describing the function of this component.

placeholder = param.String(allow_refs=False, default=’’, label=’Placeholder’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303fed4d0>)

Placeholder for empty input field.

serializer = param.ObjectSelector(allow_refs=False, default=’ast’, label=’Serializer’, names={}, nested_refs=False, objects=[‘ast’, ‘json’], rx=<param.reactive.reactive_ops object at 0x304160ed0>)

The serialization (and deserialization) method to use. ‘ast’ uses ast.literal_eval and ‘json’ uses json.loads and json.dumps.

type = param.ClassSelector(allow_None=True, allow_refs=False, class_=(<class ‘type’>, <class ‘tuple’>), label=’Type’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303fee150>)

value = param.Parameter(allow_None=True, allow_refs=False, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304161010>)

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.LoadingSpinner(*, bgcolor, color, size, throttle, value, disabled, 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: BooleanIndicator

The LoadingSpinner is a boolean indicator providing a visual representation of the loading status.

If the value is set to True the spinner will rotate while setting it to False will disable the rotating segment.

Reference: https://panel.holoviz.org/reference/indicators/LoadingSpinner.html

Example:

>>> LoadingSpinner(value=True, color='primary', bgcolor='light', width=100, height=100)

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.indicators.Indicator: sizing_mode

panel.widgets.indicators.BooleanIndicator: throttle

value = param.Boolean(allow_refs=True, default=False, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3040554d0>)

Whether the indicator is active or not.

bgcolor = param.ObjectSelector(allow_refs=True, default=’light’, label=’Bgcolor’, names={}, nested_refs=False, objects=[‘dark’, ‘light’], rx=<param.reactive.reactive_ops object at 0x304055010>)

color = param.ObjectSelector(allow_refs=True, default=’dark’, label=’Color’, names={}, nested_refs=False, objects=[‘primary’, ‘secondary’, ‘success’, ‘info’, ‘danger’, ‘warning’, ‘light’, ‘dark’], rx=<param.reactive.reactive_ops object at 0x3040a5650>)

size = param.Integer(allow_refs=True, default=125, inclusive_bounds=(True, True), label=’Size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3040a47d0>)

Size of the spinner in pixels.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.MenuButton(*, clicked, items, split, button_style, button_type, icon, icon_size, disabled, 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: _ButtonBase, _ClickButton, IconMixin

The MenuButton widget allows specifying a list of menu items to select from triggering events when the button is clicked.

Unlike other widgets, it does not have a value parameter. Instead it has a clicked parameter that can be watched to trigger events and which reports the last clicked menu item.

Reference: https://panel.holoviz.org/reference/widgets/MenuButton.html

Example:

>>> menu_items = [('Option A', 'a'), ('Option B', 'b'), None, ('Option C', 'c')]
>>> MenuButton(name='Dropdown', items=menu_items, button_type='primary')

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.button.IconMixin: icon, icon_size

panel.widgets.button._ButtonBase: button_type, button_style

clicked = param.String(allow_None=True, allow_refs=False, label=’Clicked’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303fb6550>)

Last menu item that was clicked.

items = param.List(allow_refs=False, bounds=(0, None), default=[], label=’Items’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303d0fa50>)

Menu items in the dropdown. Allows strings, tuples of the form (title, value) or Nones to separate groups of items.

split = param.Boolean(allow_refs=False, default=False, label=’Split’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303fe7350>)

Whether to add separate dropdown area to button.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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

js_on_click(args: Dict[str, Any] = {}, code: str = '') Callback[source]#

Allows defining a JS callback to be triggered when the button is clicked.

Parameters:
  • args (dict) – A mapping of objects to make available to the JS callback

  • code (str) – The Javascript code to execute when the button is clicked.

Returns:

callback – The Callback which can be used to disable the callback.

Return type:

Callback

jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback[source]#

Allows defining a Javascript (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:

Callback

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

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_click(callback: Callable[[Event], None]) Watcher[source]#

Register a callback to be executed when the button is clicked.

The callback is given an Event argument declaring the number of clicks

Parameters:

callback ((Callable[[param.parameterized.Event], None])) – The function to run on click events. Must accept a positional Event argument

Returns:

watcher – A Watcher that executes the callback when the MenuButton is clicked.

Return type:

param.Parameterized.Watcher

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.widgets.MultiChoice(*, delete_button, max_items, option_limit, placeholder, search_option_limit, solid, description, value, options, disabled, 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: _MultiSelectBase

The MultiChoice widget allows selecting multiple values from a list of options.

It falls into the broad category of multi-value, option-selection widgets that provide a compatible API and include the MultiSelect, CrossSelector, CheckBoxGroup and CheckButtonGroup widgets.

The MultiChoice widget provides a much more compact UI than MultiSelect.

Reference: https://panel.holoviz.org/reference/widgets/MultiChoice.html

Example:

>>> MultiChoice(
...     name='Favourites', value=['Panel', 'hvPlot'],
...     options=['Panel', 'hvPlot', 'HoloViews', 'GeoViews', 'Datashader', 'Param', 'Colorcet'],
...     max_items=2
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

panel.widgets.select.SelectBase: options

panel.widgets.select._MultiSelectBase: value, description

width = param.Integer(allow_None=True, allow_refs=False, bounds=(0, None), default=300, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303ac1790>)

Width of this component. If sizing_mode is set to stretch or scale mode this will merely be used as a suggestion.

delete_button = param.Boolean(allow_refs=False, default=True, label=’Delete button’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303fbe7d0>)

Whether to display a button to delete a selected option.

max_items = param.Integer(allow_None=True, allow_refs=False, bounds=(1, None), inclusive_bounds=(True, True), label=’Max items’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303cf0290>)

Maximum number of options that can be selected.

option_limit = param.Integer(allow_None=True, allow_refs=False, bounds=(1, None), inclusive_bounds=(True, True), label=’Option limit’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x304061cd0>)

Maximum number of options to display at once.

search_option_limit = param.Integer(allow_None=True, allow_refs=False, bounds=(1, None), inclusive_bounds=(True, True), label=’Search option limit’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303cd9150>)

Maximum number of options to display at once if search string is entered.

placeholder = param.String(allow_refs=False, default=’’, label=’Placeholder’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303fbd350>)

String displayed when no selection has been made.

solid = param.Boolean(allow_refs=False, default=True, label=’Solid’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303c44dd0>)

Whether to display widget with solid or light style.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.MultiSelect(*, size, description, value, options, disabled, 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: _MultiSelectBase

The MultiSelect widget allows selecting multiple values from a list of options.

It falls into the broad category of multi-value, option-selection widgets that provide a compatible API and include the`CrossSelector`, CheckBoxGroup and CheckButtonGroup widgets.

Reference: https://panel.holoviz.org/reference/widgets/MultiSelect.html

Example:

>>> MultiSelect(
...     name='Frameworks', value=['Bokeh', 'Panel'],
...     options=['Bokeh', 'Dash', 'Panel', 'Streamlit', 'Voila'], size=8
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

panel.widgets.select.SelectBase: options

panel.widgets.select._MultiSelectBase: width, value, description

size = param.Integer(allow_refs=True, default=4, inclusive_bounds=(True, True), label=’Size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303b088d0>)

The number of items displayed at once (i.e. determines the widget height).

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.NestedSelect(*, _levels, _max_depth, _widgets, layout, levels, options, value, disabled, 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: CompositeWidget

The NestedSelect widget is composed of multiple widgets, where subsequent select options depend on the parent’s value.

Reference: https://panel.holoviz.org/reference/widgets/NestedSelect.html

Example:

>>> NestedSelect(
...     options={
...         "gfs": {"tmp": [1000, 500], "pcp": [1000]},
...         "name": {"tmp": [1000, 925, 850, 700, 500], "pcp": [1000]},
...     },
...     levels=["model", "var", "level"],
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width

disabled = param.Boolean(allow_refs=False, default=False, label=’Disabled’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303999110>)

Whether the widget is disabled.

value = param.Dict(allow_None=True, allow_refs=False, class_=<class ‘dict’>, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303923010>)

The value from all the Select widgets; the keys are the levels names. If no levels names are specified, the keys are the levels indices.

options = param.ClassSelector(allow_None=True, allow_refs=False, class_=(<class ‘dict’>, <class ‘function’>), label=’Options’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303922bd0>)

The options to select from. The options may be nested dictionaries, lists, or callables that return those types. If callables are used, the callables must accept level and value keyword arguments, where level is the level that updated and value is a dictionary of the current values, containing keys up to the level that was updated.

layout = param.Parameter(allow_refs=False, default=<class ‘panel.layout.base.Column’>, label=’Layout’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303923950>)

The layout type of the widgets. If a dictionary, a “type” key can be provided, to specify the layout type of the widgets, and any additional keyword arguments will be used to instantiate the layout.

levels = param.List(allow_refs=False, bounds=(0, None), default=[], label=’Levels’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303922b50>)

Either a list of strings or a list of dictionaries. If a list of strings, the strings are used as the names of the levels. If a list of dictionaries, each dictionary may have a “name” key, which is used as the name of the level, a “type” key, which is used as the type of widget, and any corresponding widget keyword arguments. Must be specified if options is callable.

_widgets = param.List(allow_refs=False, bounds=(0, None), default=[], label=’ widgets’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303923190>)

The nested select widgets.

_max_depth = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’ max depth’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303922450>)

The number of levels of the nested select widgets.

_levels = param.List(allow_refs=False, bounds=(0, None), default=[], label=’ levels’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303922810>)

The internal rep of levels to prevent overwriting user provided levels.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

layout[source]#

alias of Column

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.widgets.Number(*, colors, default_color, font_size, format, nan_format, title_size, value, disabled, 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: ValueIndicator

The Number indicator renders the value as text optionally colored according to the colors thresholds.

Reference: https://panel.holoviz.org/reference/indicators/Number.html

Example:

>>> Number(name='Rate', value=72, format='{value}%', colors=[(80, 'green'), (100, 'red')]

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.indicators.Indicator: sizing_mode

panel.widgets.indicators.ValueIndicator: value

default_color = param.String(allow_refs=False, default=’black’, label=’Default color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30393e090>)

The color of the Number indicator if no colors are provided

colors = param.List(allow_None=True, allow_refs=False, bounds=(0, None), label=’Colors’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30392be50>)

Color thresholds for the Number indicator, specified as a tuple of the absolute thresholds and the color to switch to.

format = param.String(allow_refs=False, default=’{value}’, label=’Format’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30393f950>)

A formatter string which accepts a {value}.

font_size = param.String(allow_refs=False, default=’54pt’, label=’Font size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303929310>)

The size of number itself.

nan_format = param.String(allow_refs=False, default=’-’, label=’Nan format’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30393f950>)

How to format nan values.

title_size = param.String(allow_refs=False, default=’18pt’, label=’Title size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30392bd50>)

The size of the title given by the name.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.NumberInput(*, page_step_multiplier, wheel_wait, description, end, format, placeholder, start, value, disabled, 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: _SpinnerBase

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

panel.widgets.input._NumericInputBase: description, value, placeholder, format, start, end

panel.widgets.input._SpinnerBase: width, page_step_multiplier, wheel_wait

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.PasswordInput(*, description, max_length, placeholder, value, value_input, disabled, 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: TextInput

The PasswordInput allows entering any string using an obfuscated text input box.

Reference: https://panel.holoviz.org/reference/widgets/PasswordInput.html

Example:

>>> PasswordInput(
...     name='Password', placeholder='Enter your password here...'
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

panel.widgets.input.TextInput: width, description, max_length, placeholder, value, value_input

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

classmethod from_param(parameter: param.Parameter, onkeyup=False, **params) Viewable[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:
  • parameter (param.Parameter) – A parameter to create the widget from.

  • onkeyup (boolean) – Whether to trigger events on every key press.

  • params (dict) – Keyword arguments to be passed to the widget constructor

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.Player(*, end, start, value, value_throttled, direction, interval, loop_policy, show_loop_controls, step, disabled, 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: PlayerBase

The Player provides controls to play and skip through a number of frames defined by explicit start and end values. The speed at which the widget plays is defined by the interval (in milliseconds), but it is also possible to skip frames using the step parameter.

Reference: https://panel.holoviz.org/reference/widgets/Player.html

Example:

>>> Player(name='Player', start=0, end=100, value=32, loop_policy='loop')

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: margin, disabled

panel.widgets.player.PlayerBase: height, width, direction, interval, loop_policy, show_loop_controls, step

start = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Start’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303768510>)

Lower bound on the slider value

end = param.Integer(allow_refs=False, default=10, inclusive_bounds=(True, True), label=’End’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3037b6610>)

Upper bound on the slider value

value = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303768190>)

Current player value

value_throttled = param.Integer(allow_refs=False, constant=True, default=0, inclusive_bounds=(True, True), label=’Value throttled’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3037b6990>)

Current throttled player value.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.Progress(*, active, bar_color, max, value, disabled, 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: ValueIndicator

The Progress widget displays the progress towards some target based on the current value and the max value.

If no value is set, the Progress widget is in indeterminate mode and will animate depending on whether it is active or not. A more beautiful indicator for this use case is the LoadingSpinner.

Reference: https://panel.holoviz.org/reference/indicators/Progress.html

Example:

>>> Progress(value=20, max=100, bar_color="primary")

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

width = param.Integer(allow_refs=False, bounds=(0, None), default=300, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303789b90>)

The width of the component (in pixels). This can be either fixed or preferred width, depending on width sizing policy.

sizing_mode = param.ObjectSelector(allow_refs=False, label=’Sizing mode’, names={}, nested_refs=False, objects=[‘fixed’, ‘stretch_width’, ‘stretch_height’, ‘stretch_both’, ‘scale_width’, ‘scale_height’, ‘scale_both’, None], rx=<param.reactive.reactive_ops object at 0x303720590>)

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 and aspect_ratio instead (those take precedence over sizing_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.

value = param.Integer(allow_refs=False, bounds=(-1, None), default=-1, inclusive_bounds=(True, True), label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3038907d0>)

The current value of the progress bar. If set to -1 the progress bar will be indeterminate and animate depending on the active parameter.

active = param.Boolean(allow_refs=False, default=True, label=’Active’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303720b90>)

If no value is set the active property toggles animation of the progress bar on and off.

bar_color = param.ObjectSelector(allow_refs=False, default=’success’, label=’Bar color’, names={}, nested_refs=False, objects=[‘primary’, ‘secondary’, ‘success’, ‘info’, ‘danger’, ‘warning’, ‘light’, ‘dark’], rx=<param.reactive.reactive_ops object at 0x30378a990>)

max = param.Integer(allow_refs=False, default=100, inclusive_bounds=(True, True), label=’Max’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303720a10>)

The maximum value of the progress bar.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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

sizing_mode = None#
class panel.widgets.RadioBoxGroup(*, inline, value, options, disabled, 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: _RadioGroupBase

The RadioBoxGroup widget allows selecting from a list or dictionary of values using a set of checkboxes.

It falls into the broad category of single-value, option-selection widgets that provide a compatible API and include the RadioButtonGroup, Select and DiscreteSlider widgets.

Reference: https://panel.holoviz.org/reference/widgets/RadioBoxGroup.html

Example:

>>> RadioBoxGroup(
...     name='Sponsor', options=['Anaconda', 'Blackstone'], inline=True
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.select.SelectBase: options

panel.widgets.select.SingleSelectBase: value

inline = param.Boolean(allow_refs=False, default=False, label=’Inline’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30371d910>)

Whether the items be arrange vertically (False) or horizontally in-line (True).

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.RadioButtonGroup(*, orientation, value, options, button_style, button_type, description, description_delay, disabled, 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: _RadioGroupBase, _ButtonBase, TooltipMixin

The RadioButtonGroup widget allows selecting from a list or dictionary of values using a set of toggle buttons.

It falls into the broad category of single-value, option-selection widgets that provide a compatible API and include the RadioBoxGroup, Select, and DiscreteSlider widgets.

Reference: https://panel.holoviz.org/reference/widgets/RadioButtonGroup.html

Example:

>>> RadioButtonGroup(
...     name='Plotting library', options=['Matplotlib', 'Bokeh', 'Plotly'],
...     button_type='success'
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets._mixin.TooltipMixin: description, description_delay

panel.widgets.button._ButtonBase: button_type, button_style

panel.widgets.select.SelectBase: options

panel.widgets.select.SingleSelectBase: value

orientation = param.Selector(allow_refs=False, default=’horizontal’, label=’Orientation’, names={}, nested_refs=False, objects=[‘horizontal’, ‘vertical’], rx=<param.reactive.reactive_ops object at 0x303725f50>)

Button group orientation, either ‘horizontal’ (default) or ‘vertical’.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.RangeSlider(*, end, format, start, step, value_throttled, value, bar_color, direction, orientation, show_value, tooltips, disabled, 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: _RangeSliderBase

The RangeSlider widget allows selecting a floating-point range using a slider with two handles.

Reference: https://panel.holoviz.org/reference/widgets/RangeSlider.html

Example:

>>> RangeSlider(
...     value=(1.0, 1.5), start=0.0, end=2.0, step=0.25, name="A tuple of floats"
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.slider._SliderBase: bar_color, direction, orientation, show_value, tooltips

value = param.Range(allow_refs=False, default=(0, 1), inclusive_bounds=(True, True), label=’Value’, length=2, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x30374a790>)

The selected range as a tuple of values. Updated when a handle is dragged.

value_start = param.Number(allow_refs=False, constant=True, default=0, inclusive_bounds=(True, True), label=’Value start’, nested_refs=False, readonly=True, rx=<param.reactive.reactive_ops object at 0x3035fd690>)

The lower value of the selected range.

value_end = param.Number(allow_refs=False, constant=True, default=1, inclusive_bounds=(True, True), label=’Value end’, nested_refs=False, readonly=True, rx=<param.reactive.reactive_ops object at 0x30301a8d0>)

The upper value of the selected range.

value_throttled = param.Range(allow_None=True, allow_refs=False, constant=True, inclusive_bounds=(True, True), label=’Value throttled’, length=2, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x3035fcd50>)

The selected range as a tuple of floating point values. Updated when a handle is released

start = param.Number(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Start’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30301a8d0>)

The lower bound.

end = param.Number(allow_refs=False, default=1, inclusive_bounds=(True, True), label=’End’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3035fcbd0>)

The upper bound.

step = param.Number(allow_refs=False, default=0.1, inclusive_bounds=(True, True), label=’Step’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3035fd790>)

The step size.

format = param.ClassSelector(allow_None=True, allow_refs=False, class_=(<class ‘str’>, <class ‘bokeh.models.formatters.TickFormatter’>), label=’Format’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3035ff910>)

A format string or bokeh TickFormatter.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.Select(*, description, disabled_options, groups, size, value, options, disabled, 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: SingleSelectBase

The Select widget allows selecting a value from a list or dictionary of options by selecting it from a dropdown menu or selection area.

It falls into the broad category of single-value, option-selection widgets that provide a compatible API and include the RadioBoxGroup, AutocompleteInput and DiscreteSlider widgets.

Reference: https://panel.holoviz.org/reference/widgets/Select.html

Example:

>>> Select(name='Study', options=['Biology', 'Chemistry', 'Physics'])

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

panel.widgets.select.SelectBase: options

panel.widgets.select.SingleSelectBase: value

width = param.Integer(allow_None=True, allow_refs=False, bounds=(0, None), default=300, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3035af3d0>)

Width of this component. If sizing_mode is set to stretch or scale mode this will merely be used as a suggestion.

description = param.String(allow_None=True, allow_refs=False, label=’Description’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3035a67d0>)

An HTML string describing the function of this component.

disabled_options = param.List(allow_refs=False, bounds=(0, None), default=[], label=’Disabled options’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x3035e38d0>)

Optional list of options that are disabled, i.e. unusable and un-clickable. If options is a dictionary the list items must be dictionary values.

groups = param.Dict(allow_None=True, allow_refs=False, class_=<class ‘dict’>, label=’Groups’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x3035af090>)

Dictionary whose keys are used to visually group the options and whose values are either a list or a dictionary of options to select from. Mutually exclusive with options and valid only if size is 1.

size = param.Integer(allow_refs=False, bounds=(1, None), default=1, inclusive_bounds=(True, True), label=’Size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3035a6590>)

Declares how many options are displayed at the same time. If set to 1 displays options as dropdown otherwise displays scrollable area.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.SpeechToText(*, _grammars, abort, audio_started, button_hide, button_not_started, button_started, button_type, continuous, grammars, interim_results, lang, max_alternatives, results, service_uri, sound_started, speech_started, start, started, stop, value, disabled, 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: Widget

The SpeechToText widget controls the speech recognition service of the browser.

It wraps the HTML5 SpeechRecognition API. See https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition

Reference: https://panel.holoviz.org/reference/widgets/SpeechToText.html

Example:

>>> SpeechToText(button_type="light")

This functionality is experimental and only supported by Chrome and a few other browsers. Checkout https://caniuse.com/speech-recognition for a up to date list of browsers supporting the SpeechRecognition Api. Or alternatively https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition#Browser_compatibility

On some browsers, like Chrome, using Speech Recognition on a web page involves a server-based recognition engine. Your audio is sent to a web service for recognition processing, so it won’t work offline. Whether this is secure and confidential enough for your use case is up to you to evaluate.

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

abort = param.Event(allow_refs=False, default=False, label=’Abort’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3035a7590>)

Stops the speech recognition service from listening to incoming audio, and doesn’t attempt to return a RecognitionResult.

start = param.Event(allow_refs=False, default=False, label=’Start’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3035ec1d0>)

Starts the speech recognition service listening to incoming audio with intent to recognize grammars associated with the current SpeechRecognition.

stop = param.Event(allow_refs=False, default=False, label=’Stop’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3035a7a10>)

Stops the speech recognition service from listening to incoming audio, and attempts to return a RecognitionResult using the audio captured so far.

lang = param.ObjectSelector(allow_None=True, allow_refs=False, default=’’, names={}, nested_refs=False, objects=[‘’, ‘af-ZA’, ‘ar-AE’, ‘ar-BH’, ‘ar-DZ’, ‘ar-EG’, ‘ar-IL’, ‘ar-IQ’, ‘ar-JO’, ‘ar-KW’, ‘ar-LB’, ‘ar-MA’, ‘ar-OM’, ‘ar-PS’, ‘ar-QA’, ‘ar-SA’, ‘ar-TN’, ‘bg-BG’, ‘ca-ES’, ‘cmn-Hans-CN’, ‘cmn-Hans-HK’, ‘cmn-Hant-TW’, ‘cs-CZ’, ‘da-DK’, ‘de-DE’, ‘el-GR’, ‘en-AU’, ‘en-CA’, ‘en-GB’, ‘en-IE’, ‘en-IN’, ‘en-NZ’, ‘en-PH’, ‘en-US’, ‘en-ZA’, ‘es-AR’, ‘es-BO’, ‘es-CL’, ‘es-CO’, ‘es-CR’, ‘es-DO’, ‘es-EC’, ‘es-ES’, ‘es-GT’, ‘es-HN’, ‘es-MX’, ‘es-NI’, ‘es-PA’, ‘es-PE’, ‘es-PR’, ‘es-PY’, ‘es-SV’, ‘es-US’, ‘es-UY’, ‘es-VE’, ‘eu-ES’, ‘fa-IR’, ‘fi-FI’, ‘fil-PH’, ‘fr-FR’, ‘gl-ES’, ‘he-IL’, ‘hi-IN’, ‘hr_HR’, ‘hu-HU’, ‘id-ID’, ‘is-IS’, ‘it-CH’, ‘it-IT’, ‘ja-JP’, ‘ko-KR’, ‘lt-LT’, ‘ms-MY’, ‘nb-NO’, ‘nl-NL’, ‘pl-PL’, ‘pt-BR’, ‘pt-PT’, ‘ro-RO’, ‘ru-RU’, ‘sk-SK’, ‘sl-SI’, ‘sr-RS’, ‘sv-SE’, ‘th-TH’, ‘tr-TR’, ‘uk-UA’, ‘vi-VN’, ‘yue-Hant-HK’, ‘zu-ZA’], rx=<param.reactive.reactive_ops object at 0x3035ed190>)

The language of the current SpeechRecognition in BCP 47 format. For example ‘en-US’. If not specified, this defaults to the HTML lang attribute value, or the user agent’s language setting if that isn’t set either.

continuous = param.Boolean(allow_refs=False, default=False, label=’Continuous’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3035a7a10>)

Controls whether continuous results are returned for each recognition, or only a single result. Defaults to False

interim_results = param.Boolean(allow_refs=False, default=False, label=’Interim results’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3035a7590>)

Controls whether interim results should be returned (True) or not (False.) Interim results are results that are not yet final (e.g. the RecognitionResult.is_final property is False).

max_alternatives = param.Integer(allow_refs=False, bounds=(1, 5), default=1, inclusive_bounds=(True, True), label=’Max alternatives’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3035ecf90>)

Sets the maximum number of RecognitionAlternatives provided per result. A number between 1 and 5. The default value is 1.

service_uri = param.String(allow_refs=False, default=’’, label=’Service uri’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3035ec190>)

Specifies the location of the speech recognition service used by the current SpeechRecognition to handle the actual recognition. The default is the user agent’s default speech service.

grammars = param.ClassSelector(allow_None=True, allow_refs=False, class_=<class ‘panel.widgets.speech_to_text.GrammarList’>, label=’Grammars’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3035a7990>)

A GrammarList object that represents the grammars that will be understood by the current SpeechRecognition service

button_hide = param.Boolean(allow_refs=False, default=False, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3035ecf50>)

If True no button is shown. If False a toggle Start/ Stop button is shown.

button_type = param.ObjectSelector(allow_refs=False, default=’light’, label=’Button type’, names={}, nested_refs=False, objects=[‘default’, ‘primary’, ‘success’, ‘warning’, ‘danger’, ‘light’, ‘light’, ‘dark’], rx=<param.reactive.reactive_ops object at 0x3035ec050>)

The button styling.

button_not_started = param.String(allow_refs=False, default=’’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3035ecf50>)

The text to show on the button when the SpeechRecognition service is NOT started. If ‘’ a muted microphone icon is shown.

button_started = param.String(allow_refs=False, default=’’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3035a7990>)

The text to show on the button when the SpeechRecognition service is started. If ‘’ a muted microphone icon is shown.

started = param.Boolean(allow_refs=False, constant=True, default=False, label=’Started’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3035a7590>)

Returns True if the Speech Recognition Service is started and False otherwise.

audio_started = param.Boolean(allow_refs=False, constant=True, default=False, label=’Audio started’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3035a7a10>)

Returns True if the Audio is started and False otherwise.

sound_started = param.Boolean(allow_refs=False, constant=True, default=False, label=’Sound started’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3035a7590>)

Returns True if the Sound is started and False otherwise.

speech_started = param.Boolean(allow_refs=False, constant=True, default=False, label=’Speech started’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3035a7a10>)

Returns True if the the User has started speaking and False otherwise.

results = param.List(allow_refs=False, bounds=(0, None), constant=True, default=[], label=’Results’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3035ec190>)

The results as a list of Dictionaries.

value = param.String(allow_refs=False, constant=True, default=’’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3035a7990>)

The transcipt of the highest confidence RecognitionAlternative of the last RecognitionResult. Please note we strip the transcript for leading spaces.

_grammars = param.List(allow_refs=False, bounds=(0, None), constant=True, default=[], label=’ grammars’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3035ed010>)

List used to transfer the serialized grammars from server to browser.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.

property results_as_html: str#

Returns the results formatted as html

Convenience method for ease of use

property results_deserialized#

Returns the results as a List of RecognitionResults

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

panel.widgets.Spinner[source]#

alias of NumberInput

class panel.widgets.StaticText(*, value, disabled, 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: Widget

The StaticText widget displays a text value, but does not allow editing it.

Reference: https://panel.holoviz.org/reference/widgets/StaticText.html

Example:

>>> StaticText(name='Model', value='animagen2')

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

value = param.Parameter(allow_None=True, allow_refs=False, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30375d490>)

The current value

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.Switch(*, value, disabled, 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: _BooleanWidget

The Switch allows toggling a single condition between True/False states by ticking a checkbox.

This widget is interchangeable with the Toggle widget.

Reference: https://panel.holoviz.org/reference/widgets/Switch.html

Example:

>>> Switch(name='Works with the tools you know and love', value=True)

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.input._BooleanWidget: value

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.Tabulator(value=None, **params)[source]#

Bases: BaseTable

The Tabulator widget wraps the [Tabulator js](http://tabulator.info/) table to provide a full-featured, very powerful interactive table.

Reference: https://panel.holoviz.org/reference/widgets/Tabulator.html

Example:

>>> Tabulator(df, theme='site', pagination='remote', page_size=25)

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.tables.BaseTable: selection, aggregators, editors, formatters, hierarchical, show_index, sorters, text_align, titles, widths, value

row_height = param.Integer(allow_refs=True, default=30, inclusive_bounds=(True, True), label=’Row height’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3033dc7d0>)

The height of each table row.

buttons = param.Dict(allow_refs=True, class_=<class ‘dict’>, default={}, label=’Buttons’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x3033de790>)

Dictionary mapping from column name to a HTML element to use as the button icon.

expanded = param.List(allow_refs=True, bounds=(0, None), default=[], label=’Expanded’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x303439550>)

List of expanded rows, only applicable if a row_content function has been defined.

embed_content = param.Boolean(allow_refs=True, default=False, label=’Embed content’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3033dee10>)

Whether to embed the row_content or render it dynamically when a row is expanded.

filters = param.List(allow_refs=True, bounds=(0, None), default=[], label=’Filters’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303439550>)

List of client-side filters declared as dictionaries containing ‘field’, ‘type’ and ‘value’ keys.

frozen_columns = param.ClassSelector(allow_refs=True, class_=(<class ‘list’>, <class ‘dict’>), default=[], label=’Frozen columns’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x3033dca10>)

One of: - List indicating the columns to freeze. The column(s) may be selected by name or index. - Dict indicating columns to freeze as keys and their freeze location as values, freeze location is either ‘right’ or ‘left’.

frozen_rows = param.List(allow_refs=True, bounds=(0, None), default=[], label=’Frozen rows’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x3034386d0>)

List indicating the rows to freeze. If set, the first N rows will be frozen, which prevents them from scrolling out of frame; if set to a negative value the last N rows will be frozen.

groups = param.Dict(allow_refs=True, class_=<class ‘dict’>, default={}, label=’Groups’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x3033de710>)

Dictionary mapping defining the groups.

groupby = param.List(allow_refs=True, bounds=(0, None), default=[], label=’Groupby’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x3034386d0>)

Groups rows in the table by one or more columns.

header_align = param.ClassSelector(allow_refs=True, class_=(<class ‘dict’>, <class ‘str’>), default={}, label=’Header align’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x3033de790>)

A mapping from column name to alignment or a fixed column alignment, which should be one of ‘left’, ‘center’, ‘right’.

header_filters = param.ClassSelector(allow_None=True, allow_refs=True, class_=(<class ‘bool’>, <class ‘dict’>), label=’Header filters’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x303439010>)

Whether to enable filters in the header or dictionary configuring filters for each column.

hidden_columns = param.List(allow_refs=True, bounds=(0, None), default=[], label=’Hidden columns’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x3033dead0>)

List of columns to hide.

layout = param.ObjectSelector(allow_refs=True, default=’fit_data_table’, label=’Layout’, names={}, nested_refs=False, objects=[‘fit_data’, ‘fit_data_fill’, ‘fit_data_stretch’, ‘fit_data_table’, ‘fit_columns’], rx=<param.reactive.reactive_ops object at 0x3033dc590>)

pagination = param.ObjectSelector(allow_None=True, allow_refs=True, label=’Pagination’, names={}, nested_refs=False, objects=[‘local’, ‘remote’], rx=<param.reactive.reactive_ops object at 0x3033dcf90>)

page = param.Integer(allow_refs=True, default=1, inclusive_bounds=(True, True), label=’Page’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3033dc690>)

Currently selected page (indexed starting at 1), if pagination is enabled.

page_size = param.Integer(allow_refs=True, bounds=(1, None), default=20, inclusive_bounds=(True, True), label=’Page size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3033de450>)

Number of rows to render per page, if pagination is enabled.

row_content = param.Callable(allow_None=True, allow_refs=True, label=’Row content’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303506e50>)

A function which is given the DataFrame row and should return a Panel object to render as additional detail below the row.

selectable = param.ClassSelector(allow_refs=True, class_=(<class ‘bool’>, <class ‘str’>, <class ‘int’>), default=True, label=’Selectable’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3033df290>)

Defines the selection mode of the Tabulator. - True Selects rows on click. To select multiple use Ctrl-select, to select a range use Shift-select - False Disables selection - ‘checkbox’ Adds a column of checkboxes to toggle selections - ‘checkbox-single’ Same as ‘checkbox’ but header does not allow select/deselect all - ‘toggle’ Selection toggles when clicked - int The maximum number of selectable rows.

selectable_rows = param.Callable(allow_None=True, allow_refs=True, label=’Selectable rows’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3035a8250>)

A function which given a DataFrame should return a list of rows by integer index, which are selectable.

sortable = param.ClassSelector(allow_refs=True, class_=(<class ‘bool’>, <class ‘dict’>), default=True, label=’Sortable’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3033df350>)

Whether the columns in the table should be sortable. Can either be specified as a simple boolean toggling the behavior on and off or as a dictionary specifying the option per column.

theme = param.ObjectSelector(allow_refs=True, default=’simple’, label=’Theme’, names={}, nested_refs=False, objects=[‘default’, ‘site’, ‘simple’, ‘midnight’, ‘modern’, ‘bootstrap’, ‘bootstrap4’, ‘materialize’, ‘bulma’, ‘semantic-ui’, ‘fast’, ‘bootstrap5’], rx=<param.reactive.reactive_ops object at 0x3033def90>)

Tabulator CSS theme to apply to table.

theme_classes = param.List(allow_refs=True, bounds=(0, None), class_=<class ‘str’>, default=[], item_type=<class ‘str’>, label=’Theme classes’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x3033df110>)

List of extra CSS classes to apply to the Tabulator element to customize the theme.

title_formatters = param.Dict(allow_refs=True, class_=<class ‘dict’>, default={}, label=’Title formatters’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x3035aaf90>)

Tabulator formatter specification to use for a particular column header title.

add_filter(filter, column=None)[source]#

Adds a filter to the table which can be a static value or dynamic parameter based object which will automatically update the table when changed..

When a static value, widget or parameter is supplied the filtering will follow a few well defined behaviors:

  • scalar: Filters by checking for equality

  • tuple: A tuple will be interpreted as range.

  • list: A list will be interpreted as a set of discrete

    scalars and the filter will check if the values in the column match any of the items in the list.

Parameters:
  • filter (Widget, param.Parameter or FunctionType) – The value by which to filter the DataFrame along the declared column, or a function accepting the DataFrame to be filtered and returning a filtered copy of the DataFrame.

  • column (str or None) – Column to which the filter will be applied, if the filter is a constant value, widget or parameter.

Raises:

ValueError – If the filter type is not supported or no column: was declared.

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

property current_view: pd.DataFrame#

Returns the current view of the table after filtering and sorting are applied.

download(filename: str = 'table.csv')[source]#

Triggers downloading of the table as a CSV or JSON.

Parameters:

filename (str) – The filename to save the table as.

download_menu(text_kwargs={}, button_kwargs={})[source]#

Returns a menu containing a TextInput and Button widget to set the filename and trigger a client-side download of the data.

Parameters:
  • text_kwargs (dict) – Keyword arguments passed to the TextInput constructor

  • button_kwargs (dict) – Keyword arguments passed to the Button constructor

Returns:

  • filename (TextInput) – The TextInput widget setting a filename.

  • button (Button) – The Button that triggers a download.

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 from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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_click(callback: Callable[[CellClickEvent], None], column: Optional[str] = None)[source]#

Register a callback to be executed when any cell is clicked. The callback is given a CellClickEvent declaring the column and row of the cell that was clicked.

Parameters:
  • callback ((callable)) – The callback to run on edit events.

  • column ((str)) – Optional argument restricting the callback to a specific column.

on_edit(callback: Callable[[TableEditEvent], None])[source]#

Register a callback to be executed when a cell is edited. Whenever a cell is edited on_edit callbacks are called with a TableEditEvent as the first argument containing the column, row and value of the edited cell.

Parameters:

callback ((callable)) – The callback to run on edit events.

patch(patch_value, as_index=True)[source]#

Efficiently patches (updates) the existing value with the patch_value.

Parameters:
  • patch_value ((pd.DataFrame | pd.Series | Dict)) – The value(s) to patch the existing value with.

  • as_index (boolean) – Whether to treat the patch index as DataFrame indexes (True) or as simple integer index.

Raises:

ValueError – Raised if the patch_value is not a supported type.:

Examples

Patch a DataFrame with a Dictionary row. >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> patch_value = {“x”: [(0, 3)]} >>> tabulator.patch(patch_value) >>> tabulator.value.to_dict(“list”) {‘x’: [3, 2], ‘y’: [‘a’, ‘b’]}

Patch a Dataframe with a Dictionary of Columns. >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> patch_value = {“x”: [(slice(2), (3,4))], “y”: [(1,’d’)]} >>> tabulator.patch(patch_value) >>> tabulator.value.to_dict(“list”) {‘x’: [3, 4], ‘y’: [‘a’, ‘d’]}

Patch a DataFrame with a Series. Please note the index is used in the update. >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> patch_value = pd.Series({“index”: 1, “x”: 4, “y”: “d”}) >>> tabulator.patch(patch_value) >>> tabulator.value.to_dict(“list”) {‘x’: [1, 4], ‘y’: [‘a’, ‘d’]}

Patch a Dataframe with a Dataframe. Please note the index is used in the update. >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> patch_value = pd.DataFrame({“x”: [3, 4], “y”: [“c”, “d”]}) >>> tabulator.patch(patch_value) >>> tabulator.value.to_dict(“list”) {‘x’: [3, 4], ‘y’: [‘c’, ‘d’]}

remove_filter(filter)[source]#

Removes a filter which was previously added.

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)

property selected_dataframe#

Returns a DataFrame of the currently selected rows.

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

stream(stream_value, rollover=None, reset_index=True, follow=True)[source]#

Streams (appends) the stream_value provided to the existing value in an efficient manner.

Parameters:
  • stream_value ((pd.DataFrame | pd.Series | Dict)) – The new value(s) to append to the existing value.

  • rollover (int) – A maximum column size, above which data from the start of the column begins to be discarded. If None, then columns will continue to grow unbounded.

  • reset_index ((bool, default=True)) – If True and the stream_value is a DataFrame, then its index is reset. Helps to keep the index unique and named index

Raises:

ValueError – Raised if the stream_value is not a supported type.:

Examples

Stream a Series to a DataFrame >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> stream_value = pd.Series({“x”: 4, “y”: “d”}) >>> tabulator.stream(stream_value) >>> tabulator.value.to_dict(“list”) {‘x’: [1, 2, 4], ‘y’: [‘a’, ‘b’, ‘d’]}

Stream a Dataframe to a Dataframe >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> stream_value = pd.DataFrame({“x”: [3, 4], “y”: [“c”, “d”]}) >>> tabulator.stream(stream_value) >>> tabulator.value.to_dict(“list”) {‘x’: [1, 2, 3, 4], ‘y’: [‘a’, ‘b’, ‘c’, ‘d’]}

Stream a Dictionary row to a DataFrame >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> stream_value = {“x”: 4, “y”: “d”} >>> tabulator.stream(stream_value) >>> tabulator.value.to_dict(“list”) {‘x’: [1, 2, 4], ‘y’: [‘a’, ‘b’, ‘d’]}

Stream a Dictionary of Columns to a Dataframe >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> stream_value = {“x”: [3, 4], “y”: [“c”, “d”]} >>> tabulator.stream(stream_value) >>> tabulator.value.to_dict(“list”) {‘x’: [1, 2, 3, 4], ‘y’: [‘a’, ‘b’, ‘c’, ‘d’]}

class panel.widgets.Terminal(output=None, **params)[source]#

Bases: Widget

The Terminal widget renders a live terminal in the browser using the xterm.js library making it possible to display logs or even provide an interactive terminal in a Panel application.

Reference: https://panel.holoviz.org/reference/widgets/Terminal.html

Example:

>>> Terminal(
...     "Welcome to the Panel Terminal!", options={"cursorBlink": True}
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

clear = param.Action(allow_None=True, allow_refs=False, constant=True, label=’Clear’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3034fd750>)

Clears the Terminal.

options = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Options’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3033dd190>)

Initial Options for the Terminal Constructor. cf. https://xtermjs.org/docs/api/terminal/interfaces/iterminaloptions/

output = param.String(allow_refs=False, default=’’, label=’Output’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3034fd750>)

System output written to the Terminal

ncols = param.Integer(allow_refs=False, constant=True, default=0, inclusive_bounds=(True, True), label=’Ncols’, nested_refs=False, readonly=True, rx=<param.reactive.reactive_ops object at 0x3033a7450>)

The number of columns in the terminal.

nrows = param.Integer(allow_refs=False, constant=True, default=0, inclusive_bounds=(True, True), label=’Nrows’, nested_refs=False, readonly=True, rx=<param.reactive.reactive_ops object at 0x3033c6c50>)

The number of rows in the terminal.

value = param.String(allow_refs=False, constant=True, default=’’, nested_refs=False, readonly=True, rx=<param.reactive.reactive_ops object at 0x30334f2d0>)

User input received from the Terminal. Sent one character at the time.

write_to_console = param.Boolean(allow_refs=False, default=False, label=’Write to console’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3034ffcd0>)

Whether or not to write to the server console.

_clears = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’ clears’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3033f9cd0>)

Sends a signal to clear the terminal

_output = param.String(allow_refs=False, default=’’, label=’ output’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3033dd190>)

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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

property subprocess#

The subprocess enables running commands like ‘ls’, [‘ls’, ‘-l’], ‘bash’, ‘python’ and ‘ipython’ in the terminal.

class panel.widgets.TextAreaInput(*, auto_grow, cols, max_rows, resizable, rows, description, max_length, placeholder, value, value_input, disabled, 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: TextInput

The TextAreaInput allows entering any multiline string using a text input box.

Lines are joined with the newline character `

`.

Reference: https://panel.holoviz.org/reference/widgets/TextAreaInput.html :Example:

>>> TextAreaInput(
...     name='Description', placeholder='Enter your description here...'
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

panel.widgets.input.TextInput: width, description, max_length, placeholder, value, value_input

auto_grow = param.Boolean(allow_refs=False, default=False, label=’Auto grow’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303303310>)

Whether the text area should automatically grow vertically to accommodate the current text.

cols = param.Integer(allow_refs=False, default=20, inclusive_bounds=(True, True), label=’Cols’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3032bfe10>)

Number of columns in the text input field.

max_rows = param.Integer(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Max rows’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3032bf050>)

When combined with auto_grow this determines the maximum number of rows the input area can grow.

rows = param.Integer(allow_refs=False, default=2, inclusive_bounds=(True, True), label=’Rows’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3032bee50>)

Number of rows in the text input field.

resizable = param.ObjectSelector(allow_refs=False, label=’Resizable’, names={}, nested_refs=False, objects=[‘both’, ‘width’, ‘height’, False], rx=<param.reactive.reactive_ops object at 0x303303410>)

Whether the layout is interactively resizable, and if so in which dimensions: width, height, or both. Can only be set during initialization.

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

classmethod from_param(parameter: param.Parameter, onkeyup=False, **params) Viewable[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:
  • parameter (param.Parameter) – A parameter to create the widget from.

  • onkeyup (boolean) – Whether to trigger events on every key press.

  • params (dict) – Keyword arguments to be passed to the widget constructor

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.TextEditor(*, mode, placeholder, toolbar, value, disabled, 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: Widget

The TextEditor widget provides a WYSIWYG (what-you-see-is-what-you-get) rich text editor which outputs HTML.

The editor is built on top of the [Quill.js](https://quilljs.com/) library.

Reference: https://panel.holoviz.org/reference/widgets/TextEditor.html

Example:

>>> TextEditor(placeholder='Enter some text')

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width

disabled = param.Boolean(allow_refs=False, default=False, label=’Disabled’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30318ff90>)

Whether the editor is disabled.

mode = param.Selector(allow_refs=False, default=’toolbar’, label=’Mode’, names={}, nested_refs=False, objects=[‘bubble’, ‘toolbar’], rx=<param.reactive.reactive_ops object at 0x30319f250>)

Whether to display a toolbar or a bubble menu on highlight.

toolbar = param.ClassSelector(allow_refs=False, class_=(<class ‘list’>, <class ‘bool’>), default=True, label=’Toolbar’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30318fed0>)

Toolbar configuration either as a boolean toggle or a configuration specified as a list.

placeholder = param.String(allow_refs=False, default=’’, label=’Placeholder’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30319f3d0>)

Placeholder output when the editor is empty.

value = param.String(allow_refs=False, default=’’, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30318fe90>)

State of the current text in the editor

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.TextInput(*, description, max_length, placeholder, value, value_input, disabled, 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: Widget

The TextInput widget allows entering any string using a text input box.

Reference: https://panel.holoviz.org/reference/widgets/TextInput.html

Example:

>>> TextInput(name='Name', placeholder='Enter your name here ...')

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

width = param.Integer(allow_None=True, allow_refs=True, bounds=(0, None), default=300, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30319d410>)

Width of this component. If sizing_mode is set to stretch or scale mode this will merely be used as a suggestion.

description = param.String(allow_None=True, allow_refs=True, label=’Description’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3031b0b90>)

An HTML string describing the function of this component.

max_length = param.Integer(allow_refs=True, default=5000, inclusive_bounds=(True, True), label=’Max length’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30319d410>)

Max count of characters in the input field.

placeholder = param.String(allow_refs=True, default=’’, label=’Placeholder’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3030f2310>)

Placeholder for empty input field.

value = param.String(allow_None=True, allow_refs=True, default=’’, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30319c510>)

Initial or entered text value updated when <enter> key is pressed.

value_input = param.String(allow_None=True, allow_refs=True, default=’’, label=’Value input’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3031db290>)

Initial or entered text value updated on every key press.

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

classmethod from_param(parameter: param.Parameter, onkeyup=False, **params) Viewable[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:
  • parameter (param.Parameter) – A parameter to create the widget from.

  • onkeyup (boolean) – Whether to trigger events on every key press.

  • params (dict) – Keyword arguments to be passed to the widget constructor

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.TextToSpeech(*, _voices, auto_speak, cancel, pause, resume, speak, lang, pitch, rate, value, voice, volume, disabled, 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: Utterance, Widget

The TextToSpeech widget wraps the HTML5 SpeechSynthesis API

See https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis

Reference: https://panel.holoviz.org/reference/widgets/TextToSpeech.html

Example:

>>> TextToSpeech(name="Speech Synthesis", value="Data apps are nice")

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.text_to_speech.Utterance: value, lang, pitch, rate, voice, volume

auto_speak = param.Boolean(allow_refs=False, default=True, label=’Auto speak’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3033b3e90>)

Whether or not to automatically speak when the value changes.

cancel = param.Event(allow_refs=False, default=False, label=’Cancel’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3032c9bd0>)

Removes all utterances from the utterance queue.

pause = param.Event(allow_refs=False, default=False, label=’Pause’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3033b3a50>)

Puts the TextToSpeak object into a paused state.

resume = param.Event(allow_refs=False, default=False, label=’Resume’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3032caa50>)

Puts the TextToSpeak object into a non-paused state: resumes it if it was already paused.

paused = param.Boolean(allow_refs=False, constant=True, default=False, label=’Paused’, nested_refs=False, readonly=True, rx=<param.reactive.reactive_ops object at 0x3033b0050>)

A Boolean that returns true if the TextToSpeak object is in a paused state.

pending = param.Boolean(allow_refs=False, constant=True, default=False, label=’Pending’, nested_refs=False, readonly=True, rx=<param.reactive.reactive_ops object at 0x3032ca090>)

A Boolean that returns true if the utterance queue contains as-yet-unspoken utterances.

speak = param.Event(allow_refs=False, default=False, label=’Speak’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3033b3a50>)

Speak. I.e. send a new Utterance to the browser

speaking = param.Boolean(allow_refs=False, constant=True, default=False, label=’Speaking’, nested_refs=False, readonly=True, rx=<param.reactive.reactive_ops object at 0x303060850>)

A Boolean that returns true if an utterance is currently in the process of being spoken — even if TextToSpeak is in a paused state.

voices = param.List(allow_refs=False, bounds=(0, None), constant=True, default=[], label=’Voices’, nested_refs=False, readonly=True, rx=<param.reactive.reactive_ops object at 0x303062ad0>)

Returns a list of Voice objects representing all the available voices on the current device.

_voices = param.List(allow_refs=False, bounds=(0, None), default=[], label=’ voices’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3032ca090>)

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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

set_voices(voices)[source]#

Updates the lang and voice parameter objects, default and value

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

to_dict(include_uuid=True)[source]#

Returns the object parameter values in a dictionary

Returns:

[description]

Return type:

Dict

class panel.widgets.Toggle(**params)[source]#

Bases: _ButtonBase, IconMixin

The Toggle widget allows toggling a single condition between True/False states.

This widget is interchangeable with the Checkbox widget.

Reference: https://panel.holoviz.org/reference/widgets/Toggle.html

Example:

>>> Toggle(name='Toggle', button_type='success')

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.button.IconMixin: icon, icon_size

panel.widgets.button._ButtonBase: button_type, button_style

value = param.Boolean(allow_refs=False, default=False, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x303015b90>)

Whether the button is currently toggled.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.ToggleGroup(*, value, options, disabled, 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: SingleSelectBase

This class is a factory of ToggleGroup widgets.

A ToggleGroup is a group of widgets which can be switched ‘on’ or ‘off’.

Two types of widgets are available through the widget_type argument :
  • ‘button’ (default)

  • ‘box’

Two different behaviors are available through behavior argument:
  • ‘check’ (default)boolean

    Any number of widgets can be selected. In this case value is a ‘list’ of objects.

  • ‘radio’boolean

    One and only one widget is switched on. In this case value is an ‘object’.

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.select.SelectBase: options

panel.widgets.select.SingleSelectBase: value

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.ToggleIcon(*, active_icon, icon, size, value, description, description_delay, disabled, 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: _ClickableIcon, TooltipMixin

The ToggleIcon widget allows toggling a single condition between True/False states. This widget is interchangeable with the Checkbox and Toggle widget.

This widget incorporates a value attribute, which alternates between False and True.

Reference: https://panel.holoviz.org/reference/widgets/ToggleIcon.html

Example:

>>> pn.widgets.ToggleIcon(
...     icon="thumb-up", active_icon="thumb-down", size="4em", description="Like"
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets._mixin.TooltipMixin: description, description_delay

panel.widgets.icon._ClickableIcon: active_icon, icon, size, value

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.TooltipIcon(*, value, disabled, 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: Widget

The TooltipIcon displays a small ? icon. When you hover over the ? icon, the value will display.

Use the TooltipIcon to provide

  • helpful information to users without taking up a lot of screen space

  • tooltips next to Panel widgets that do not support tooltips yet.

Reference: https://panel.holoviz.org/reference/indicators/TooltipIcon.html

Example:

>>> pn.widgets.TooltipIcon(value="This is a simple tooltip by using a string")

Parameters inherited from:

panel.viewable.Layoutable: aspect_ratio, css_classes, design, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

align = param.Align(allow_refs=False, default=’center’, label=’Align’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x302cd0c50>)

Whether the object should be aligned with the start, end or center of its container. If set as a tuple it will declare (vertical, horizontal) alignment.

value = param.ClassSelector(allow_refs=False, class_=(<class ‘str’>, <class ‘bokeh.models.ui.tooltips.Tooltip’>), default=’Description’, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x302ddac10>)

The description in the tooltip.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.Tqdm(*, layout, lock, max, progress, text, text_pane, value, write_to_console, disabled, 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: Indicator

The Tqdm indicator wraps the well known tqdm progress indicator and displays the progress towards some target in your Panel app.

Reference: https://panel.holoviz.org/reference/indicators/Tqdm.html

Example:

>>> tqdm = Tqdm()
>>> for i in tqdm(range(0,10), desc="My loop", leave=True, colour='#666666'):
...     time.sleep(timeout)

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, disabled

panel.widgets.indicators.Indicator: sizing_mode

margin = param.Parameter(allow_refs=False, default=0, label=’Margin’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x302c89c50>)

Allows to create additional space around the component. May be specified as a two-tuple of the form (vertical, horizontal) or a four-tuple (top, right, bottom, left).

width = param.Integer(allow_refs=False, bounds=(0, None), default=400, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x302c8b650>)

The width of the component (in pixels). This can be either fixed or preferred width, depending on width sizing policy.

value = param.Integer(allow_refs=False, bounds=(-1, None), default=0, inclusive_bounds=(True, True), label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x302c8ac50>)

The current value of the progress bar. If set to -1 the progress bar will be indeterminate and animate depending on the active parameter.

layout = param.ClassSelector(allow_None=True, allow_refs=False, class_=(<class ‘panel.layout.base.Column’>, <class ‘panel.layout.base.Row’>), constant=True, label=’Layout’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x302c8a750>)

The layout for the text and progress indicator.

lock = param.ClassSelector(allow_None=True, allow_refs=False, class_=<class ‘object’>, label=’Lock’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x302c89c50>)

The multithreading.Lock or multiprocessing.Lock object to be used by Tqdm.

max = param.Integer(allow_refs=False, default=100, inclusive_bounds=(True, True), label=’Max’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x302c8ad10>)

The maximum value of the progress bar.

progress = param.ClassSelector(allow_None=True, allow_refs=False, class_=<class ‘panel.widgets.indicators.Progress’>, label=’Progress’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x302c8aa90>)

The Progress indicator used to display the progress.

text = param.String(allow_refs=False, default=’’, label=’Text’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x302c8b8d0>)

The current tqdm style progress text.

text_pane = param.ClassSelector(allow_None=True, allow_refs=False, class_=<class ‘panel.pane.markup.Str’>, label=’Text pane’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x302c899d0>)

The pane to display the text to.

write_to_console = param.Boolean(allow_refs=False, default=False, label=’Write to console’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x302c89cd0>)

Whether or not to also write to the console.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.

reset()[source]#

Resets the parameters

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.widgets.Trend(*, data, layout, neg_color, plot_color, plot_type, plot_x, plot_y, pos_color, value, value_change, selection, disabled, 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: SyncableData, Indicator

The Trend indicator enables the user to display a dashboard kpi card.

The card can be layout out as:

  • a column (text and plot on top of each other) or a row (text and

  • plot after each other)

Reference: https://panel.holoviz.org/reference/indicators/Trend.html

Example:

>>> data = {'x': np.arange(50), 'y': np.random.randn(50).cumsum()}
>>> Trend(name='Price', data=data, plot_type='area', width=200, height=200)

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.reactive.SyncableData: selection

sizing_mode = param.ObjectSelector(allow_refs=False, label=’Sizing mode’, names={}, nested_refs=False, objects=[‘fixed’, ‘stretch_width’, ‘stretch_height’, ‘stretch_both’, ‘scale_width’, ‘scale_height’, ‘scale_both’, None], rx=<param.reactive.reactive_ops object at 0x302c90bd0>)

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 and aspect_ratio instead (those take precedence over sizing_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.

data = param.Parameter(allow_None=True, allow_refs=False, label=’Data’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x302a42750>)

The plot data declared as a dictionary of arrays or a DataFrame.

layout = param.ObjectSelector(allow_refs=False, default=’column’, label=’Layout’, names={}, nested_refs=False, objects=[‘column’, ‘row’], rx=<param.reactive.reactive_ops object at 0x302a41290>)

plot_x = param.String(allow_refs=False, default=’x’, label=’Plot x’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x302a42910>)

The name of the key in the plot_data to use on the x-axis.

plot_y = param.String(allow_refs=False, default=’y’, label=’Plot y’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x302a411d0>)

The name of the key in the plot_data to use on the y-axis.

plot_color = param.String(allow_refs=False, default=’#428bca’, label=’Plot color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x302a42dd0>)

The color to use in the plot.

plot_type = param.ObjectSelector(allow_refs=False, default=’bar’, label=’Plot type’, names={}, nested_refs=False, objects=[‘line’, ‘step’, ‘area’, ‘bar’], rx=<param.reactive.reactive_ops object at 0x302a40590>)

The plot type to render the plot data as.

pos_color = param.String(allow_refs=False, default=’#5cb85c’, label=’Pos color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x302a41290>)

The color used to indicate a positive change.

neg_color = param.String(allow_refs=False, default=’#d9534f’, label=’Neg color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x302a40a10>)

The color used to indicate a negative change.

value = param.Parameter(allow_refs=False, default=’auto’, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x302a42750>)

The primary value to be displayed.

value_change = param.Parameter(allow_refs=False, default=’auto’, label=’Value change’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x302a40310>)

A secondary value. For example the change in percent.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.

patch(patch_value: 'pd.DataFrame' | 'pd.Series' | Dict) None[source]#

Efficiently patches (updates) the existing value with the patch_value.

Parameters:

patch_value ((pd.DataFrame | pd.Series | Dict)) – The value(s) to patch the existing value with.

Raises:

ValueError – Raised if the patch_value is not a supported type.:

Examples

Patch a DataFrame with a Dictionary row. >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> obj = DataComponent(value) >>> patch_value = {“x”: [(0, 3)]} >>> obj.patch(patch_value) >>> obj.value.to_dict(“list”) {‘x’: [3, 2], ‘y’: [‘a’, ‘b’]}

Patch a Dataframe with a Dictionary of Columns. >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> obj = DataComponent(value) >>> patch_value = {“x”: [(slice(2), (3,4))], “y”: [(1,’d’)]} >>> obj.patch(patch_value) >>> obj.value.to_dict(“list”) {‘x’: [3, 4], ‘y’: [‘a’, ‘d’]}

Patch a DataFrame with a Series. Please note the index is used in the update. >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> obj = DataComponent(value) >>> patch_value = pd.Series({“index”: 1, “x”: 4, “y”: “d”}) >>> obj.patch(patch_value) >>> obj.value.to_dict(“list”) {‘x’: [1, 4], ‘y’: [‘a’, ‘d’]}

Patch a Dataframe with a Dataframe. Please note the index is used in the update. >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> obj = DataComponent(value) >>> patch_value = pd.DataFrame({“x”: [3, 4], “y”: [“c”, “d”]}) >>> obj.patch(patch_value) >>> obj.value.to_dict(“list”) {‘x’: [3, 4], ‘y’: [‘c’, ‘d’]}

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

sizing_mode = None#
stream(stream_value: 'pd.DataFrame' | 'pd.Series' | Dict, rollover: Optional[int] = None, reset_index: bool = True) None[source]#

Streams (appends) the stream_value provided to the existing value in an efficient manner.

Parameters:
  • stream_value ((pd.DataFrame | pd.Series | Dict)) – The new value(s) to append to the existing value.

  • rollover ((int | None, default=None)) – A maximum column size, above which data from the start of the column begins to be discarded. If None, then columns will continue to grow unbounded.

  • (bool (reset_index) – If True and the stream_value is a DataFrame, then its index is reset. Helps to keep the index unique and named index.

  • default=True) – If True and the stream_value is a DataFrame, then its index is reset. Helps to keep the index unique and named index.

Raises:

ValueError – Raised if the stream_value is not a supported type.:

Examples

Stream a Series to a DataFrame >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> obj = DataComponent(value) >>> stream_value = pd.Series({“x”: 4, “y”: “d”}) >>> obj.stream(stream_value) >>> obj.value.to_dict(“list”) {‘x’: [1, 2, 4], ‘y’: [‘a’, ‘b’, ‘d’]}

Stream a Dataframe to a Dataframe >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> obj = DataComponent(value) >>> stream_value = pd.DataFrame({“x”: [3, 4], “y”: [“c”, “d”]}) >>> obj.stream(stream_value) >>> obj.value.to_dict(“list”) {‘x’: [1, 2, 3, 4], ‘y’: [‘a’, ‘b’, ‘c’, ‘d’]}

Stream a Dictionary row to a DataFrame >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = DataComponent(value) >>> stream_value = {“x”: 4, “y”: “d”} >>> obj.stream(stream_value) >>> obj.value.to_dict(“list”) {‘x’: [1, 2, 4], ‘y’: [‘a’, ‘b’, ‘d’]}

Stream a Dictionary of Columns to a Dataframe >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> obj = DataComponent(value) >>> stream_value = {“x”: [3, 4], “y”: [“c”, “d”]} >>> obj.stream(stream_value) >>> obj.value.to_dict(“list”) {‘x’: [1, 2, 3, 4], ‘y’: [‘a’, ‘b’, ‘c’, ‘d’]}

class panel.widgets.Utterance(*, lang, pitch, rate, value, voice, volume, name)[source]#

Bases: Parameterized

An utterance is the smallest unit of speech in spoken language analysis.

The Utterance Model wraps the HTML5 SpeechSynthesisUtterance API

See https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesisUtterance

value = param.String(allow_refs=False, default=’’, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x302a94250>)

The text that will be synthesised when the utterance is spoken. The text may be provided as plain text, or a well-formed SSML document.

lang = param.ObjectSelector(allow_refs=False, default=’’, label=’Lang’, names={}, nested_refs=False, objects=[‘’], rx=<param.reactive.reactive_ops object at 0x302a77290>)

The language of the utterance.

pitch = param.Number(allow_refs=False, bounds=(0.0, 2.0), default=1.0, inclusive_bounds=(True, True), label=’Pitch’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x302a75210>)

The pitch at which the utterance will be spoken at expressed as a number between 0 and 2.

rate = param.Number(allow_refs=False, bounds=(0.1, 10.0), default=1.0, inclusive_bounds=(True, True), label=’Rate’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x302a75fd0>)

The speed at which the utterance will be spoken at expressed as a number between 0.1 and 10.

voice = param.ObjectSelector(allow_refs=False, label=’Voice’, names={}, nested_refs=False, objects=[], rx=<param.reactive.reactive_ops object at 0x302a75e50>)

The voice that will be used to speak the utterance.

volume = param.Number(allow_refs=False, bounds=(0.0, 1.0), default=1.0, inclusive_bounds=(True, True), label=’Volume’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x302a75350>)

The volume that the utterance will be spoken at expressed as a number between 0 and 1.

set_voices(voices)[source]#

Updates the lang and voice parameter objects, default and value

to_dict(include_uuid=True)[source]#

Returns the object parameter values in a dictionary

Returns:

[description]

Return type:

Dict

class panel.widgets.VideoStream(*, format, paused, timeout, value, disabled, 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: Widget

The VideoStream displays a video from a local stream (for example from a webcam) and allows accessing the streamed video data from Python.

Reference: https://panel.holoviz.org/reference/widgets/VideoStream.html

Example:

>>> VideoStream(name='Video Stream', timeout=100)

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

format = param.ObjectSelector(allow_refs=False, default=’png’, label=’Format’, names={}, nested_refs=False, objects=[‘png’, ‘jpeg’], rx=<param.reactive.reactive_ops object at 0x302a2b190>)

The file format as which the video is returned.

paused = param.Boolean(allow_refs=False, default=False, label=’Paused’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x302a11310>)

Whether the video is currently paused

timeout = param.Number(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Timeout’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x302a11710>)

Interval between snapshots in millisecons

value = param.String(allow_refs=False, default=’’, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x302a11310>)

A base64 representation of the video stream snapshot.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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

snapshot()[source]#

Triggers a snapshot of the current VideoStream state to sync the widget value.

class panel.widgets.Voice(*, default, lang, local_service, voice_uri, name)[source]#

Bases: Parameterized

The current device (i.e. OS and Browser) provides a list of Voices. Each with a unique name and speaking a specific language.

Wraps the HTML5 SpeecSynthesisVoice API

See https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesisVoice

default = param.Boolean(allow_refs=False, constant=True, default=False, label=’Default’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30299ecd0>)

A Boolean indicating whether the voice is the default voice for the current app language (True), or not (False.)

lang = param.String(allow_refs=False, constant=True, default=’’, label=’Lang’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30286a4d0>)

Returns a BCP 47 language tag indicating the language of the voice.

local_service = param.Boolean(allow_refs=False, constant=True, default=False, label=’Local service’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30299ec50>)

A Boolean indicating whether the voice is supplied by a local speech synthesizer service (True), or a remote speech synthesizer service (False.)

voice_uri = param.String(allow_refs=False, constant=True, default=’’, label=’Voice uri’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30286a950>)

Returns the type of URI and location of the speech synthesis service for this voice.

static group_by_lang(voices)[source]#

Returns a dictionary where the key is the lang and the value is a list of voices for that language.

static to_voices_list(voices)[source]#

Returns a list of Voice objects from the list of dicts provided

class panel.widgets.Widget(*, disabled, 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: Reactive

Widgets allow syncing changes in bokeh widget models with the parameters on the Widget instance.

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, visible

panel.viewable.Viewable: loading

height = param.Integer(allow_None=True, allow_refs=True, bounds=(0, None), inclusive_bounds=(True, True), label=’Height’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x302793510>)

The height of the component (in pixels). This can be either fixed or preferred height, depending on height sizing policy.

margin = param.Margin(allow_None=True, allow_refs=True, default=(5, 10), label=’Margin’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x302992ed0>)

Allows to create additional space around the component. May be specified as a two-tuple of the form (vertical, horizontal) or a four-tuple (top, right, bottom, left).

width = param.Integer(allow_None=True, allow_refs=True, bounds=(0, None), inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x302793dd0>)

The width of the component (in pixels). This can be either fixed or preferred width, depending on width sizing policy.

disabled = param.Boolean(allow_refs=True, default=False, label=’Disabled’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x302993d50>)

Whether the widget is disabled.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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


_mixin Module#

Inheritance diagram of panel.widgets._mixin
class panel.widgets._mixin.TooltipMixin(*, description, description_delay, disabled, 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: Widget

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

description = param.ClassSelector(allow_None=True, allow_refs=True, class_=(<class ‘str’>, <class ‘bokeh.models.ui.tooltips.Tooltip’>, <class ‘panel.widgets.indicators.TooltipIcon’>), label=’Description’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30ed4b210>)

The description in the tooltip.

description_delay = param.Integer(allow_refs=True, default=500, inclusive_bounds=(True, True), label=’Description delay’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30e6a66d0>)

Delay (in milliseconds) to display the tooltip after the cursor has hovered over the Button, default is 500ms.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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


base Module#

Inheritance diagram of panel.widgets.base

Defines the Widget base class which provides bi-directional communication between the rendered dashboard and the Widget parameters.

class panel.widgets.base.CompositeWidget(*, disabled, 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: Widget

A baseclass for widgets which are made up of two or more other widgets

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.base.Widget(*, disabled, 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: Reactive

Widgets allow syncing changes in bokeh widget models with the parameters on the Widget instance.

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, visible

panel.viewable.Viewable: loading

height = param.Integer(allow_None=True, allow_refs=True, bounds=(0, None), inclusive_bounds=(True, True), label=’Height’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30ef3e6d0>)

The height of the component (in pixels). This can be either fixed or preferred height, depending on height sizing policy.

margin = param.Margin(allow_None=True, allow_refs=True, default=(5, 10), label=’Margin’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30eeb4fd0>)

Allows to create additional space around the component. May be specified as a two-tuple of the form (vertical, horizontal) or a four-tuple (top, right, bottom, left).

width = param.Integer(allow_None=True, allow_refs=True, bounds=(0, None), inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30eeb6c50>)

The width of the component (in pixels). This can be either fixed or preferred width, depending on width sizing policy.

disabled = param.Boolean(allow_refs=True, default=False, label=’Disabled’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30eeb5a10>)

Whether the widget is disabled.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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


button Module#

Inheritance diagram of panel.widgets.button

Defines the Button and button-like widgets which allow triggering events or merely toggling between on-off states.

class panel.widgets.button.Button(*, clicks, value, button_style, button_type, icon, icon_size, description, description_delay, disabled, 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: _ButtonBase, _ClickButton, IconMixin, TooltipMixin

The Button widget allows triggering events when the button is clicked.

The Button provides a value parameter, which will toggle from False to True while the click event is being processed

It also provides an additional clicks parameter, that can be watched to subscribe to click events.

Reference: https://panel.holoviz.org/reference/widgets/Button.html#widgets-gallery-button

Example:

>>> pn.widgets.Button(name='Click me', icon='caret-right', button_type='primary')

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets._mixin.TooltipMixin: description, description_delay

panel.widgets.button.IconMixin: icon, icon_size

panel.widgets.button._ButtonBase: button_type, button_style

clicks = param.Integer(allow_refs=True, default=0, inclusive_bounds=(True, True), label=’Clicks’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30f1166d0>)

Number of clicks (can be listened to)

value = param.Event(allow_refs=True, default=False, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30f438410>)

Toggles from False to True while the event is being processed.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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

js_on_click(args: Dict[str, Any] = {}, code: str = '') Callback[source]#

Allows defining a JS callback to be triggered when the button is clicked.

Parameters:
  • args (dict) – A mapping of objects to make available to the JS callback

  • code (str) – The Javascript code to execute when the button is clicked.

Returns:

callback – The Callback which can be used to disable the callback.

Return type:

Callback

jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback[source]#

Allows defining a Javascript (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:

Callback

Links properties on the this Button to those on the target object in Javascript (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(s) 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. Default is False.

  • **links (dict[str,str]) – A mapping between properties on the source model and the target model property to link it to.

Returns:

The Link can be used unlink the widget and the target model.

Return type:

Link

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_click(callback: Callable[[Event], Union[None, Awaitable[None]]]) Watcher[source]#

Register a callback to be executed when the Button is clicked.

The callback is given an Event argument declaring the number of clicks

Example

>>> button = pn.widgets.Button(name='Click me')
>>> def handle_click(event):
...    print("I was clicked!")
>>> button.on_click(handle_click)
Parameters:

callback – The function to run on click events. Must accept a positional Event argument. Can be a sync or async function

Returns:

watcher – A Watcher that executes the callback when the button is clicked.

Return type:

param.Parameterized.Watcher

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.widgets.button.IconMixin(**params)[source]#

Bases: Widget

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

icon = param.String(allow_None=True, allow_refs=True, label=’Icon’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30f116710>)

An icon to render to the left of the button label. Either an SVG or an icon name which is loaded from https://tabler-icons.io.

icon_size = param.String(allow_refs=True, default=’1em’, label=’Icon size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30f43bed0>)

Size of the icon as a string, e.g. 12px or 1em.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.button.MenuButton(*, clicked, items, split, button_style, button_type, icon, icon_size, disabled, 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: _ButtonBase, _ClickButton, IconMixin

The MenuButton widget allows specifying a list of menu items to select from triggering events when the button is clicked.

Unlike other widgets, it does not have a value parameter. Instead it has a clicked parameter that can be watched to trigger events and which reports the last clicked menu item.

Reference: https://panel.holoviz.org/reference/widgets/MenuButton.html

Example:

>>> menu_items = [('Option A', 'a'), ('Option B', 'b'), None, ('Option C', 'c')]
>>> MenuButton(name='Dropdown', items=menu_items, button_type='primary')

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.button.IconMixin: icon, icon_size

panel.widgets.button._ButtonBase: button_type, button_style

clicked = param.String(allow_None=True, allow_refs=False, label=’Clicked’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30f43bd10>)

Last menu item that was clicked.

items = param.List(allow_refs=False, bounds=(0, None), default=[], label=’Items’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30f482010>)

Menu items in the dropdown. Allows strings, tuples of the form (title, value) or Nones to separate groups of items.

split = param.Boolean(allow_refs=False, default=False, label=’Split’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30f44f9d0>)

Whether to add separate dropdown area to button.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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

js_on_click(args: Dict[str, Any] = {}, code: str = '') Callback[source]#

Allows defining a JS callback to be triggered when the button is clicked.

Parameters:
  • args (dict) – A mapping of objects to make available to the JS callback

  • code (str) – The Javascript code to execute when the button is clicked.

Returns:

callback – The Callback which can be used to disable the callback.

Return type:

Callback

jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback[source]#

Allows defining a Javascript (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:

Callback

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

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_click(callback: Callable[[Event], None]) Watcher[source]#

Register a callback to be executed when the button is clicked.

The callback is given an Event argument declaring the number of clicks

Parameters:

callback ((Callable[[param.parameterized.Event], None])) – The function to run on click events. Must accept a positional Event argument

Returns:

watcher – A Watcher that executes the callback when the MenuButton is clicked.

Return type:

param.Parameterized.Watcher

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.widgets.button.Toggle(**params)[source]#

Bases: _ButtonBase, IconMixin

The Toggle widget allows toggling a single condition between True/False states.

This widget is interchangeable with the Checkbox widget.

Reference: https://panel.holoviz.org/reference/widgets/Toggle.html

Example:

>>> Toggle(name='Toggle', button_type='success')

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.button.IconMixin: icon, icon_size

panel.widgets.button._ButtonBase: button_type, button_style

value = param.Boolean(allow_refs=False, default=False, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30f4832d0>)

Whether the button is currently toggled.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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


codeeditor Module#

Inheritance diagram of panel.widgets.codeeditor

Defines the CodeEditor widget based on Ace.

class panel.widgets.codeeditor.CodeEditor(*, annotations, filename, language, print_margin, readonly, theme, value, disabled, 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: Widget

The CodeEditor widget allows displaying and editing code in the powerful Ace editor.

Reference: https://panel.holoviz.org/reference/widgets/CodeEditor.html

Example:

>>> CodeEditor(value=py_code, language='python', theme='monokai')

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

annotations = param.List(allow_refs=False, bounds=(0, None), default=[], label=’Annotations’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30fd8c110>)

List of annotations to add to the editor.

filename = param.String(allow_refs=False, default=’’, label=’Filename’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30fd8a7d0>)

Filename from which to deduce language

language = param.String(allow_refs=False, default=’text’, label=’Language’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30fa7ab50>)

Language of the editor

print_margin = param.Boolean(allow_refs=False, default=False, label=’Print margin’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30fd8b050>)

Whether to show the a print margin.

readonly = param.Boolean(allow_refs=False, default=False, label=’Readonly’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30fd8c690>)

Define if editor content can be modified. Alias for disabled.

theme = param.ObjectSelector(allow_refs=False, default=’chrome’, label=’Theme’, names={}, nested_refs=False, objects=[‘ambiance’, ‘chaos’, ‘chrome’, ‘clouds’, ‘clouds_midnight’, ‘cobalt’, ‘crimson_editor’, ‘dawn’, ‘dracula’, ‘dreamweaver’, ‘eclipse’, ‘github’, ‘gob’, ‘gruvbox’, ‘idle_fingers’, ‘iplastic’, ‘katzenmilch’, ‘kr_theme’, ‘kuroir’, ‘merbivore’, ‘merbivore_soft’, ‘mono_industrial’, ‘monokai’, ‘pastel_on_dark’, ‘solarized_dark’, ‘solarized_light’, ‘sqlserver’, ‘terminal’, ‘textmate’, ‘tomorrow’, ‘tomorrow_night’, ‘tomorrow_night_blue’, ‘tomorrow_night_bright’, ‘tomorrow_night_eighties’, ‘twilight’, ‘vibrant_ink’, ‘xcode’], rx=<param.reactive.reactive_ops object at 0x30f987750>)

Theme of the editor

value = param.String(allow_refs=False, default=’’, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30fd8c1d0>)

State of the current code in the editor

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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


debugger Module#

Inheritance diagram of panel.widgets.debugger

The Debugger Widget is an uneditable Card that gives you feedback on errors thrown by your Panel callbacks.

class panel.widgets.debugger.CheckFilter(name='')[source]#

Bases: Filter

add_debugger(debugger)[source]#

Add a debugger to this logging filter.

Parameters:

widg (panel.widgets.Debugger) – The widget displaying the logs.

Return type:

None.

filter(record)[source]#

Will filter out messages coming from a different bokeh document than the document where the debugger is embedded in server mode. Returns True if no debugger was added.

class panel.widgets.debugger.Debugger(*, _number_of_errors, _number_of_infos, _number_of_warnings, formatter_args, level, logger_names, only_last, active_header_background, button_css_classes, collapsed, collapsible, header, header_background, header_color, header_css_classes, hide_header, title, title_css_classes, auto_scroll_limit, scroll_button_threshold, scroll_position, view_latest, scroll, 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: Card

A uneditable Card layout holding a terminal printing out logs from your callbacks. By default, it will only print exceptions. If you want to add your own log, use the panel.callbacks logger within your callbacks: logger = logging.getLogger(‘panel.callbacks’)

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, visible

panel.viewable.Viewable: loading

panel.layout.base.ListLike: objects

panel.layout.base.ListPanel: scroll

panel.layout.base.Column: auto_scroll_limit, scroll_button_threshold, scroll_position, view_latest

panel.layout.card.Card: css_classes, active_header_background, button_css_classes, collapsible, collapsed, header, header_background, header_color, header_css_classes, hide_header, title_css_classes, title

_number_of_errors = param.Integer(allow_refs=False, bounds=(0, None), default=0, inclusive_bounds=(True, True), label=’ number of errors’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30f8766d0>)

Number of logged errors since last acknowledged.

_number_of_warnings = param.Integer(allow_refs=False, bounds=(0, None), default=0, inclusive_bounds=(True, True), label=’ number of warnings’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30f90ffd0>)

Number of logged warnings since last acknowledged.

_number_of_infos = param.Integer(allow_refs=False, bounds=(0, None), default=0, inclusive_bounds=(True, True), label=’ number of infos’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30fee2810>)

Number of logged information since last acknowledged.

only_last = param.Boolean(allow_refs=False, default=True, label=’Only last’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30f96b9d0>)

Whether only the last stack is printed or the full.

level = param.Integer(allow_refs=False, default=40, inclusive_bounds=(True, True), label=’Level’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30fee2a10>)

Logging level to print in the debugger terminal.

formatter_args = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={‘fmt’: ‘%(asctime)s [%(name)s - %(levelname)s]: %(message)s’}, label=’Formatter args’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30f96b6d0>)

Arguments to pass to the logging formatter. See the standard python logging libraries.

logger_names = param.List(allow_refs=False, bounds=(1, None), class_=<class ‘str’>, default=[‘panel’], item_type=<class ‘str’>, label=’Logger names’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30fa027d0>)

Loggers which will be prompted in the debugger terminal.

append(obj: Any) None[source]#

Appends an object to the layout.

Parameters:

(object) (obj) –

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:

Callback

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

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) –

reverse() None[source]#

Reverses the objects in the layout.

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.widgets.debugger.DebuggerButtons(*, clears, debug_name, terminal_output, 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

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, visible

panel.viewable.Viewable: loading

terminal_output = param.String(allow_refs=False, default=’’, label=’Terminal output’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30fd12890>)

debug_name = param.String(allow_refs=False, default=’’, label=’Debug name’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30f803e10>)

clears = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Clears’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30f800210>)

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:

Callback

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

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: 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.widgets.debugger.TermFormatter(*args, only_last=True, **kwargs)[source]#

Bases: Formatter

converter()#
localtime([seconds]) -> (tm_year,tm_mon,tm_mday,tm_hour,tm_min,

tm_sec,tm_wday,tm_yday,tm_isdst)

Convert seconds since the Epoch to a time tuple expressing local time. When ‘seconds’ is not passed in, convert the current time instead.

format(record)[source]#

Format the specified record as text.

The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.

formatException(ei)[source]#

Format and return the specified exception information as a string.

This default implementation just uses traceback.print_exception()

formatStack(stack_info)[source]#

This method is provided as an extension point for specialized formatting of stack information.

The input data is a string as returned from a call to traceback.print_stack(), but with the last trailing newline removed.

The base implementation just returns the value passed in.

formatTime(record, datefmt=None)[source]#

Return the creation time of the specified LogRecord as formatted text.

This method should be called from format() by a formatter which wants to make use of a formatted time. This method can be overridden in formatters to provide for any specific requirement, but the basic behaviour is as follows: if datefmt (a string) is specified, it is used with time.strftime() to format the creation time of the record. Otherwise, an ISO8601-like (or RFC 3339-like) format is used. The resulting string is returned. This function uses a user-configurable function to convert the creation time to a tuple. By default, time.localtime() is used; to change this for a particular formatter instance, set the ‘converter’ attribute to a function with the same signature as time.localtime() or time.gmtime(). To change it for all formatters, for example if you want all logging times to be shown in GMT, set the ‘converter’ attribute in the Formatter class.

usesTime()[source]#

Check if the format uses the creation time of the record.


file_selector Module#

Inheritance diagram of panel.widgets.file_selector

Defines a FileSelector widget which allows selecting files and directories on the server.

class panel.widgets.file_selector.FileSelector(directory: Optional[Union[AnyStr, PathLike]] = None, **params)[source]#

Bases: CompositeWidget

The FileSelector widget allows browsing the filesystem on the server and selecting one or more files in a directory.

Reference: https://panel.holoviz.org/reference/widgets/FileSelector.html

Example:

>>> FileSelector(directory='~', file_pattern='*.png')

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

directory = param.String(allow_refs=False, default=’/Users/runner/work/panel/panel/doc’, label=’Directory’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30d4319d0>)

The directory to explore.

file_pattern = param.String(allow_refs=False, default=’*’, label=’File pattern’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30d430d10>)

A glob-like pattern to filter the files.

only_files = param.Boolean(allow_refs=False, default=False, label=’Only files’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30d431990>)

Whether to only allow selecting files.

show_hidden = param.Boolean(allow_refs=False, default=False, label=’Show hidden’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30d4307d0>)

Whether to show hidden files and directories (starting with a period).

size = param.Integer(allow_refs=False, default=10, inclusive_bounds=(True, True), label=’Size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30d432e50>)

The number of options shown at once (note this is the only way to control the height of this widget)

refresh_period = param.Integer(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Refresh period’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30d5987d0>)

If set to non-None value indicates how frequently to refresh the directory contents in milliseconds.

root_directory = param.String(allow_None=True, allow_refs=False, label=’Root directory’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30d4326d0>)

If set, overrides directory parameter as the root directory beyond which users cannot navigate.

value = param.List(allow_refs=False, bounds=(0, None), default=[], label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30d430190>)

List of selected files.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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


icon Module#

Inheritance diagram of panel.widgets.icon
class panel.widgets.icon.ButtonIcon(*, clicks, toggle_duration, active_icon, icon, size, value, description, description_delay, disabled, 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: _ClickableIcon, _ClickButton, TooltipMixin

The ButtonIcon widget facilitates event triggering upon button clicks.

This widget displays a default icon initially. Upon being clicked, an active_icon appears for a specified toggle_duration.

For instance, the ButtonIcon can be effectively utilized to implement a feature akin to ChatGPT’s copy-to-clipboard button.

The button incorporates a value attribute, which alternates between False and True as the click event is processed.

Furthermore, it includes an clicks attribute, enabling subscription to click events for further actions or monitoring.

Reference: https://panel.holoviz.org/reference/widgets/ButtonIcon.html

Example:

>>> button_icon = pn.widgets.ButtonIcon(
...     icon='clipboard',
...     active_icon='check',
...     description='Copy',
...     toggle_duration=2000
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets._mixin.TooltipMixin: description, description_delay

panel.widgets.icon._ClickableIcon: active_icon, icon, size

value = param.Boolean(allow_refs=False, default=False, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30c0e6110>)

Toggles from False to True while the event is being processed.

clicks = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Clicks’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30c0f2e50>)

The number of times the button has been clicked.

toggle_duration = param.Integer(allow_refs=False, default=75, inclusive_bounds=(True, True), label=’Toggle duration’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30c0aea10>)

The number of milliseconds the active_icon should be shown for and how long the button should be disabled for.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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

js_on_click(args: Dict[str, Any] = {}, code: str = '') Callback[source]#

Allows defining a JS callback to be triggered when the button is clicked.

Parameters:
  • args (dict) – A mapping of objects to make available to the JS callback

  • code (str) – The Javascript code to execute when the button is clicked.

Returns:

callback – The Callback which can be used to disable the callback.

Return type:

Callback

jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback[source]#

Allows defining a Javascript (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:

Callback

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

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_click(callback: Callable[[Event], None]) Watcher[source]#

Register a callback to be executed when the button is clicked.

The callback is given an Event argument declaring the number of clicks.

Parameters:

callback ((Callable[[param.parameterized.Event], None])) – The function to run on click events. Must accept a positional Event argument

Returns:

watcher – A Watcher that executes the callback when the MenuButton is clicked.

Return type:

param.Parameterized.Watcher

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.widgets.icon.ToggleIcon(*, active_icon, icon, size, value, description, description_delay, disabled, 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: _ClickableIcon, TooltipMixin

The ToggleIcon widget allows toggling a single condition between True/False states. This widget is interchangeable with the Checkbox and Toggle widget.

This widget incorporates a value attribute, which alternates between False and True.

Reference: https://panel.holoviz.org/reference/widgets/ToggleIcon.html

Example:

>>> pn.widgets.ToggleIcon(
...     icon="thumb-up", active_icon="thumb-down", size="4em", description="Like"
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets._mixin.TooltipMixin: description, description_delay

panel.widgets.icon._ClickableIcon: active_icon, icon, size, value

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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


indicators Module#

Inheritance diagram of panel.widgets.indicators

Indicators#

Indicators can be used to indicate status or progress

Check out the Panel gallery of indicators https://panel.holoviz.org/reference/index.html#indicators for inspiration.

How to use indicators#

>>> pn.indicators.Number(
...    name='Rate', value=72, format='{value}%',
...    colors=[(80, 'green'), (100, 'red')]
... )
class panel.widgets.indicators.BooleanIndicator(*, throttle, value, disabled, 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: Indicator

BooleanIndicator is an abstract baseclass for indicators that visually indicate a boolean value.

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.indicators.Indicator: sizing_mode

throttle = param.Integer(allow_refs=True, default=500, inclusive_bounds=(True, True), label=’Throttle’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30ab8e6d0>)

” Throttles value change events, ensuring that they only toggle off after a minimum time specified in milliseconds has passed.

value = param.Boolean(allow_refs=False, default=False, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30987de90>)

Whether the indicator is active or not.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.indicators.BooleanStatus(*, color, throttle, value, disabled, 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: BooleanIndicator

The BooleanStatus is a boolean indicator providing a visual representation of a boolean status as filled or non-filled circle.

If the value is set to True the indicator will be filled while setting it to False will cause it to be non-filled.

Reference: https://panel.holoviz.org/reference/indicators/BooleanStatus.html

Example:

>>> BooleanStatus(value=True, color='primary', width=100, height=100)

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: margin, disabled

panel.widgets.indicators.Indicator: sizing_mode

panel.widgets.indicators.BooleanIndicator: throttle

height = param.Integer(allow_refs=False, bounds=(0, None), default=20, inclusive_bounds=(True, True), label=’Height’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309f67a90>)

height of the circle.

width = param.Integer(allow_refs=False, bounds=(0, None), default=20, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309716290>)

Width of the circle.

value = param.Boolean(allow_refs=False, default=False, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309f750d0>)

Whether the indicator is active or not.

color = param.ObjectSelector(allow_refs=False, default=’dark’, label=’Color’, names={}, nested_refs=False, objects=[‘primary’, ‘secondary’, ‘success’, ‘info’, ‘danger’, ‘warning’, ‘light’, ‘dark’], rx=<param.reactive.reactive_ops object at 0x30ee7f750>)

The color of the circle, one of ‘primary’, ‘secondary’, ‘success’, ‘info’, ‘danger’, ‘warning’, ‘light’, ‘dark’

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.indicators.Dial(*, annulus_width, background, bounds, colors, default_color, end_angle, format, label_color, nan_format, needle_color, needle_width, start_angle, tick_size, title_size, unfilled_color, value_size, value, disabled, 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: ValueIndicator

A Dial represents a value in some range as a position on an annular dial. It is similar to a Gauge but more minimal visually.

Reference: https://panel.holoviz.org/reference/indicators/Dial.html

Example:

>>> Dial(name='Speed', value=79, format="{value} km/h", bounds=(0, 200), colors=[(0.4, 'green'), (1, 'red')])

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: margin, disabled

panel.widgets.indicators.Indicator: sizing_mode

height = param.Integer(allow_refs=False, bounds=(1, None), default=250, inclusive_bounds=(True, True), label=’Height’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3096f0a50>)

The height of the component (in pixels). This can be either fixed or preferred height, depending on height sizing policy.

width = param.Integer(allow_refs=False, bounds=(1, None), default=250, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3097af650>)

The width of the component (in pixels). This can be either fixed or preferred width, depending on width sizing policy.

value = param.Number(allow_None=True, allow_refs=False, default=25, inclusive_bounds=(True, True), label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309eb7910>)

Value to indicate on the dial a value within the declared bounds.

annulus_width = param.Number(allow_refs=False, default=0.2, inclusive_bounds=(True, True), label=’Annulus width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3097ad8d0>)

Width of the radial annulus as a fraction of the total.

background = param.Parameter(allow_None=True, allow_refs=False, label=’Background’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3097179d0>)

Background color of the component.

bounds = param.Range(allow_refs=False, default=(0, 100), inclusive_bounds=(True, True), label=’Bounds’, length=2, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30987e6d0>)

The upper and lower bound of the dial.

colors = param.List(allow_None=True, allow_refs=False, bounds=(0, None), label=’Colors’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309717d10>)

Color thresholds for the Dial, specified as a list of tuples of the fractional threshold and the color to switch to.

default_color = param.String(allow_refs=False, default=’lightblue’, label=’Default color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30ab7e710>)

Color of the radial annulus if not color thresholds are supplied.

end_angle = param.Number(allow_refs=False, default=25, inclusive_bounds=(True, True), label=’End angle’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309eb7790>)

Angle at which the dial ends.

format = param.String(allow_refs=False, default=’{value}%’, label=’Format’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309716990>)

Formatting string for the value indicator and lower/upper bounds.

label_color = param.String(allow_refs=False, default=’black’, label=’Label color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309716710>)

Color for all extraneous labels.

nan_format = param.String(allow_refs=False, default=’-’, label=’Nan format’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309db8c50>)

How to format nan values.

needle_color = param.String(allow_refs=False, default=’black’, label=’Needle color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309716bd0>)

Color of the Dial needle.

needle_width = param.Number(allow_refs=False, default=0.1, inclusive_bounds=(True, True), label=’Needle width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309eb7910>)

Radial width of the needle.

start_angle = param.Number(allow_refs=False, default=-205, inclusive_bounds=(True, True), label=’Start angle’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3097acc10>)

Angle at which the dial starts.

tick_size = param.String(allow_None=True, allow_refs=False, label=’Tick size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309db8c50>)

Font size of the Dial min/max labels.

title_size = param.String(allow_None=True, allow_refs=False, label=’Title size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309714950>)

Font size of the Dial title.

unfilled_color = param.String(allow_refs=False, default=’whitesmoke’, label=’Unfilled color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309db8c50>)

Color of the unfilled region of the Dial.

value_size = param.String(allow_None=True, allow_refs=False, label=’Value size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309716990>)

Font size of the Dial value label.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.indicators.Gauge(*, annulus_width, bounds, colors, custom_opts, end_angle, format, num_splits, show_labels, show_ticks, start_angle, title_size, tooltip_format, value, disabled, 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: ValueIndicator

A Gauge represents a value in some range as a position on speedometer or gauge. It is similar to a Dial but visually a lot busier.

Reference: https://panel.holoviz.org/reference/indicators/Gauge.html

Example:

>>> Gauge(name='Speed', value=79, bounds=(0, 200), colors=[(0.4, 'green'), (1, 'red')])

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: margin, disabled

panel.widgets.indicators.Indicator: sizing_mode

height = param.Integer(allow_refs=False, bounds=(0, None), default=300, inclusive_bounds=(True, True), label=’Height’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3095afa10>)

The height of the component (in pixels). This can be either fixed or preferred height, depending on height sizing policy.

width = param.Integer(allow_refs=False, bounds=(0, None), default=300, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3096621d0>)

The width of the component (in pixels). This can be either fixed or preferred width, depending on width sizing policy.

value = param.Number(allow_refs=False, default=25, inclusive_bounds=(True, True), label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3095af9d0>)

Value to indicate on the gauge a value within the declared bounds.

annulus_width = param.Integer(allow_refs=False, default=10, inclusive_bounds=(True, True), label=’Annulus width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309663150>)

Width of the gauge annulus.

bounds = param.Range(allow_refs=False, default=(0, 100), inclusive_bounds=(True, True), label=’Bounds’, length=2, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3095ac9d0>)

The upper and lower bound of the dial.

colors = param.List(allow_None=True, allow_refs=False, bounds=(0, None), label=’Colors’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3096622d0>)

Color thresholds for the Gauge, specified as a list of tuples of the fractional threshold and the color to switch to.

custom_opts = param.Dict(allow_None=True, allow_refs=False, class_=<class ‘dict’>, label=’Custom opts’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3094d4890>)

Additional options to pass to the ECharts Gauge definition.

end_angle = param.Number(allow_refs=False, default=-45, inclusive_bounds=(True, True), label=’End angle’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309663050>)

Angle at which the gauge ends.

format = param.String(allow_refs=False, default=’{value}%’, label=’Format’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3094d4490>)

Formatting string for the value indicator.

num_splits = param.Integer(allow_refs=False, default=10, inclusive_bounds=(True, True), label=’Num splits’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3096622d0>)

Number of splits along the gauge.

show_ticks = param.Boolean(allow_refs=False, default=True, label=’Show ticks’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3094d4390>)

Whether to show ticks along the dials.

show_labels = param.Boolean(allow_refs=False, default=True, label=’Show labels’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309663a10>)

Whether to show tick labels along the dials.

start_angle = param.Number(allow_refs=False, default=225, inclusive_bounds=(True, True), label=’Start angle’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3096629d0>)

Angle at which the gauge starts.

tooltip_format = param.String(allow_refs=False, default=’{b}{c}%’, label=’Tooltip format’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309663a10>)

Formatting string for the hover tooltip.

title_size = param.Integer(allow_refs=False, default=18, inclusive_bounds=(True, True), label=’Title size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309663210>)

Size of title font.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.indicators.LinearGauge(*, bounds, colors, default_color, format, horizontal, nan_format, needle_color, show_boundaries, tick_size, title_size, unfilled_color, value_size, value, disabled, 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: ValueIndicator

A LinearGauge represents a value in some range as a position on an linear scale. It is similar to a Dial/Gauge but visually more compact.

Reference: https://panel.holoviz.org/reference/indicators/LinearGauge.html

Example:

>>> LinearGauge(value=30, default_color='red', bounds=(0, 100))

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: margin, disabled

panel.widgets.indicators.Indicator: sizing_mode

height = param.Integer(allow_refs=False, bounds=(1, None), default=300, inclusive_bounds=(True, True), label=’Height’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30953e650>)

The height of the component (in pixels). This can be either fixed or preferred height, depending on height sizing policy.

width = param.Integer(allow_refs=False, bounds=(1, None), default=125, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30953ab10>)

The width of the component (in pixels). This can be either fixed or preferred width, depending on width sizing policy.

value = param.Number(allow_None=True, allow_refs=False, default=25, inclusive_bounds=(True, True), label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30953dc10>)

Value to indicate on the dial a value within the declared bounds.

bounds = param.Range(allow_refs=False, default=(0, 100), inclusive_bounds=(True, True), label=’Bounds’, length=2, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30953ae10>)

The upper and lower bound of the gauge.

default_color = param.String(allow_refs=False, default=’lightblue’, label=’Default color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30953cdd0>)

Color of the radial annulus if not color thresholds are supplied.

colors = param.Parameter(allow_None=True, allow_refs=False, label=’Colors’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309539490>)

Color thresholds for the gauge, specified as a list of tuples of the fractional threshold and the color to switch to.

format = param.String(allow_refs=False, default=’{value:.2f}%’, label=’Format’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30953db50>)

Formatting string for the value indicator and lower/upper bounds.

horizontal = param.Boolean(allow_refs=False, default=False, label=’Horizontal’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3095393d0>)

Whether to display the linear gauge horizontally.

nan_format = param.String(allow_refs=False, default=’-’, label=’Nan format’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30953db50>)

How to format nan values.

needle_color = param.String(allow_refs=False, default=’black’, label=’Needle color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3095393d0>)

Color of the gauge needle.

show_boundaries = param.Boolean(allow_refs=False, default=False, label=’Show boundaries’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30953cd50>)

Whether to show the boundaries between colored regions.

unfilled_color = param.String(allow_refs=False, default=’whitesmoke’, label=’Unfilled color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309539610>)

Color of the unfilled region of the LinearGauge.

title_size = param.String(allow_None=True, allow_refs=False, label=’Title size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30953ce90>)

Font size of the gauge title.

tick_size = param.String(allow_None=True, allow_refs=False, label=’Tick size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309538190>)

Font size of the gauge tick labels.

value_size = param.String(allow_None=True, allow_refs=False, label=’Value size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30953ce90>)

Font size of the gauge value label.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.indicators.LoadingSpinner(*, bgcolor, color, size, throttle, value, disabled, 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: BooleanIndicator

The LoadingSpinner is a boolean indicator providing a visual representation of the loading status.

If the value is set to True the spinner will rotate while setting it to False will disable the rotating segment.

Reference: https://panel.holoviz.org/reference/indicators/LoadingSpinner.html

Example:

>>> LoadingSpinner(value=True, color='primary', bgcolor='light', width=100, height=100)

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.indicators.Indicator: sizing_mode

panel.widgets.indicators.BooleanIndicator: throttle

value = param.Boolean(allow_refs=True, default=False, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309525650>)

Whether the indicator is active or not.

bgcolor = param.ObjectSelector(allow_refs=True, default=’light’, label=’Bgcolor’, names={}, nested_refs=False, objects=[‘dark’, ‘light’], rx=<param.reactive.reactive_ops object at 0x3094a7ad0>)

color = param.ObjectSelector(allow_refs=True, default=’dark’, label=’Color’, names={}, nested_refs=False, objects=[‘primary’, ‘secondary’, ‘success’, ‘info’, ‘danger’, ‘warning’, ‘light’, ‘dark’], rx=<param.reactive.reactive_ops object at 0x3094a7710>)

size = param.Integer(allow_refs=True, default=125, inclusive_bounds=(True, True), label=’Size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3094a6f90>)

Size of the spinner in pixels.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.indicators.Number(*, colors, default_color, font_size, format, nan_format, title_size, value, disabled, 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: ValueIndicator

The Number indicator renders the value as text optionally colored according to the colors thresholds.

Reference: https://panel.holoviz.org/reference/indicators/Number.html

Example:

>>> Number(name='Rate', value=72, format='{value}%', colors=[(80, 'green'), (100, 'red')]

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.indicators.Indicator: sizing_mode

panel.widgets.indicators.ValueIndicator: value

default_color = param.String(allow_refs=False, default=’black’, label=’Default color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309580bd0>)

The color of the Number indicator if no colors are provided

colors = param.List(allow_None=True, allow_refs=False, bounds=(0, None), label=’Colors’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309714b10>)

Color thresholds for the Number indicator, specified as a tuple of the absolute thresholds and the color to switch to.

format = param.String(allow_refs=False, default=’{value}’, label=’Format’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309467fd0>)

A formatter string which accepts a {value}.

font_size = param.String(allow_refs=False, default=’54pt’, label=’Font size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309465d50>)

The size of number itself.

nan_format = param.String(allow_refs=False, default=’-’, label=’Nan format’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309467fd0>)

How to format nan values.

title_size = param.String(allow_refs=False, default=’18pt’, label=’Title size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309465d50>)

The size of the title given by the name.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.indicators.Progress(*, active, bar_color, max, value, disabled, 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: ValueIndicator

The Progress widget displays the progress towards some target based on the current value and the max value.

If no value is set, the Progress widget is in indeterminate mode and will animate depending on whether it is active or not. A more beautiful indicator for this use case is the LoadingSpinner.

Reference: https://panel.holoviz.org/reference/indicators/Progress.html

Example:

>>> Progress(value=20, max=100, bar_color="primary")

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

width = param.Integer(allow_refs=False, bounds=(0, None), default=300, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309233310>)

The width of the component (in pixels). This can be either fixed or preferred width, depending on width sizing policy.

sizing_mode = param.ObjectSelector(allow_refs=False, label=’Sizing mode’, names={}, nested_refs=False, objects=[‘fixed’, ‘stretch_width’, ‘stretch_height’, ‘stretch_both’, ‘scale_width’, ‘scale_height’, ‘scale_both’, None], rx=<param.reactive.reactive_ops object at 0x30946ab10>)

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 and aspect_ratio instead (those take precedence over sizing_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.

value = param.Integer(allow_refs=False, bounds=(-1, None), default=-1, inclusive_bounds=(True, True), label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309469410>)

The current value of the progress bar. If set to -1 the progress bar will be indeterminate and animate depending on the active parameter.

active = param.Boolean(allow_refs=False, default=True, label=’Active’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309469b90>)

If no value is set the active property toggles animation of the progress bar on and off.

bar_color = param.ObjectSelector(allow_refs=False, default=’success’, label=’Bar color’, names={}, nested_refs=False, objects=[‘primary’, ‘secondary’, ‘success’, ‘info’, ‘danger’, ‘warning’, ‘light’, ‘dark’], rx=<param.reactive.reactive_ops object at 0x3093e0250>)

max = param.Integer(allow_refs=False, default=100, inclusive_bounds=(True, True), label=’Max’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3094684d0>)

The maximum value of the progress bar.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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

sizing_mode = None#
class panel.widgets.indicators.String(*, default_color, font_size, title_size, value, disabled, 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: ValueIndicator

The String indicator renders a string with a title.

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.indicators.Indicator: sizing_mode

value = param.String(allow_None=True, allow_refs=False, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3092fa250>)

The string to display

default_color = param.String(allow_refs=False, default=’black’, label=’Default color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30930ec50>)

The color of the Number indicator if no colors are provided

font_size = param.String(allow_refs=False, default=’54pt’, label=’Font size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3092f9750>)

The size of number itself.

title_size = param.String(allow_refs=False, default=’18pt’, label=’Title size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30930d9d0>)

The size of the title given by the name.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.indicators.TooltipIcon(*, value, disabled, 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: Widget

The TooltipIcon displays a small ? icon. When you hover over the ? icon, the value will display.

Use the TooltipIcon to provide

  • helpful information to users without taking up a lot of screen space

  • tooltips next to Panel widgets that do not support tooltips yet.

Reference: https://panel.holoviz.org/reference/indicators/TooltipIcon.html

Example:

>>> pn.widgets.TooltipIcon(value="This is a simple tooltip by using a string")

Parameters inherited from:

panel.viewable.Layoutable: aspect_ratio, css_classes, design, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

align = param.Align(allow_refs=False, default=’center’, label=’Align’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309296c10>)

Whether the object should be aligned with the start, end or center of its container. If set as a tuple it will declare (vertical, horizontal) alignment.

value = param.ClassSelector(allow_refs=False, class_=(<class ‘str’>, <class ‘bokeh.models.ui.tooltips.Tooltip’>), default=’Description’, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309295e10>)

The description in the tooltip.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.indicators.Tqdm(*, layout, lock, max, progress, text, text_pane, value, write_to_console, disabled, 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: Indicator

The Tqdm indicator wraps the well known tqdm progress indicator and displays the progress towards some target in your Panel app.

Reference: https://panel.holoviz.org/reference/indicators/Tqdm.html

Example:

>>> tqdm = Tqdm()
>>> for i in tqdm(range(0,10), desc="My loop", leave=True, colour='#666666'):
...     time.sleep(timeout)

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, disabled

panel.widgets.indicators.Indicator: sizing_mode

margin = param.Parameter(allow_refs=False, default=0, label=’Margin’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3092ab590>)

Allows to create additional space around the component. May be specified as a two-tuple of the form (vertical, horizontal) or a four-tuple (top, right, bottom, left).

width = param.Integer(allow_refs=False, bounds=(0, None), default=400, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30933e690>)

The width of the component (in pixels). This can be either fixed or preferred width, depending on width sizing policy.

value = param.Integer(allow_refs=False, bounds=(-1, None), default=0, inclusive_bounds=(True, True), label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30933dcd0>)

The current value of the progress bar. If set to -1 the progress bar will be indeterminate and animate depending on the active parameter.

layout = param.ClassSelector(allow_None=True, allow_refs=False, class_=(<class ‘panel.layout.base.Column’>, <class ‘panel.layout.base.Row’>), constant=True, label=’Layout’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30923ae90>)

The layout for the text and progress indicator.

lock = param.ClassSelector(allow_None=True, allow_refs=False, class_=<class ‘object’>, label=’Lock’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30930c110>)

The multithreading.Lock or multiprocessing.Lock object to be used by Tqdm.

max = param.Integer(allow_refs=False, default=100, inclusive_bounds=(True, True), label=’Max’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30933e010>)

The maximum value of the progress bar.

progress = param.ClassSelector(allow_None=True, allow_refs=False, class_=<class ‘panel.widgets.indicators.Progress’>, label=’Progress’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3092aab50>)

The Progress indicator used to display the progress.

text = param.String(allow_refs=False, default=’’, label=’Text’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30930ce50>)

The current tqdm style progress text.

text_pane = param.ClassSelector(allow_None=True, allow_refs=False, class_=<class ‘panel.pane.markup.Str’>, label=’Text pane’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3092aab50>)

The pane to display the text to.

write_to_console = param.Boolean(allow_refs=False, default=False, label=’Write to console’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30931e8d0>)

Whether or not to also write to the console.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.

reset()[source]#

Resets the parameters

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.widgets.indicators.Trend(*, data, layout, neg_color, plot_color, plot_type, plot_x, plot_y, pos_color, value, value_change, selection, disabled, 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: SyncableData, Indicator

The Trend indicator enables the user to display a dashboard kpi card.

The card can be layout out as:

  • a column (text and plot on top of each other) or a row (text and

  • plot after each other)

Reference: https://panel.holoviz.org/reference/indicators/Trend.html

Example:

>>> data = {'x': np.arange(50), 'y': np.random.randn(50).cumsum()}
>>> Trend(name='Price', data=data, plot_type='area', width=200, height=200)

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.reactive.SyncableData: selection

sizing_mode = param.ObjectSelector(allow_refs=False, label=’Sizing mode’, names={}, nested_refs=False, objects=[‘fixed’, ‘stretch_width’, ‘stretch_height’, ‘stretch_both’, ‘scale_width’, ‘scale_height’, ‘scale_both’, None], rx=<param.reactive.reactive_ops object at 0x3090a6410>)

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 and aspect_ratio instead (those take precedence over sizing_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.

data = param.Parameter(allow_None=True, allow_refs=False, label=’Data’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x308db0d10>)

The plot data declared as a dictionary of arrays or a DataFrame.

layout = param.ObjectSelector(allow_refs=False, default=’column’, label=’Layout’, names={}, nested_refs=False, objects=[‘column’, ‘row’], rx=<param.reactive.reactive_ops object at 0x3090a5f90>)

plot_x = param.String(allow_refs=False, default=’x’, label=’Plot x’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x308db0d10>)

The name of the key in the plot_data to use on the x-axis.

plot_y = param.String(allow_refs=False, default=’y’, label=’Plot y’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3090a5f50>)

The name of the key in the plot_data to use on the y-axis.

plot_color = param.String(allow_refs=False, default=’#428bca’, label=’Plot color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3090a5f90>)

The color to use in the plot.

plot_type = param.ObjectSelector(allow_refs=False, default=’bar’, label=’Plot type’, names={}, nested_refs=False, objects=[‘line’, ‘step’, ‘area’, ‘bar’], rx=<param.reactive.reactive_ops object at 0x3090a7a90>)

The plot type to render the plot data as.

pos_color = param.String(allow_refs=False, default=’#5cb85c’, label=’Pos color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3090a5f90>)

The color used to indicate a positive change.

neg_color = param.String(allow_refs=False, default=’#d9534f’, label=’Neg color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3090a6210>)

The color used to indicate a negative change.

value = param.Parameter(allow_refs=False, default=’auto’, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3090a6410>)

The primary value to be displayed.

value_change = param.Parameter(allow_refs=False, default=’auto’, label=’Value change’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3090a7590>)

A secondary value. For example the change in percent.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.

patch(patch_value: 'pd.DataFrame' | 'pd.Series' | Dict) None[source]#

Efficiently patches (updates) the existing value with the patch_value.

Parameters:

patch_value ((pd.DataFrame | pd.Series | Dict)) – The value(s) to patch the existing value with.

Raises:

ValueError – Raised if the patch_value is not a supported type.:

Examples

Patch a DataFrame with a Dictionary row. >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> obj = DataComponent(value) >>> patch_value = {“x”: [(0, 3)]} >>> obj.patch(patch_value) >>> obj.value.to_dict(“list”) {‘x’: [3, 2], ‘y’: [‘a’, ‘b’]}

Patch a Dataframe with a Dictionary of Columns. >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> obj = DataComponent(value) >>> patch_value = {“x”: [(slice(2), (3,4))], “y”: [(1,’d’)]} >>> obj.patch(patch_value) >>> obj.value.to_dict(“list”) {‘x’: [3, 4], ‘y’: [‘a’, ‘d’]}

Patch a DataFrame with a Series. Please note the index is used in the update. >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> obj = DataComponent(value) >>> patch_value = pd.Series({“index”: 1, “x”: 4, “y”: “d”}) >>> obj.patch(patch_value) >>> obj.value.to_dict(“list”) {‘x’: [1, 4], ‘y’: [‘a’, ‘d’]}

Patch a Dataframe with a Dataframe. Please note the index is used in the update. >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> obj = DataComponent(value) >>> patch_value = pd.DataFrame({“x”: [3, 4], “y”: [“c”, “d”]}) >>> obj.patch(patch_value) >>> obj.value.to_dict(“list”) {‘x’: [3, 4], ‘y’: [‘c’, ‘d’]}

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

sizing_mode = None#
stream(stream_value: 'pd.DataFrame' | 'pd.Series' | Dict, rollover: Optional[int] = None, reset_index: bool = True) None[source]#

Streams (appends) the stream_value provided to the existing value in an efficient manner.

Parameters:
  • stream_value ((pd.DataFrame | pd.Series | Dict)) – The new value(s) to append to the existing value.

  • rollover ((int | None, default=None)) – A maximum column size, above which data from the start of the column begins to be discarded. If None, then columns will continue to grow unbounded.

  • (bool (reset_index) – If True and the stream_value is a DataFrame, then its index is reset. Helps to keep the index unique and named index.

  • default=True) – If True and the stream_value is a DataFrame, then its index is reset. Helps to keep the index unique and named index.

Raises:

ValueError – Raised if the stream_value is not a supported type.:

Examples

Stream a Series to a DataFrame >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> obj = DataComponent(value) >>> stream_value = pd.Series({“x”: 4, “y”: “d”}) >>> obj.stream(stream_value) >>> obj.value.to_dict(“list”) {‘x’: [1, 2, 4], ‘y’: [‘a’, ‘b’, ‘d’]}

Stream a Dataframe to a Dataframe >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> obj = DataComponent(value) >>> stream_value = pd.DataFrame({“x”: [3, 4], “y”: [“c”, “d”]}) >>> obj.stream(stream_value) >>> obj.value.to_dict(“list”) {‘x’: [1, 2, 3, 4], ‘y’: [‘a’, ‘b’, ‘c’, ‘d’]}

Stream a Dictionary row to a DataFrame >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = DataComponent(value) >>> stream_value = {“x”: 4, “y”: “d”} >>> obj.stream(stream_value) >>> obj.value.to_dict(“list”) {‘x’: [1, 2, 4], ‘y’: [‘a’, ‘b’, ‘d’]}

Stream a Dictionary of Columns to a Dataframe >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> obj = DataComponent(value) >>> stream_value = {“x”: [3, 4], “y”: [“c”, “d”]} >>> obj.stream(stream_value) >>> obj.value.to_dict(“list”) {‘x’: [1, 2, 3, 4], ‘y’: [‘a’, ‘b’, ‘c’, ‘d’]}

class panel.widgets.indicators.ValueIndicator(*, value, disabled, 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: Indicator

A ValueIndicator provides a visual representation for a numeric value.

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.indicators.Indicator: sizing_mode

value = param.Number(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309340e50>)

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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


input Module#

Inheritance diagram of panel.widgets.input

The input widgets generally allow entering arbitrary information into a text field or similar.

class panel.widgets.input.ArrayInput(*, max_array_size, description, placeholder, serializer, type, value, disabled, 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: LiteralInput

The ArrayInput allows rendering and editing NumPy arrays in a text input widget.

Arrays larger than the max_array_size will be summarized and editing will be disabled.

Reference: https://panel.holoviz.org/reference/widgets/ArrayInput.html

Example:

>>> To be determined ...

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

panel.widgets.input.LiteralInput: width, description, placeholder, serializer, type, value

max_array_size = param.Number(allow_refs=False, default=1000, inclusive_bounds=(True, True), label=’Max array size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x311865510>)

Arrays larger than this limit will be allowed in Python but will not be serialized into JavaScript. Although such large arrays will thus not be editable in the widget, such a restriction helps avoid overwhelming the browser and lets other widgets remain usable.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.input.Checkbox(*, value, disabled, 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: _BooleanWidget

The Checkbox allows toggling a single condition between True/False states by ticking a checkbox.

This widget is interchangeable with the Toggle widget.

Reference: https://panel.holoviz.org/reference/widgets/Checkbox.html

Example:

>>> Checkbox(name='Works with the tools you know and love', value=True)

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.input._BooleanWidget: value

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.input.ColorPicker(*, description, value, disabled, 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: Widget

The ColorPicker widget allows selecting a hexadecimal RGB color value using the browser’s color-picking widget.

Reference: https://panel.holoviz.org/reference/widgets/ColorPicker.html

Example:

>>> ColorPicker(name='Color', value='#99ef78')

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

width = param.Integer(allow_None=True, allow_refs=False, bounds=(0, None), default=52, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1671966d0>)

Width of this component. If sizing_mode is set to stretch or scale mode this will merely be used as a suggestion.

description = param.String(allow_None=True, allow_refs=False, label=’Description’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x310c7e710>)

An HTML string describing the function of this component.

value = param.Color(allow_None=True, allow_named=True, allow_refs=False, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x311862210>)

The selected color

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.input.DatePicker(*, description, disabled_dates, enabled_dates, end, start, value, disabled, 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: Widget

The DatePicker allows selecting a date value using a text box and a date-picking utility.

Reference: https://panel.holoviz.org/reference/widgets/DatePicker.html

Example:

>>> DatePicker(
...     value=date(2025,1,1),
...     start=date(2025,1,1), end=date(2025,12,31),
...     name='Date'
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

width = param.Integer(allow_None=True, allow_refs=False, bounds=(0, None), default=300, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3118aebd0>)

Width of this component. If sizing_mode is set to stretch or scale mode this will merely be used as a suggestion.

value = param.CalendarDate(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3118ad710>)

The current value

start = param.CalendarDate(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Start’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3118aeb50>)

Inclusive lower bound of the allowed date selection

end = param.CalendarDate(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’End’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3118ad610>)

Inclusive upper bound of the allowed date selection

disabled_dates = param.List(allow_None=True, allow_refs=False, bounds=(0, None), class_=(<class ‘datetime.date’>, <class ‘str’>), item_type=(<class ‘datetime.date’>, <class ‘str’>), label=’Disabled dates’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3118af010>)

enabled_dates = param.List(allow_None=True, allow_refs=False, bounds=(0, None), class_=(<class ‘datetime.date’>, <class ‘str’>), item_type=(<class ‘datetime.date’>, <class ‘str’>), label=’Enabled dates’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3118aced0>)

description = param.String(allow_None=True, allow_refs=False, label=’Description’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3118ae790>)

An HTML string describing the function of this component.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.input.DateRangePicker(*, description, disabled_dates, enabled_dates, end, start, value, disabled, 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: Widget

The DateRangePicker allows selecting a date range using a text box and a date-picking utility.

Reference: https://panel.holoviz.org/reference/widgets/DateRangePicker.html

Example:

>>> DateRangePicker(
...     value=(date(2025,1,1), date(2025,1,5)),
...     start=date(2025,1,1), end=date(2025,12,31),
...     name='Date range'
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

width = param.Integer(allow_None=True, allow_refs=False, bounds=(0, None), default=300, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3118dff10>)

Width of this component. If sizing_mode is set to stretch or scale mode this will merely be used as a suggestion.

value = param.DateRange(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Value’, length=2, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3118d0050>)

The current value

start = param.CalendarDate(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Start’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3118dfe50>)

Inclusive lower bound of the allowed date selection

end = param.CalendarDate(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’End’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3118d17d0>)

Inclusive upper bound of the allowed date selection

disabled_dates = param.List(allow_None=True, allow_refs=False, bounds=(0, None), class_=(<class ‘datetime.date’>, <class ‘str’>), item_type=(<class ‘datetime.date’>, <class ‘str’>), label=’Disabled dates’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3118dee50>)

enabled_dates = param.List(allow_None=True, allow_refs=False, bounds=(0, None), class_=(<class ‘datetime.date’>, <class ‘str’>), item_type=(<class ‘datetime.date’>, <class ‘str’>), label=’Enabled dates’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3118dc490>)

description = param.String(allow_None=True, allow_refs=False, label=’Description’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3118dd710>)

An HTML string describing the function of this component.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.input.DatetimeInput(*, end, format, start, description, placeholder, serializer, type, value, disabled, 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: LiteralInput

The DatetimeInput allows specifying Python datetime like values using a text input widget.

An optional type may be declared.

Reference: https://panel.holoviz.org/reference/widgets/DatetimeInput.html

Example:

>>> DatetimeInput(name='Datetime', value=datetime(2019, 2, 8))

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

panel.widgets.input.LiteralInput: width, description, placeholder, serializer, type

value = param.Date(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x311901f10>)

The current value

start = param.Date(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Start’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x311903150>)

Inclusive lower bound of the allowed date selection

end = param.Date(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’End’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x311901f90>)

Inclusive upper bound of the allowed date selection

format = param.String(allow_refs=False, default=’%Y-%m-%d %H:%M:%S’, label=’Format’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x311902890>)

Datetime format used for parsing and formatting the datetime.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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

type[source]#

alias of datetime

class panel.widgets.input.DatetimePicker(*, mode, value, as_numpy_datetime64, description, disabled_dates, enable_seconds, enable_time, enabled_dates, end, military_time, start, disabled, 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: _DatetimePickerBase

The DatetimePicker allows selecting selecting a datetime value using a textbox and a datetime-picking utility.

Reference: https://panel.holoviz.org/reference/widgets/DatetimePicker.html

Example:

>>> DatetimePicker(
...    value=datetime(2025,1,1,22,0),
...    start=date(2025,1,1), end=date(2025,12,31),
...    military_time=True, name='Date and time'
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

panel.widgets.input._DatetimePickerBase: width, disabled_dates, enabled_dates, enable_time, enable_seconds, end, military_time, start, description, as_numpy_datetime64

value = param.Date(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3118fed10>)

mode = param.String(allow_refs=False, constant=True, default=’single’, label=’Mode’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31192d750>)

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.input.DatetimeRangeInput(*, end, format, start, value, disabled, 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: CompositeWidget

The DatetimeRangeInput widget allows selecting a datetime range using two DatetimeInput widgets, which return a tuple range.

Reference: https://panel.holoviz.org/reference/widgets/DatetimeRangeInput.html

Example:

>>> DatetimeRangeInput(
...     name='Datetime Range',
...     value=(datetime(2017, 1, 1), datetime(2018, 1, 10)),
...     start=datetime(2017, 1, 1), end=datetime(2019, 1, 1),
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

value = param.Tuple(allow_refs=False, default=(None, None), label=’Value’, length=2, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x311944b90>)

The current value

start = param.Date(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Start’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3118eee10>)

Inclusive lower bound of the allowed date selection

end = param.Date(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’End’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3118ef190>)

Inclusive upper bound of the allowed date selection

format = param.String(allow_refs=False, default=’%Y-%m-%d %H:%M:%S’, label=’Format’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x311923310>)

Datetime format used for parsing and formatting the datetime.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.input.DatetimeRangePicker(*, mode, value, as_numpy_datetime64, description, disabled_dates, enable_seconds, enable_time, enabled_dates, end, military_time, start, disabled, 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: _DatetimePickerBase

The DatetimeRangePicker allows selecting selecting a datetime range using a text box and a datetime-range-picking utility.

Reference: https://panel.holoviz.org/reference/widgets/DatetimeRangePicker.html

Example:

>>> DatetimeRangePicker(
...    value=(datetime(2025,1,1,22,0), datetime(2025,1,2,22,0)),
...    start=date(2025,1,1), end=date(2025,12,31),
...    military_time=True, name='Datetime Range'
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

panel.widgets.input._DatetimePickerBase: width, disabled_dates, enabled_dates, enable_time, enable_seconds, end, military_time, start, description, as_numpy_datetime64

value = param.DateRange(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Value’, length=2, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31194df10>)

The current value

mode = param.String(allow_refs=False, constant=True, default=’range’, label=’Mode’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31191b010>)

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.input.FileInput(*, accept, description, filename, mime_type, multiple, value, disabled, 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: Widget

The FileInput allows the user to upload one or more files to the server.

It makes the filename, MIME type and (bytes) content available in Python.

Please note

  • you can in fact drag and drop files onto the FileInput.

  • you easily save the files using the save method.

Reference: https://panel.holoviz.org/reference/widgets/FileInput.html

Example:

>>> FileInput(accept='.png,.jpeg', multiple=True)

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

accept = param.String(allow_None=True, allow_refs=False, label=’Accept’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x311999250>)

description = param.String(allow_None=True, allow_refs=False, label=’Description’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31199b590>)

An HTML string describing the function of this component.

filename = param.ClassSelector(allow_None=True, allow_refs=False, class_=(<class ‘str’>, <class ‘list’>), label=’Filename’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31199a690>)

mime_type = param.ClassSelector(allow_None=True, allow_refs=False, class_=(<class ‘str’>, <class ‘list’>), label=’Mime type’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31199b610>)

multiple = param.Boolean(allow_refs=False, default=False, label=’Multiple’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31199a910>)

value = param.Parameter(allow_None=True, allow_refs=False, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x311999a90>)

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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)[source]#

Saves the uploaded FileInput data object(s) to file(s) or BytesIO object(s).

Parameters:

list[str]) (filename (str or) –

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.widgets.input.FloatInput(*, step, value_throttled, page_step_multiplier, wheel_wait, mode, description, end, format, placeholder, start, value, disabled, 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: _SpinnerBase, _FloatInputBase

The FloatInput allows selecting a floating point value using a spinbox.

It behaves like a slider except that the lower and upper bounds are optional and a specific value can be entered. The value can be changed using the keyboard (up, down, page up, page down), mouse wheel and arrow buttons.

Reference: https://panel.holoviz.org/reference/widgets/FloatInput.html

Example:

>>> FloatInput(name='Value', value=5., step=1e-1, start=0, end=10)

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

panel.widgets.input._NumericInputBase: description, format

panel.widgets.input._FloatInputBase: value, start, end, mode

panel.widgets.input._SpinnerBase: width, page_step_multiplier, wheel_wait

placeholder = param.String(allow_refs=False, default=’’, label=’Placeholder’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3119a6110>)

Placeholder when the value is empty.

step = param.Number(allow_refs=False, default=0.1, inclusive_bounds=(True, True), label=’Step’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3119ac250>)

The step size.

value_throttled = param.Number(allow_None=True, allow_refs=False, constant=True, inclusive_bounds=(True, True), label=’Value throttled’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3119ace10>)

The current value. Updates only on <enter> or when the widget looses focus.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.input.IntInput(*, step, value_throttled, page_step_multiplier, wheel_wait, mode, description, end, format, placeholder, start, value, disabled, 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: _SpinnerBase, _IntInputBase

The IntInput allows selecting an integer value using a spinbox.

It behaves like a slider except that lower and upper bounds are optional and a specific value can be entered. The value can be changed using the keyboard (up, down, page up, page down), mouse wheel and arrow buttons.

Reference: https://panel.holoviz.org/reference/widgets/IntInput.html

Example:

>>> IntInput(name='Value', value=100, start=0, end=1000, step=10)

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

panel.widgets.input._NumericInputBase: description, placeholder, format

panel.widgets.input._IntInputBase: value, start, end, mode

panel.widgets.input._SpinnerBase: width, page_step_multiplier, wheel_wait

step = param.Integer(allow_refs=False, default=1, inclusive_bounds=(True, True), label=’Step’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3119c1fd0>)

The step size.

value_throttled = param.Integer(allow_None=True, allow_refs=False, constant=True, inclusive_bounds=(True, True), label=’Value throttled’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3119af750>)

The current value. Updates only on <enter> or when the widget looses focus.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.input.LiteralInput(*, description, placeholder, serializer, type, value, disabled, 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: Widget

The LiteralInput allows declaring Python literals using a text input widget.

A literal is some specific primitive value of type str , int, float, bool etc or a dict, list, tuple, set etc of primitive values.

Optionally the literal type may be declared.

Reference: https://panel.holoviz.org/reference/widgets/LiteralInput.html

Example:

>>> LiteralInput(name='Dictionary', value={'key': [1, 2, 3]}, type=dict)

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

width = param.Integer(allow_None=True, allow_refs=False, bounds=(0, None), default=300, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3119ee850>)

Width of this component. If sizing_mode is set to stretch or scale mode this will merely be used as a suggestion.

description = param.String(allow_None=True, allow_refs=False, label=’Description’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x311a01090>)

An HTML string describing the function of this component.

placeholder = param.String(allow_refs=False, default=’’, label=’Placeholder’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3119ef9d0>)

Placeholder for empty input field.

serializer = param.ObjectSelector(allow_refs=False, default=’ast’, label=’Serializer’, names={}, nested_refs=False, objects=[‘ast’, ‘json’], rx=<param.reactive.reactive_ops object at 0x310f47750>)

The serialization (and deserialization) method to use. ‘ast’ uses ast.literal_eval and ‘json’ uses json.loads and json.dumps.

type = param.ClassSelector(allow_None=True, allow_refs=False, class_=(<class ‘type’>, <class ‘tuple’>), label=’Type’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3119edb10>)

value = param.Parameter(allow_None=True, allow_refs=False, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x311a00390>)

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.input.NumberInput(*, page_step_multiplier, wheel_wait, description, end, format, placeholder, start, value, disabled, 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: _SpinnerBase

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

panel.widgets.input._NumericInputBase: description, value, placeholder, format, start, end

panel.widgets.input._SpinnerBase: width, page_step_multiplier, wheel_wait

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.input.PasswordInput(*, description, max_length, placeholder, value, value_input, disabled, 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: TextInput

The PasswordInput allows entering any string using an obfuscated text input box.

Reference: https://panel.holoviz.org/reference/widgets/PasswordInput.html

Example:

>>> PasswordInput(
...     name='Password', placeholder='Enter your password here...'
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

panel.widgets.input.TextInput: width, description, max_length, placeholder, value, value_input

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

classmethod from_param(parameter: param.Parameter, onkeyup=False, **params) Viewable[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:
  • parameter (param.Parameter) – A parameter to create the widget from.

  • onkeyup (boolean) – Whether to trigger events on every key press.

  • params (dict) – Keyword arguments to be passed to the widget constructor

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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

panel.widgets.input.Spinner[source]#

alias of NumberInput

class panel.widgets.input.StaticText(*, value, disabled, 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: Widget

The StaticText widget displays a text value, but does not allow editing it.

Reference: https://panel.holoviz.org/reference/widgets/StaticText.html

Example:

>>> StaticText(name='Model', value='animagen2')

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

value = param.Parameter(allow_None=True, allow_refs=False, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x311a3ab10>)

The current value

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.input.Switch(*, value, disabled, 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: _BooleanWidget

The Switch allows toggling a single condition between True/False states by ticking a checkbox.

This widget is interchangeable with the Toggle widget.

Reference: https://panel.holoviz.org/reference/widgets/Switch.html

Example:

>>> Switch(name='Works with the tools you know and love', value=True)

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.input._BooleanWidget: value

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.input.TextAreaInput(*, auto_grow, cols, max_rows, resizable, rows, description, max_length, placeholder, value, value_input, disabled, 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: TextInput

The TextAreaInput allows entering any multiline string using a text input box.

Lines are joined with the newline character `

`.

Reference: https://panel.holoviz.org/reference/widgets/TextAreaInput.html :Example:

>>> TextAreaInput(
...     name='Description', placeholder='Enter your description here...'
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

panel.widgets.input.TextInput: width, description, max_length, placeholder, value, value_input

auto_grow = param.Boolean(allow_refs=False, default=False, label=’Auto grow’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x311a9f290>)

Whether the text area should automatically grow vertically to accommodate the current text.

cols = param.Integer(allow_refs=False, default=20, inclusive_bounds=(True, True), label=’Cols’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x311ab20d0>)

Number of columns in the text input field.

max_rows = param.Integer(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Max rows’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x311ab2790>)

When combined with auto_grow this determines the maximum number of rows the input area can grow.

rows = param.Integer(allow_refs=False, default=2, inclusive_bounds=(True, True), label=’Rows’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x311ab2010>)

Number of rows in the text input field.

resizable = param.ObjectSelector(allow_refs=False, label=’Resizable’, names={}, nested_refs=False, objects=[‘both’, ‘width’, ‘height’, False], rx=<param.reactive.reactive_ops object at 0x311ab1410>)

Whether the layout is interactively resizable, and if so in which dimensions: width, height, or both. Can only be set during initialization.

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

classmethod from_param(parameter: param.Parameter, onkeyup=False, **params) Viewable[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:
  • parameter (param.Parameter) – A parameter to create the widget from.

  • onkeyup (boolean) – Whether to trigger events on every key press.

  • params (dict) – Keyword arguments to be passed to the widget constructor

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.input.TextInput(*, description, max_length, placeholder, value, value_input, disabled, 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: Widget

The TextInput widget allows entering any string using a text input box.

Reference: https://panel.holoviz.org/reference/widgets/TextInput.html

Example:

>>> TextInput(name='Name', placeholder='Enter your name here ...')

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

width = param.Integer(allow_None=True, allow_refs=True, bounds=(0, None), default=300, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x311a5eb10>)

Width of this component. If sizing_mode is set to stretch or scale mode this will merely be used as a suggestion.

description = param.String(allow_None=True, allow_refs=True, label=’Description’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x311ac98d0>)

An HTML string describing the function of this component.

max_length = param.Integer(allow_refs=True, default=5000, inclusive_bounds=(True, True), label=’Max length’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x311a5f350>)

Max count of characters in the input field.

placeholder = param.String(allow_refs=True, default=’’, label=’Placeholder’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x311ac9550>)

Placeholder for empty input field.

value = param.String(allow_None=True, allow_refs=True, default=’’, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x311a5fc50>)

Initial or entered text value updated when <enter> key is pressed.

value_input = param.String(allow_None=True, allow_refs=True, default=’’, label=’Value input’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x311ac8190>)

Initial or entered text value updated on every key press.

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

classmethod from_param(parameter: param.Parameter, onkeyup=False, **params) Viewable[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:
  • parameter (param.Parameter) – A parameter to create the widget from.

  • onkeyup (boolean) – Whether to trigger events on every key press.

  • params (dict) – Keyword arguments to be passed to the widget constructor

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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


misc Module#

Inheritance diagram of panel.widgets.misc

Miscellaneous widgets which do not fit into the other main categories.

class panel.widgets.misc.FileDownload(file=None, **params)[source]#

Bases: IconMixin

The FileDownload widget allows a user to download a file.

It works either by sending the file data to the browser on initialization (`embed`=True), or when the button is clicked.

Reference: https://panel.holoviz.org/reference/widgets/FileDownload.html

Example:

>>> FileDownload(file='IntroductionToPanel.ipynb', filename='intro.ipynb')

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.button.IconMixin: icon, icon_size

auto = param.Boolean(allow_refs=False, default=True, label=’Auto’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31429bc90>)

Whether to download on the initial click or allow for right-click save as.

button_type = param.ObjectSelector(allow_refs=False, default=’default’, label=’Button type’, names={}, nested_refs=False, objects=[‘default’, ‘primary’, ‘success’, ‘warning’, ‘danger’, ‘light’], rx=<param.reactive.reactive_ops object at 0x314298050>)

A button theme; should be one of ‘default’ (white), ‘primary’ (blue), ‘success’ (green), ‘info’ (yellow), ‘light’ (light), or ‘danger’ (red).

button_style = param.ObjectSelector(allow_refs=False, default=’solid’, label=’Button style’, names={}, nested_refs=False, objects=[‘solid’, ‘outline’], rx=<param.reactive.reactive_ops object at 0x314293d90>)

A button style to switch between ‘solid’, ‘outline’.

callback = param.Callable(allow_None=True, allow_refs=False, label=’Callback’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x314298e90>)

A callable that returns the file path or file-like object.

data = param.String(allow_None=True, allow_refs=False, label=’Data’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x312e16710>)

The data being transferred.

embed = param.Boolean(allow_refs=False, default=False, label=’Embed’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x314299710>)

Whether to embed the file on initialization.

file = param.Parameter(allow_None=True, allow_refs=False, label=’File’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31429c7d0>)

The file, Path, file-like object or file contents to transfer. If the file is not pointing to a file on disk a filename must also be provided.

filename = param.String(allow_None=True, allow_refs=False, label=’Filename’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31429b2d0>)

A filename which will also be the default name when downloading the file.

label = param.String(allow_refs=False, default=’Download file’, label=’Label’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31429c7d0>)

The label of the download button

description = param.String(allow_None=True, allow_refs=False, label=’Description’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x314299710>)

An HTML string describing the function of this component.

_clicks = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’ clicks’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x312cbadd0>)

_transfers = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’ transfers’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3142994d0>)

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.misc.JSONEditor(*, menu, mode, schema, search, selection, templates, value, disabled, 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: Widget

The JSONEditor provides a visual editor for JSON-serializable datastructures, e.g. Python dictionaries and lists, with functionality for different editing modes, inserting objects and validation using JSON Schema.

Reference: https://panel.holoviz.org/reference/widgets/JSONEditor.html

Example:

>>> JSONEditor(value={
...     'dict'  : {'key': 'value'},
...     'float' : 3.14,
...     'int'   : 1,
...     'list'  : [1, 2, 3],
...     'string': 'A string',
... }, mode='code')

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

menu = param.Boolean(allow_refs=False, default=True, label=’Menu’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x314244750>)

Adds main menu bar - Contains format, sort, transform, search etc. functionality. true by default. Applicable in all types of mode.

mode = param.Selector(allow_refs=False, default=’tree’, label=’Mode’, names={}, nested_refs=False, objects=[‘tree’, ‘view’, ‘form’, ‘text’, ‘preview’], rx=<param.reactive.reactive_ops object at 0x31419ea90>)

Sets the editor mode. In ‘view’ mode, the data and datastructure is read-only. In ‘form’ mode, only the value can be changed, the data structure is read-only. Mode ‘code’ requires the Ace editor to be loaded on the page. Mode ‘text’ shows the data as plain text. The ‘preview’ mode can handle large JSON documents up to 500 MiB. It shows a preview of the data, and allows to transform, sort, filter, format, or compact the data.

search = param.Boolean(allow_refs=False, default=True, label=’Search’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x314244750>)

Enables a search box in the upper right corner of the JSONEditor. true by default. Only applicable when mode is ‘tree’, ‘view’, or ‘form’.

selection = param.List(allow_refs=False, bounds=(0, None), default=[], label=’Selection’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31419f450>)

Current selection.

schema = param.Dict(allow_None=True, allow_refs=False, class_=<class ‘dict’>, label=’Schema’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x314246e90>)

Validate the JSON object against a JSON schema. A JSON schema describes the structure that a JSON object must have, like required properties or the type that a value must have. See http://json-schema.org/ for more information.

templates = param.List(allow_refs=False, bounds=(0, None), default=[], label=’Templates’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31419ec10>)

Array of templates that will appear in the context menu, Each template is a json object precreated that can be added as a object value to any node in your document.

value = param.Parameter(allow_refs=False, default={}, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x314246250>)

JSON data to be edited.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.misc.VideoStream(*, format, paused, timeout, value, disabled, 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: Widget

The VideoStream displays a video from a local stream (for example from a webcam) and allows accessing the streamed video data from Python.

Reference: https://panel.holoviz.org/reference/widgets/VideoStream.html

Example:

>>> VideoStream(name='Video Stream', timeout=100)

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

format = param.ObjectSelector(allow_refs=False, default=’png’, label=’Format’, names={}, nested_refs=False, objects=[‘png’, ‘jpeg’], rx=<param.reactive.reactive_ops object at 0x314212190>)

The file format as which the video is returned.

paused = param.Boolean(allow_refs=False, default=False, label=’Paused’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3142d8d90>)

Whether the video is currently paused

timeout = param.Number(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Timeout’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3142d8f50>)

Interval between snapshots in millisecons

value = param.String(allow_refs=False, default=’’, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3142d8d90>)

A base64 representation of the video stream snapshot.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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

snapshot()[source]#

Triggers a snapshot of the current VideoStream state to sync the widget value.


player Module#

Inheritance diagram of panel.widgets.player

Defines Player widgets which offer media-player like controls.

class panel.widgets.player.DiscretePlayer(*, value, value_throttled, direction, interval, loop_policy, show_loop_controls, step, options, disabled, 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: PlayerBase, SelectBase

The DiscretePlayer provides controls to iterate through a list of discrete options. The speed at which the widget plays is defined by the interval (in milliseconds), but it is also possible to skip items using the step parameter.

Reference: https://panel.holoviz.org/reference/widgets/DiscretePlayer.html

Example:

>>> DiscretePlayer(
...     name='Discrete Player',
...     options=[2, 4, 8, 16, 32, 64, 128], value=32,
...     loop_policy='loop'
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: margin, disabled

panel.widgets.select.SelectBase: options

panel.widgets.player.PlayerBase: height, width, direction, loop_policy, show_loop_controls, step

interval = param.Integer(allow_refs=False, default=500, inclusive_bounds=(True, True), label=’Interval’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31479e6d0>)

Interval between updates

value = param.Parameter(allow_None=True, allow_refs=False, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x314966250>)

Current player value

value_throttled = param.Parameter(allow_None=True, allow_refs=False, constant=True, label=’Value throttled’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x314699090>)

Current player value

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.player.Player(*, end, start, value, value_throttled, direction, interval, loop_policy, show_loop_controls, step, disabled, 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: PlayerBase

The Player provides controls to play and skip through a number of frames defined by explicit start and end values. The speed at which the widget plays is defined by the interval (in milliseconds), but it is also possible to skip frames using the step parameter.

Reference: https://panel.holoviz.org/reference/widgets/Player.html

Example:

>>> Player(name='Player', start=0, end=100, value=32, loop_policy='loop')

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: margin, disabled

panel.widgets.player.PlayerBase: height, width, direction, interval, loop_policy, show_loop_controls, step

start = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Start’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x314952650>)

Lower bound on the slider value

end = param.Integer(allow_refs=False, default=10, inclusive_bounds=(True, True), label=’End’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31486bc90>)

Upper bound on the slider value

value = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x314952a50>)

Current player value

value_throttled = param.Integer(allow_refs=False, constant=True, default=0, inclusive_bounds=(True, True), label=’Value throttled’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31486b850>)

Current throttled player value.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.player.PlayerBase(*, direction, interval, loop_policy, show_loop_controls, step, disabled, 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: Widget

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: margin, disabled

height = param.Integer(allow_refs=False, bounds=(0, None), default=80, inclusive_bounds=(True, True), label=’Height’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3149b5dd0>)

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), default=510, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x314985510>)

Width of this component. If sizing_mode is set to stretch or scale mode this will merely be used as a suggestion.

direction = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Direction’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3149b5e90>)

Current play direction of the Player (-1: playing in reverse, 0: paused, 1: playing)

interval = param.Integer(allow_refs=False, default=500, inclusive_bounds=(True, True), label=’Interval’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x314986710>)

Interval between updates, in milliseconds. Default is 500, i.e. two updates per second.

loop_policy = param.ObjectSelector(allow_refs=False, default=’once’, label=’Loop policy’, names={}, nested_refs=False, objects=[‘once’, ‘loop’, ‘reflect’], rx=<param.reactive.reactive_ops object at 0x314607750>)

Policy used when player hits last frame

show_loop_controls = param.Boolean(allow_refs=False, default=True, label=’Show loop controls’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x314987510>)

Whether the loop controls radio buttons are shown

step = param.Integer(allow_refs=False, default=1, inclusive_bounds=(True, True), label=’Step’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x314986990>)

Number of frames to step forward and back by on each event.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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


select Module#

Inheritance diagram of panel.widgets.select

Defines various Select widgets which allow choosing one or more items from a list of options.

class panel.widgets.select.AutocompleteInput(*, case_sensitive, description, min_characters, options, placeholder, restrict, search_strategy, value, value_input, disabled, 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: Widget

The MultiChoice widget allows selecting multiple values from a list of options.

It falls into the broad category of multi-value, option-selection widgets that provide a compatible API and include the MultiSelect, CrossSelector, CheckBoxGroup and CheckButtonGroup widgets.

The MultiChoice widget provides a much more compact UI than MultiSelect.

Reference: https://panel.holoviz.org/reference/widgets/AutocompleteInput.html

Example:

>>> AutocompleteInput(
...     name='Study', options=['Biology', 'Chemistry', 'Physics'],
...     placeholder='Write your study here ...'
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

width = param.Integer(allow_None=True, allow_refs=False, bounds=(0, None), default=300, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x314c6e6d0>)

Width of this component. If sizing_mode is set to stretch or scale mode this will merely be used as a suggestion.

case_sensitive = param.Boolean(allow_refs=False, default=True, label=’Case sensitive’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x315077190>)

Enable or disable case sensitivity.

min_characters = param.Integer(allow_refs=False, default=2, inclusive_bounds=(True, True), label=’Min characters’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x315075590>)

The number of characters a user must type before completions are presented.

options = param.List(allow_refs=False, bounds=(0, None), default=[], label=’Options’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x315075990>)

A list of completion strings. This will be used to guide the user upon typing the beginning of a desired value.

placeholder = param.String(allow_refs=False, default=’’, label=’Placeholder’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x314dbe710>)

Placeholder for empty input field.

restrict = param.Boolean(allow_refs=False, default=True, label=’Restrict’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x315076c90>)

Set to False in order to allow users to enter text that is not present in the list of completion strings.

search_strategy = param.Selector(allow_refs=False, default=’starts_with’, label=’Search strategy’, names={}, nested_refs=False, objects=[‘starts_with’, ‘includes’], rx=<param.reactive.reactive_ops object at 0x315076090>)

Define how to search the list of completion strings. The default option “starts_with” means that the user’s text must match the start of a completion string. Using “includes” means that the user’s text can match any substring of a completion string.

value = param.String(allow_None=True, allow_refs=False, default=’’, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x315077110>)

Initial or entered text value updated when <enter> key is pressed.

value_input = param.String(allow_None=True, allow_refs=False, default=’’, label=’Value input’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x315076110>)

Initial or entered text value updated on every key press.

description = param.String(allow_None=True, allow_refs=False, label=’Description’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x315074750>)

An HTML string describing the function of this component.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.select.CheckBoxGroup(*, inline, value, options, disabled, 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: _CheckGroupBase

The CheckBoxGroup widget allows selecting between a list of options by ticking the corresponding checkboxes.

It falls into the broad category of multi-option selection widgets that provide a compatible API and include the MultiSelect, CrossSelector and CheckButtonGroup widgets.

Reference: https://panel.holoviz.org/reference/widgets/CheckBoxGroup.html

Example:

>>> CheckBoxGroup(
...     name='Fruits', value=['Apple', 'Pear'], options=['Apple', 'Banana', 'Pear', 'Strawberry'],
...     inline=True
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.select.SelectBase: options

panel.widgets.select._CheckGroupBase: value

inline = param.Boolean(allow_refs=False, default=False, label=’Inline’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x315084790>)

Whether the items be arrange vertically (False) or horizontally in-line (True).

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.select.CheckButtonGroup(*, orientation, value, options, button_style, button_type, description, description_delay, disabled, 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: _CheckGroupBase, _ButtonBase, TooltipMixin

The CheckButtonGroup widget allows selecting between a list of options by toggling the corresponding buttons.

It falls into the broad category of multi-option selection widgets that provide a compatible API and include the MultiSelect, CrossSelector and CheckBoxGroup widgets.

Reference: https://panel.holoviz.org/reference/widgets/CheckButtonGroup.html

Example:

>>> CheckButtonGroup(
...     name='Regression Models', value=['Lasso', 'Ridge'],
...     options=['Lasso', 'Linear', 'Ridge', 'Polynomial']
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets._mixin.TooltipMixin: description, description_delay

panel.widgets.button._ButtonBase: button_type, button_style

panel.widgets.select.SelectBase: options

panel.widgets.select._CheckGroupBase: value

orientation = param.Selector(allow_refs=False, default=’horizontal’, label=’Orientation’, names={}, nested_refs=False, objects=[‘horizontal’, ‘vertical’], rx=<param.reactive.reactive_ops object at 0x3150b69d0>)

Button group orientation, either ‘horizontal’ (default) or ‘vertical’.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.select.ColorMap(*, ncols, swatch_height, swatch_width, value_name, value, options, disabled, 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: SingleSelectBase

The ColorMap widget allows selecting a value from a dictionary of options each containing a colormap specified as a list of colors or a matplotlib colormap.

Reference: https://panel.holoviz.org/reference/widgets/ColorMap.html

Example:

>>> ColorMap(name='Reds', options={'Reds': ['white', 'red'], 'Blues': ['#ffffff', '#0000ff']})

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

options = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Options’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3150d77d0>)

Dictionary of colormaps

value = param.Parameter(allow_None=True, allow_refs=False, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3150e9990>)

The selected colormap.

ncols = param.Integer(allow_refs=False, default=1, inclusive_bounds=(True, True), label=’Ncols’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3150e9c10>)

Number of columns of swatches to display.

swatch_height = param.Integer(allow_refs=False, default=20, inclusive_bounds=(True, True), label=’Swatch height’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3150ea390>)

Height of the color swatches.

swatch_width = param.Integer(allow_refs=False, default=100, inclusive_bounds=(True, True), label=’Swatch width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3150e9cd0>)

Width of the color swatches.

value_name = param.String(allow_None=True, allow_refs=False, label=’Value name’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3150e9990>)

Name of the selected colormap.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.select.CrossSelector(*, definition_order, filter_fn, size, description, value, options, disabled, 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: CompositeWidget, MultiSelect

A composite widget which allows selecting from a list of items by moving them between two lists. Supports filtering values by name to select them in bulk.

Reference: https://panel.holoviz.org/reference/widgets/CrossSelector.html

Example:

>>> CrossSelector(
...     name='Fruits', value=['Apple', 'Pear'],
...     options=['Apple', 'Banana', 'Pear', 'Strawberry']
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: margin, disabled

panel.widgets.select.SelectBase: options

panel.widgets.select._MultiSelectBase: value, description

height = param.Integer(allow_None=True, allow_refs=False, bounds=(0, None), default=200, inclusive_bounds=(True, True), label=’Height’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x315065750>)

The number of options shown at once (note this is the only way to control the height of this widget)

width = param.Integer(allow_None=True, allow_refs=False, bounds=(0, None), default=600, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x315114e90>)

The number of options shown at once (note this is the only way to control the height of this widget)

size = param.Integer(allow_refs=False, default=10, inclusive_bounds=(True, True), label=’Size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x315067290>)

The number of options shown at once (note this is the only way to control the height of this widget)

filter_fn = param.Callable(allow_refs=False, label=’Filter fn’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3149b6e50>)

The filter function applied when querying using the text fields, defaults to re.search. Function is two arguments, the query or pattern and the item label.

definition_order = param.Integer(allow_refs=False, default=True, inclusive_bounds=(True, True), label=’Definition order’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x315087710>)

Whether to preserve definition order after filtering. Disable to allow the order of selection to define the order of the selected list.

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

filter_fn(string, flags=0)[source]#

Scan through string looking for a match to the pattern, returning a Match object, or None if no match was found.

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.select.MultiChoice(*, delete_button, max_items, option_limit, placeholder, search_option_limit, solid, description, value, options, disabled, 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: _MultiSelectBase

The MultiChoice widget allows selecting multiple values from a list of options.

It falls into the broad category of multi-value, option-selection widgets that provide a compatible API and include the MultiSelect, CrossSelector, CheckBoxGroup and CheckButtonGroup widgets.

The MultiChoice widget provides a much more compact UI than MultiSelect.

Reference: https://panel.holoviz.org/reference/widgets/MultiChoice.html

Example:

>>> MultiChoice(
...     name='Favourites', value=['Panel', 'hvPlot'],
...     options=['Panel', 'hvPlot', 'HoloViews', 'GeoViews', 'Datashader', 'Param', 'Colorcet'],
...     max_items=2
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

panel.widgets.select.SelectBase: options

panel.widgets.select._MultiSelectBase: value, description

width = param.Integer(allow_None=True, allow_refs=False, bounds=(0, None), default=300, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3151055d0>)

Width of this component. If sizing_mode is set to stretch or scale mode this will merely be used as a suggestion.

delete_button = param.Boolean(allow_refs=False, default=True, label=’Delete button’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3150da210>)

Whether to display a button to delete a selected option.

max_items = param.Integer(allow_None=True, allow_refs=False, bounds=(1, None), inclusive_bounds=(True, True), label=’Max items’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3151071d0>)

Maximum number of options that can be selected.

option_limit = param.Integer(allow_None=True, allow_refs=False, bounds=(1, None), inclusive_bounds=(True, True), label=’Option limit’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3150dafd0>)

Maximum number of options to display at once.

search_option_limit = param.Integer(allow_None=True, allow_refs=False, bounds=(1, None), inclusive_bounds=(True, True), label=’Search option limit’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x315105b10>)

Maximum number of options to display at once if search string is entered.

placeholder = param.String(allow_refs=False, default=’’, label=’Placeholder’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3150d8190>)

String displayed when no selection has been made.

solid = param.Boolean(allow_refs=False, default=True, label=’Solid’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x315107c90>)

Whether to display widget with solid or light style.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.select.MultiSelect(*, size, description, value, options, disabled, 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: _MultiSelectBase

The MultiSelect widget allows selecting multiple values from a list of options.

It falls into the broad category of multi-value, option-selection widgets that provide a compatible API and include the`CrossSelector`, CheckBoxGroup and CheckButtonGroup widgets.

Reference: https://panel.holoviz.org/reference/widgets/MultiSelect.html

Example:

>>> MultiSelect(
...     name='Frameworks', value=['Bokeh', 'Panel'],
...     options=['Bokeh', 'Dash', 'Panel', 'Streamlit', 'Voila'], size=8
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

panel.widgets.select.SelectBase: options

panel.widgets.select._MultiSelectBase: width, value, description

size = param.Integer(allow_refs=True, default=4, inclusive_bounds=(True, True), label=’Size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x315141150>)

The number of items displayed at once (i.e. determines the widget height).

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.select.NestedSelect(*, _levels, _max_depth, _widgets, layout, levels, options, value, disabled, 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: CompositeWidget

The NestedSelect widget is composed of multiple widgets, where subsequent select options depend on the parent’s value.

Reference: https://panel.holoviz.org/reference/widgets/NestedSelect.html

Example:

>>> NestedSelect(
...     options={
...         "gfs": {"tmp": [1000, 500], "pcp": [1000]},
...         "name": {"tmp": [1000, 925, 850, 700, 500], "pcp": [1000]},
...     },
...     levels=["model", "var", "level"],
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width

disabled = param.Boolean(allow_refs=False, default=False, label=’Disabled’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x315186850>)

Whether the widget is disabled.

value = param.Dict(allow_None=True, allow_refs=False, class_=<class ‘dict’>, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x315187a50>)

The value from all the Select widgets; the keys are the levels names. If no levels names are specified, the keys are the levels indices.

options = param.ClassSelector(allow_None=True, allow_refs=False, class_=(<class ‘dict’>, <class ‘function’>), label=’Options’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x315186750>)

The options to select from. The options may be nested dictionaries, lists, or callables that return those types. If callables are used, the callables must accept level and value keyword arguments, where level is the level that updated and value is a dictionary of the current values, containing keys up to the level that was updated.

layout = param.Parameter(allow_refs=False, default=<class ‘panel.layout.base.Column’>, label=’Layout’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3151850d0>)

The layout type of the widgets. If a dictionary, a “type” key can be provided, to specify the layout type of the widgets, and any additional keyword arguments will be used to instantiate the layout.

levels = param.List(allow_refs=False, bounds=(0, None), default=[], label=’Levels’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x315186bd0>)

Either a list of strings or a list of dictionaries. If a list of strings, the strings are used as the names of the levels. If a list of dictionaries, each dictionary may have a “name” key, which is used as the name of the level, a “type” key, which is used as the type of widget, and any corresponding widget keyword arguments. Must be specified if options is callable.

_widgets = param.List(allow_refs=False, bounds=(0, None), default=[], label=’ widgets’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x315187990>)

The nested select widgets.

_max_depth = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’ max depth’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x315187e90>)

The number of levels of the nested select widgets.

_levels = param.List(allow_refs=False, bounds=(0, None), default=[], label=’ levels’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x315187d10>)

The internal rep of levels to prevent overwriting user provided levels.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

layout[source]#

alias of Column

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.widgets.select.RadioBoxGroup(*, inline, value, options, disabled, 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: _RadioGroupBase

The RadioBoxGroup widget allows selecting from a list or dictionary of values using a set of checkboxes.

It falls into the broad category of single-value, option-selection widgets that provide a compatible API and include the RadioButtonGroup, Select and DiscreteSlider widgets.

Reference: https://panel.holoviz.org/reference/widgets/RadioBoxGroup.html

Example:

>>> RadioBoxGroup(
...     name='Sponsor', options=['Anaconda', 'Blackstone'], inline=True
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.select.SelectBase: options

panel.widgets.select.SingleSelectBase: value

inline = param.Boolean(allow_refs=False, default=False, label=’Inline’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31519e350>)

Whether the items be arrange vertically (False) or horizontally in-line (True).

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.select.RadioButtonGroup(*, orientation, value, options, button_style, button_type, description, description_delay, disabled, 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: _RadioGroupBase, _ButtonBase, TooltipMixin

The RadioButtonGroup widget allows selecting from a list or dictionary of values using a set of toggle buttons.

It falls into the broad category of single-value, option-selection widgets that provide a compatible API and include the RadioBoxGroup, Select, and DiscreteSlider widgets.

Reference: https://panel.holoviz.org/reference/widgets/RadioButtonGroup.html

Example:

>>> RadioButtonGroup(
...     name='Plotting library', options=['Matplotlib', 'Bokeh', 'Plotly'],
...     button_type='success'
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets._mixin.TooltipMixin: description, description_delay

panel.widgets.button._ButtonBase: button_type, button_style

panel.widgets.select.SelectBase: options

panel.widgets.select.SingleSelectBase: value

orientation = param.Selector(allow_refs=False, default=’horizontal’, label=’Orientation’, names={}, nested_refs=False, objects=[‘horizontal’, ‘vertical’], rx=<param.reactive.reactive_ops object at 0x315197ad0>)

Button group orientation, either ‘horizontal’ (default) or ‘vertical’.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.select.Select(*, description, disabled_options, groups, size, value, options, disabled, 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: SingleSelectBase

The Select widget allows selecting a value from a list or dictionary of options by selecting it from a dropdown menu or selection area.

It falls into the broad category of single-value, option-selection widgets that provide a compatible API and include the RadioBoxGroup, AutocompleteInput and DiscreteSlider widgets.

Reference: https://panel.holoviz.org/reference/widgets/Select.html

Example:

>>> Select(name='Study', options=['Biology', 'Chemistry', 'Physics'])

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, disabled

panel.widgets.select.SelectBase: options

panel.widgets.select.SingleSelectBase: value

width = param.Integer(allow_None=True, allow_refs=False, bounds=(0, None), default=300, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3151c4650>)

Width of this component. If sizing_mode is set to stretch or scale mode this will merely be used as a suggestion.

description = param.String(allow_None=True, allow_refs=False, label=’Description’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x315197d10>)

An HTML string describing the function of this component.

disabled_options = param.List(allow_refs=False, bounds=(0, None), default=[], label=’Disabled options’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x3151c4c10>)

Optional list of options that are disabled, i.e. unusable and un-clickable. If options is a dictionary the list items must be dictionary values.

groups = param.Dict(allow_None=True, allow_refs=False, class_=<class ‘dict’>, label=’Groups’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x3151c5a10>)

Dictionary whose keys are used to visually group the options and whose values are either a list or a dictionary of options to select from. Mutually exclusive with options and valid only if size is 1.

size = param.Integer(allow_refs=False, bounds=(1, None), default=1, inclusive_bounds=(True, True), label=’Size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3151c7e10>)

Declares how many options are displayed at the same time. If set to 1 displays options as dropdown otherwise displays scrollable area.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.select.SelectBase(*, options, disabled, 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: Widget

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

options = param.ClassSelector(allow_refs=True, class_=(<class ‘dict’>, <class ‘list’>), default=[], label=’Options’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3152009d0>)

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.select.SingleSelectBase(*, value, options, disabled, 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: SelectBase

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.select.SelectBase: options

value = param.Parameter(allow_None=True, allow_refs=False, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x315236650>)

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.select.ToggleGroup(*, value, options, disabled, 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: SingleSelectBase

This class is a factory of ToggleGroup widgets.

A ToggleGroup is a group of widgets which can be switched ‘on’ or ‘off’.

Two types of widgets are available through the widget_type argument :
  • ‘button’ (default)

  • ‘box’

Two different behaviors are available through behavior argument:
  • ‘check’ (default)boolean

    Any number of widgets can be selected. In this case value is a ‘list’ of objects.

  • ‘radio’boolean

    One and only one widget is switched on. In this case value is an ‘object’.

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.select.SelectBase: options

panel.widgets.select.SingleSelectBase: value

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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


slider Module#

Inheritance diagram of panel.widgets.slider

Sliders allow you to select a value from a defined range of values by moving one or more handle(s).

  • The value will update when a handle is dragged.

  • The `value_throttled`will update when a handle is released.

class panel.widgets.slider.ContinuousSlider(*, format, bar_color, direction, orientation, show_value, tooltips, disabled, 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: _SliderBase

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.slider._SliderBase: bar_color, direction, orientation, show_value, tooltips

format = param.ClassSelector(allow_None=True, allow_refs=False, class_=(<class ‘str’>, <class ‘bokeh.models.formatters.TickFormatter’>), label=’Format’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x316ffee50>)

A custom format string or Bokeh TickFormatter.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.slider.DateRangeSlider(*, end, format, start, step, value, value_throttled, bar_color, direction, orientation, show_value, tooltips, disabled, 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: _SliderBase

The DateRangeSlider widget allows selecting a date range using a slider with two handles. Supports datetime.datetime, datetime.date and np.datetime64 ranges.

Reference: https://panel.holoviz.org/reference/widgets/DateRangeSlider.html

Example:

>>> import datetime as dt
>>> DateRangeSlider(
...     value=(dt.datetime(2025, 1, 9), dt.datetime(2025, 1, 16)),
...     start=dt.datetime(2025, 1, 1),
...     end=dt.datetime(2025, 1, 31),
...     step=2,
...     name="A tuple of datetimes"
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.slider._SliderBase: bar_color, direction, orientation, show_value, tooltips

value = param.DateRange(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Value’, length=2, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x317015ed0>)

The selected range as a tuple of values. Updated when one of the handles is dragged. Supports datetime.datetime, datetime.date, and np.datetime64 ranges.

value_start = param.Date(allow_None=True, allow_refs=False, constant=True, inclusive_bounds=(True, True), label=’Value start’, nested_refs=False, readonly=True, rx=<param.reactive.reactive_ops object at 0x317016b90>)

The lower value of the selected range.

value_end = param.Date(allow_None=True, allow_refs=False, constant=True, inclusive_bounds=(True, True), label=’Value end’, nested_refs=False, readonly=True, rx=<param.reactive.reactive_ops object at 0x317016d10>)

The upper value of the selected range.

value_throttled = param.DateRange(allow_None=True, allow_refs=False, constant=True, inclusive_bounds=(True, True), label=’Value throttled’, length=2, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x317015350>)

The selected range as a tuple of values. Updated one of the handles is released. Supports datetime.datetime, datetime.date and np.datetime64 ranges

start = param.Date(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Start’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x317016790>)

The lower bound.

end = param.Date(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’End’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x317014dd0>)

The upper bound.

step = param.Number(allow_refs=False, default=1, inclusive_bounds=(True, True), label=’Step’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3170167d0>)

The step size in days. Default is 1 day.

format = param.String(allow_None=True, allow_refs=False, label=’Format’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31671e710>)

Datetime format used for parsing and formatting the date.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.slider.DateSlider(*, as_datetime, end, format, start, step, value, value_throttled, bar_color, direction, orientation, show_value, tooltips, disabled, 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: _SliderBase

The DateSlider widget allows selecting a value within a set of bounds using a slider. Supports datetime.datetime, datetime.date and np.datetime64 values. The step size is fixed at 1 day.

Reference: https://panel.holoviz.org/reference/widgets/DateSlider.html

Example:

>>> import datetime as dt
>>> DateSlider(
...     value=dt.datetime(2025, 1, 1),
...     start=dt.datetime(2025, 1, 1),
...     end=dt.datetime(2025, 1, 7),
...     name="A datetime value"
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.slider._SliderBase: bar_color, direction, orientation, show_value, tooltips

value = param.Date(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31704c890>)

The selected date value of the slider. Updated when the slider handle is dragged. Supports datetime.datetime, datetime.date or np.datetime64 types.

value_throttled = param.Date(allow_None=True, allow_refs=False, constant=True, inclusive_bounds=(True, True), label=’Value throttled’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31704fc50>)

The value of the slider. Updated when the slider handle is released.

start = param.Date(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Start’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31704c990>)

The lower bound.

end = param.Date(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’End’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31704fbd0>)

The upper bound.

as_datetime = param.Boolean(allow_refs=False, default=False, label=’As datetime’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31704e590>)

Whether to store the date as a datetime.

step = param.Number(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Step’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31704fe10>)

The step parameter in milliseconds.

format = param.String(allow_None=True, allow_refs=False, label=’Format’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31704e590>)

Datetime format used for parsing and formatting the date.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.slider.DatetimeRangeSlider(*, end, format, start, step, value, value_throttled, bar_color, direction, orientation, show_value, tooltips, disabled, 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: DateRangeSlider

The DatetimeRangeSlider widget allows selecting a datetime range using a slider with two handles. Supports datetime.datetime and np.datetime64 ranges.

Reference: https://panel.holoviz.org/reference/widgets/DatetimeRangeSlider.html

Example:

>>> import datetime as dt
>>> DatetimeRangeSlider(
...     value=(dt.datetime(2025, 1, 9), dt.datetime(2025, 1, 16)),
...     start=dt.datetime(2025, 1, 1),
...     end=dt.datetime(2025, 1, 31),
...     step=10000,
...     name="A tuple of datetimes"
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.slider._SliderBase: bar_color, direction, orientation, show_value, tooltips

panel.widgets.slider.DateRangeSlider: value, value_start, value_end, value_throttled, start, end, format

step = param.Number(allow_refs=False, default=60000, inclusive_bounds=(True, True), label=’Step’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x317079e10>)

The step size in ms. Default is 1 min.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.slider.DiscreteSlider(*, formatter, options, value, value_throttled, bar_color, direction, orientation, show_value, tooltips, disabled, 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: CompositeWidget, _SliderBase

The DiscreteSlider widget allows selecting a value from a discrete list or dictionary of values using a slider.

Reference: https://panel.holoviz.org/reference/widgets/DiscreteSlider.html

Example:

>>> DiscreteSlider(
...     value=0,
...     options=list([0, 1, 2, 4, 8, 16, 32, 64]),
...     name="A discrete value",
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.slider._SliderBase: bar_color, direction, orientation, show_value, tooltips

value = param.Parameter(allow_None=True, allow_refs=False, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x317039a50>)

The selected value of the slider. Updated when the handle is dragged. Must be one of the options.

value_throttled = param.Parameter(allow_None=True, allow_refs=False, constant=True, label=’Value throttled’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x317096610>)

The value of the slider. Updated when the handle is released.

options = param.ClassSelector(allow_refs=False, class_=(<class ‘dict’>, <class ‘list’>), default=[], label=’Options’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x317096650>)

A list or dictionary of valid options.

formatter = param.String(allow_refs=False, default=’%.3g’, label=’Formatter’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x317096610>)

A custom format string. Separate from format parameter since formatting is applied in Python, not via the bokeh TickFormatter.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

property labels#

The list of labels to display

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

property values#

The list of option values

class panel.widgets.slider.EditableFloatSlider(*, fixed_end, fixed_start, editable, end, start, step, value, value_throttled, format, bar_color, direction, orientation, show_value, tooltips, disabled, 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: _EditableContinuousSlider, FloatSlider

The EditableFloatSlider widget allows selecting selecting a numeric floating-point value within a set of bounds using a slider and for more precise control offers an editable number input box.

Reference: https://panel.holoviz.org/reference/widgets/EditableFloatSlider.html

Example:

>>> EditableFloatSlider(
...     value=1.0, start=0.0, end=2.0, step=0.25, name="A float value"
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.slider._SliderBase: bar_color, direction, orientation, tooltips

panel.widgets.slider.ContinuousSlider: format

panel.widgets.slider.FloatSlider: start, end, step, value, value_throttled

panel.widgets.slider._EditableContinuousSlider: editable, show_value

fixed_start = param.Number(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Fixed start’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x317043710>)

A fixed lower bound for the slider and input.

fixed_end = param.Number(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Fixed end’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3170b3ed0>)

A fixed upper bound for the slider and input.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.slider.EditableIntSlider(*, fixed_end, fixed_start, editable, end, start, step, value, value_throttled, format, bar_color, direction, orientation, show_value, tooltips, disabled, 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: _EditableContinuousSlider, IntSlider

The EditableIntSlider widget allows selecting selecting an integer value within a set of bounds using a slider and for more precise control offers an editable integer input box.

Reference: https://panel.holoviz.org/reference/widgets/EditableIntSlider.html

Example:

>>> EditableIntSlider(
...     value=2, start=0, end=5, step=1, name="An integer value"
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.slider._SliderBase: bar_color, direction, orientation, tooltips

panel.widgets.slider.ContinuousSlider: format

panel.widgets.slider.IntSlider: start, end, step, value, value_throttled

panel.widgets.slider._EditableContinuousSlider: editable, show_value

fixed_start = param.Integer(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Fixed start’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x316bce6d0>)

A fixed lower bound for the slider and input.

fixed_end = param.Integer(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Fixed end’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3170c88d0>)

A fixed upper bound for the slider and input.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.slider.EditableRangeSlider(*, editable, end, fixed_end, fixed_start, format, start, step, value, value_throttled, bar_color, direction, orientation, show_value, tooltips, disabled, 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: CompositeWidget, _SliderBase

The EditableRangeSlider widget allows selecting a floating-point range using a slider with two handles and for more precise control also offers a set of number input boxes.

Reference: https://panel.holoviz.org/reference/widgets/EditableRangeSlider.html

Example:

>>> EditableRangeSlider(
...      value=(1.0, 1.5), start=0.0, end=2.0, step=0.25, name="A tuple of floats"
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.slider._SliderBase: bar_color, direction, orientation, tooltips

show_value = param.Boolean(allow_refs=False, constant=True, default=False, label=’Show value’, nested_refs=False, readonly=True, rx=<param.reactive.reactive_ops object at 0x3170ebc90>)

Whether to show the widget value.

value = param.Range(allow_refs=False, default=(0, 1), inclusive_bounds=(True, True), label=’Value’, length=2, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31710c710>)

Current range value. Updated when a handle is dragged.

value_throttled = param.Range(allow_None=True, allow_refs=False, constant=True, inclusive_bounds=(True, True), label=’Value throttled’, length=2, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31710cbd0>)

The value of the slider. Updated when the handle is released.

start = param.Number(allow_refs=False, default=0.0, inclusive_bounds=(True, True), label=’Start’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31710c790>)

Lower bound of the range.

end = param.Number(allow_refs=False, default=1.0, inclusive_bounds=(True, True), label=’End’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31710cc50>)

Upper bound of the range.

fixed_start = param.Number(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Fixed start’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31710ce50>)

A fixed lower bound for the slider and input.

fixed_end = param.Number(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Fixed end’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31710d050>)

A fixed upper bound for the slider and input.

step = param.Number(allow_refs=False, default=0.1, inclusive_bounds=(True, True), label=’Step’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31710d1d0>)

Slider and number input step.

editable = param.Tuple(allow_refs=False, default=(True, True), label=’Editable’, length=2, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3170e9b50>)

Whether the lower and upper values are editable.

format = param.ClassSelector(allow_refs=False, class_=(<class ‘str’>, <class ‘bokeh.models.formatters.TickFormatter’>), default=’0.0[0000]’, label=’Format’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3170b5190>)

Allows defining a custom format string or bokeh TickFormatter.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.slider.FloatSlider(*, end, start, step, value, value_throttled, format, bar_color, direction, orientation, show_value, tooltips, disabled, 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: ContinuousSlider

The FloatSlider widget allows selecting a floating-point value within a set of bounds using a slider.

Reference: https://panel.holoviz.org/reference/widgets/FloatSlider.html

Example:

>>> FloatSlider(value=0.5, start=0.0, end=1.0, step=0.1, name="Float value")

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.slider._SliderBase: bar_color, direction, orientation, show_value, tooltips

panel.widgets.slider.ContinuousSlider: format

start = param.Number(allow_refs=False, default=0.0, inclusive_bounds=(True, True), label=’Start’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x317132490>)

The lower bound.

end = param.Number(allow_refs=False, default=1.0, inclusive_bounds=(True, True), label=’End’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x317133910>)

The upper bound.

step = param.Number(allow_refs=False, default=0.1, inclusive_bounds=(True, True), label=’Step’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x317132550>)

The step size.

value = param.Number(allow_None=True, allow_refs=False, default=0.0, inclusive_bounds=(True, True), label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x317133850>)

The selected floating-point value of the slider. Updated when the handle is dragged.

value_throttled = param.Number(allow_None=True, allow_refs=False, constant=True, inclusive_bounds=(True, True), label=’Value throttled’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3171322d0>)

The value of the slider. Updated when the handle is released.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.slider.IntRangeSlider(*, end, format, start, step, value_throttled, value, bar_color, direction, orientation, show_value, tooltips, disabled, 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: RangeSlider

The IntRangeSlider widget allows selecting an integer range using a slider with two handles.

Reference: https://panel.holoviz.org/reference/widgets/IntRangeSlider.html

Example:

>>> IntRangeSlider(
...     value=(2, 4), start=0, end=10, step=2, name="A tuple of integers"
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.slider._SliderBase: bar_color, direction, orientation, show_value, tooltips

panel.widgets.slider.RangeSlider: value, value_start, value_end, value_throttled, format

start = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Start’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x317153d90>)

The lower bound.

end = param.Integer(allow_refs=False, default=1, inclusive_bounds=(True, True), label=’End’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3170c40d0>)

The upper bound.

step = param.Integer(allow_refs=False, default=1, inclusive_bounds=(True, True), label=’Step’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x317151750>)

The step size

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.slider.IntSlider(*, end, start, step, value, value_throttled, format, bar_color, direction, orientation, show_value, tooltips, disabled, 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: ContinuousSlider

The IntSlider widget allows selecting an integer value within a set of bounds using a slider.

Reference: https://panel.holoviz.org/reference/widgets/IntSlider.html

Example:

>>> IntSlider(value=5, start=0, end=10, step=1, name="Integer Value")

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.slider._SliderBase: bar_color, direction, orientation, show_value, tooltips

panel.widgets.slider.ContinuousSlider: format

start = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Start’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31712cc10>)

The lower bound.

end = param.Integer(allow_refs=False, default=1, inclusive_bounds=(True, True), label=’End’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x317131490>)

The upper bound.

step = param.Integer(allow_refs=False, default=1, inclusive_bounds=(True, True), label=’Step’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31712e610>)

The step size.

value = param.Integer(allow_None=True, allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3170c77d0>)

The selected integer value of the slider. Updated when the handle is dragged.

value_throttled = param.Integer(allow_None=True, allow_refs=False, constant=True, inclusive_bounds=(True, True), label=’Value throttled’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31712d8d0>)

The value of the slider. Updated when the handle is released

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.widgets.slider.RangeSlider(*, end, format, start, step, value_throttled, value, bar_color, direction, orientation, show_value, tooltips, disabled, 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: _RangeSliderBase

The RangeSlider widget allows selecting a floating-point range using a slider with two handles.

Reference: https://panel.holoviz.org/reference/widgets/RangeSlider.html

Example:

>>> RangeSlider(
...     value=(1.0, 1.5), start=0.0, end=2.0, step=0.25, name="A tuple of floats"
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.slider._SliderBase: bar_color, direction, orientation, show_value, tooltips

value = param.Range(allow_refs=False, default=(0, 1), inclusive_bounds=(True, True), label=’Value’, length=2, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x3171adc10>)

The selected range as a tuple of values. Updated when a handle is dragged.

value_start = param.Number(allow_refs=False, constant=True, default=0, inclusive_bounds=(True, True), label=’Value start’, nested_refs=False, readonly=True, rx=<param.reactive.reactive_ops object at 0x3171af310>)

The lower value of the selected range.

value_end = param.Number(allow_refs=False, constant=True, default=1, inclusive_bounds=(True, True), label=’Value end’, nested_refs=False, readonly=True, rx=<param.reactive.reactive_ops object at 0x3171adb90>)

The upper value of the selected range.

value_throttled = param.Range(allow_None=True, allow_refs=False, constant=True, inclusive_bounds=(True, True), label=’Value throttled’, length=2, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x3171aefd0>)

The selected range as a tuple of floating point values. Updated when a handle is released

start = param.Number(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Start’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3171af710>)

The lower bound.

end = param.Number(allow_refs=False, default=1, inclusive_bounds=(True, True), label=’End’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3171aef10>)

The upper bound.

step = param.Number(allow_refs=False, default=0.1, inclusive_bounds=(True, True), label=’Step’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3171af6d0>)

The step size.

format = param.ClassSelector(allow_None=True, allow_refs=False, class_=(<class ‘str’>, <class ‘bokeh.models.formatters.TickFormatter’>), label=’Format’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3171aead0>)

A format string or bokeh TickFormatter.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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


speech_to_text Module#

Inheritance diagram of panel.widgets.speech_to_text

The SpeechToText widget controls the speech recognition service of the browser.

It wraps the HTML5 SpeechRecognition API. See https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition

This functionality is experimental and only supported by Chrome and a few other browsers. Checkout https://caniuse.com/speech-recognition for a up to date list of browsers supporting the SpeechRecognition Api. Or alternatively https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition#Browser_compatibility

On some browsers, like Chrome, using Speech Recognition on a web page involves a server-based recognition engine. Your audio is sent to a web service for recognition processing, so it won’t work offline. Whether this is secure and confidential enough for your use case is up to you to evaluate.

class panel.widgets.speech_to_text.Grammar(*, src, uri, weight, name)[source]#

Bases: Parameterized

A set of words or patterns of words that we want the speech recognition service to recognize

For example

grammar = Grammar(

src=’#JSGF V1.0; grammar colors; public <color> = aqua | azure | beige;’, weight=0.7

)

Wraps the HTML SpeechGrammar API. See https://developer.mozilla.org/en-US/docs/Web/API/SpeechGrammar

src = param.String(allow_refs=False, default=’’, label=’Src’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318afe710>)

A set of words or patterns of words that we want the recognition service to recognize. Defined using JSpeech Grammar Format. See https://www.w3.org/TR/jsgf/.

uri = param.String(allow_refs=False, default=’’, label=’Uri’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318b85b10>)

An uri pointing to the definition. If src is available it will be used. Otherwise uri. The uri will be loaded on the client side only.

weight = param.Number(allow_refs=False, bounds=(0.0, 1.0), default=1, inclusive_bounds=(True, True), label=’Weight’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318b85f50>, step=0.01)

The weight of the grammar. A number in the range 0–1. Default is 1.

serialize()[source]#

Returns the grammar as dict

class panel.widgets.speech_to_text.GrammarList(iterable=(), /)[source]#

Bases: list

A list of Grammar objects containing words or patterns of words that we want the recognition service to recognize.

Example:

grammar = ‘#JSGF V1.0; grammar colors; public <color> = aqua | azure | beige | bisque ;’ grammar_list = GrammarList() grammar_list.add_from_string(grammar, 1)

Wraps the HTML 5 SpeechGrammarList API

See https://developer.mozilla.org/en-US/docs/Web/API/SpeechGrammarList

add_from_string(src, weight=1.0)[source]#

Takes a src and weight and adds it to the GrammarList as a new Grammar object. The new Grammar object is returned.

add_from_uri(uri, weight=1.0)[source]#

Takes a grammar present at a specific uri, and adds it to the GrammarList as a new Grammar object. The new Grammar object is returned.

append(object, /)#

Append object to the end of the list.

clear()#

Remove all items from list.

copy()#

Return a shallow copy of the list.

count(value, /)#

Return number of occurrences of value.

extend(iterable, /)#

Extend list by appending elements from the iterable.

index(value, start=0, stop=9223372036854775807, /)#

Return first index of value.

Raises ValueError if the value is not present.

insert(index, object, /)#

Insert object before index.

pop(index=-1, /)#

Remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove(value, /)#

Remove first occurrence of value.

Raises ValueError if the value is not present.

reverse()#

Reverse IN PLACE.

serialize()[source]#

Returns a list of serialized grammars

sort(*, key=None, reverse=False)#

Sort the list in ascending order and return None.

The sort is in-place (i.e. the list itself is modified) and stable (i.e. the order of two equal elements is maintained).

If a key function is given, apply it once to each list item and sort them, ascending or descending, according to their function values.

The reverse flag can be set to sort in descending order.

class panel.widgets.speech_to_text.Language(*, country, family, name)[source]#

Bases: Parameterized

country = param.String(allow_refs=False, default=’’, label=’Country’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318b6fe10>)

A country like ‘United States’

family = param.String(allow_refs=False, default=’’, label=’Family’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318b28e50>)

The overall language family. For example ‘English’.

class panel.widgets.speech_to_text.RecognitionAlternative(*, confidence, transcript, name)[source]#

Bases: Parameterized

The RecognitionAlternative represents a word or sentence that has been recognised by the speech recognition service.

Wraps the HTML5 SpeechRecognitionAlternative API

See https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognitionAlternative

confidence = param.Number(allow_refs=False, bounds=(0.0, 1.0), constant=True, default=0.0, inclusive_bounds=(True, True), label=’Confidence’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x113112850>)

A numeric estimate between 0 and 1 of how confident the speech recognition system is that the recognition is correct.

transcript = param.String(allow_refs=False, constant=True, default=’’, label=’Transcript’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318b86410>)

The transcript of the recognised word or sentence.

class panel.widgets.speech_to_text.RecognitionResult(*, alternatives, is_final, name)[source]#

Bases: Parameterized

The Result represents a single recognition match, which may contain multiple RecognitionAlternative objects.

Wraps the HTML5 SpeechRecognitionResult API.

See https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognitionResult

alternatives = param.List(allow_refs=False, bounds=(0, None), class_=<class ‘panel.widgets.speech_to_text.RecognitionAlternative’>, constant=True, default=[], item_type=<class ‘panel.widgets.speech_to_text.RecognitionAlternative’>, label=’Alternatives’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318b7a310>)

The list of the n-best alternatives

is_final = param.Boolean(allow_refs=False, constant=True, default=False, label=’Is final’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318b28690>)

A Boolean that states whether this result is final (True) or not (False) — if so, then this is the final time this result will be returned; if not, then this result is an interim result, and may be updated later on.

classmethod create_from_dict(result)[source]#

Deserializes a serialized RecognitionResult

classmethod create_from_list(results)[source]#

Deserializes a list of serialized RecognitionResults.

class panel.widgets.speech_to_text.SpeechToText(*, _grammars, abort, audio_started, button_hide, button_not_started, button_started, button_type, continuous, grammars, interim_results, lang, max_alternatives, results, service_uri, sound_started, speech_started, start, started, stop, value, disabled, 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: Widget

The SpeechToText widget controls the speech recognition service of the browser.

It wraps the HTML5 SpeechRecognition API. See https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition

Reference: https://panel.holoviz.org/reference/widgets/SpeechToText.html

Example:

>>> SpeechToText(button_type="light")

This functionality is experimental and only supported by Chrome and a few other browsers. Checkout https://caniuse.com/speech-recognition for a up to date list of browsers supporting the SpeechRecognition Api. Or alternatively https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition#Browser_compatibility

On some browsers, like Chrome, using Speech Recognition on a web page involves a server-based recognition engine. Your audio is sent to a web service for recognition processing, so it won’t work offline. Whether this is secure and confidential enough for your use case is up to you to evaluate.

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

abort = param.Event(allow_refs=False, default=False, label=’Abort’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3189d9d50>)

Stops the speech recognition service from listening to incoming audio, and doesn’t attempt to return a RecognitionResult.

start = param.Event(allow_refs=False, default=False, label=’Start’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318a7f710>)

Starts the speech recognition service listening to incoming audio with intent to recognize grammars associated with the current SpeechRecognition.

stop = param.Event(allow_refs=False, default=False, label=’Stop’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318b2a390>)

Stops the speech recognition service from listening to incoming audio, and attempts to return a RecognitionResult using the audio captured so far.

lang = param.ObjectSelector(allow_None=True, allow_refs=False, default=’’, names={}, nested_refs=False, objects=[‘’, ‘af-ZA’, ‘ar-AE’, ‘ar-BH’, ‘ar-DZ’, ‘ar-EG’, ‘ar-IL’, ‘ar-IQ’, ‘ar-JO’, ‘ar-KW’, ‘ar-LB’, ‘ar-MA’, ‘ar-OM’, ‘ar-PS’, ‘ar-QA’, ‘ar-SA’, ‘ar-TN’, ‘bg-BG’, ‘ca-ES’, ‘cmn-Hans-CN’, ‘cmn-Hans-HK’, ‘cmn-Hant-TW’, ‘cs-CZ’, ‘da-DK’, ‘de-DE’, ‘el-GR’, ‘en-AU’, ‘en-CA’, ‘en-GB’, ‘en-IE’, ‘en-IN’, ‘en-NZ’, ‘en-PH’, ‘en-US’, ‘en-ZA’, ‘es-AR’, ‘es-BO’, ‘es-CL’, ‘es-CO’, ‘es-CR’, ‘es-DO’, ‘es-EC’, ‘es-ES’, ‘es-GT’, ‘es-HN’, ‘es-MX’, ‘es-NI’, ‘es-PA’, ‘es-PE’, ‘es-PR’, ‘es-PY’, ‘es-SV’, ‘es-US’, ‘es-UY’, ‘es-VE’, ‘eu-ES’, ‘fa-IR’, ‘fi-FI’, ‘fil-PH’, ‘fr-FR’, ‘gl-ES’, ‘he-IL’, ‘hi-IN’, ‘hr_HR’, ‘hu-HU’, ‘id-ID’, ‘is-IS’, ‘it-CH’, ‘it-IT’, ‘ja-JP’, ‘ko-KR’, ‘lt-LT’, ‘ms-MY’, ‘nb-NO’, ‘nl-NL’, ‘pl-PL’, ‘pt-BR’, ‘pt-PT’, ‘ro-RO’, ‘ru-RU’, ‘sk-SK’, ‘sl-SI’, ‘sr-RS’, ‘sv-SE’, ‘th-TH’, ‘tr-TR’, ‘uk-UA’, ‘vi-VN’, ‘yue-Hant-HK’, ‘zu-ZA’], rx=<param.reactive.reactive_ops object at 0x318a7f710>)

The language of the current SpeechRecognition in BCP 47 format. For example ‘en-US’. If not specified, this defaults to the HTML lang attribute value, or the user agent’s language setting if that isn’t set either.

continuous = param.Boolean(allow_refs=False, default=False, label=’Continuous’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318b2a2d0>)

Controls whether continuous results are returned for each recognition, or only a single result. Defaults to False

interim_results = param.Boolean(allow_refs=False, default=False, label=’Interim results’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318a91010>)

Controls whether interim results should be returned (True) or not (False.) Interim results are results that are not yet final (e.g. the RecognitionResult.is_final property is False).

max_alternatives = param.Integer(allow_refs=False, bounds=(1, 5), default=1, inclusive_bounds=(True, True), label=’Max alternatives’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3182c66d0>)

Sets the maximum number of RecognitionAlternatives provided per result. A number between 1 and 5. The default value is 1.

service_uri = param.String(allow_refs=False, default=’’, label=’Service uri’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318a7fb50>)

Specifies the location of the speech recognition service used by the current SpeechRecognition to handle the actual recognition. The default is the user agent’s default speech service.

grammars = param.ClassSelector(allow_None=True, allow_refs=False, class_=<class ‘panel.widgets.speech_to_text.GrammarList’>, label=’Grammars’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3189d81d0>)

A GrammarList object that represents the grammars that will be understood by the current SpeechRecognition service

button_hide = param.Boolean(allow_refs=False, default=False, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3189da090>)

If True no button is shown. If False a toggle Start/ Stop button is shown.

button_type = param.ObjectSelector(allow_refs=False, default=’light’, label=’Button type’, names={}, nested_refs=False, objects=[‘default’, ‘primary’, ‘success’, ‘warning’, ‘danger’, ‘light’, ‘light’, ‘dark’], rx=<param.reactive.reactive_ops object at 0x3189d8510>)

The button styling.

button_not_started = param.String(allow_refs=False, default=’’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3189da090>)

The text to show on the button when the SpeechRecognition service is NOT started. If ‘’ a muted microphone icon is shown.

button_started = param.String(allow_refs=False, default=’’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3189d8490>)

The text to show on the button when the SpeechRecognition service is started. If ‘’ a muted microphone icon is shown.

started = param.Boolean(allow_refs=False, constant=True, default=False, label=’Started’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3189d9e50>)

Returns True if the Speech Recognition Service is started and False otherwise.

audio_started = param.Boolean(allow_refs=False, constant=True, default=False, label=’Audio started’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3189d8790>)

Returns True if the Audio is started and False otherwise.

sound_started = param.Boolean(allow_refs=False, constant=True, default=False, label=’Sound started’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3189d8510>)

Returns True if the Sound is started and False otherwise.

speech_started = param.Boolean(allow_refs=False, constant=True, default=False, label=’Speech started’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3189d8450>)

Returns True if the the User has started speaking and False otherwise.

results = param.List(allow_refs=False, bounds=(0, None), constant=True, default=[], label=’Results’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3189d8310>)

The results as a list of Dictionaries.

value = param.String(allow_refs=False, constant=True, default=’’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3189d8450>)

The transcipt of the highest confidence RecognitionAlternative of the last RecognitionResult. Please note we strip the transcript for leading spaces.

_grammars = param.List(allow_refs=False, bounds=(0, None), constant=True, default=[], label=’ grammars’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3189d9110>)

List used to transfer the serialized grammars from server to browser.

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.

property results_as_html: str#

Returns the results formatted as html

Convenience method for ease of use

property results_deserialized#

Returns the results as a List of RecognitionResults

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


tables Module#

Inheritance diagram of panel.widgets.tables
class panel.widgets.tables.BaseTable(value=None, **params)[source]#

Bases: ReactiveData, Widget

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

selection = param.List(allow_refs=True, bounds=(0, None), default=[], item_type=<class ‘int’>, label=’Selection’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318e2bcd0>)

The currently selected rows of the table.

aggregators = param.Dict(allow_refs=True, class_=<class ‘dict’>, default={}, label=’Aggregators’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x318e2a350>)

A dictionary mapping from index name to an aggregator to be used for hierarchical multi-indexes (valid aggregators include ‘min’, ‘max’, ‘mean’ and ‘sum’). If separate aggregators for different columns are required the dictionary may be nested as {index_name: {column_name: aggregator}}

editors = param.Dict(allow_refs=True, class_=<class ‘dict’>, default={}, label=’Editors’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x318e2be90>)

Bokeh CellEditor to use for a particular column (overrides the default chosen based on the type).

formatters = param.Dict(allow_refs=True, class_=<class ‘dict’>, default={}, label=’Formatters’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x318e2a410>)

Bokeh CellFormatter to use for a particular column (overrides the default chosen based on the type).

hierarchical = param.Boolean(allow_refs=True, constant=True, default=False, label=’Hierarchical’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318e4e390>)

Whether to generate a hierarchical index.

row_height = param.Integer(allow_refs=False, default=40, inclusive_bounds=(True, True), label=’Row height’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318cabfd0>)

The height of each table row.

show_index = param.Boolean(allow_refs=True, default=True, label=’Show index’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318e4e390>)

Whether to show the index column.

sorters = param.List(allow_refs=True, bounds=(0, None), default=[], label=’Sorters’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318e2b8d0>)

A list of sorters to apply during pagination.

text_align = param.ClassSelector(allow_refs=True, class_=(<class ‘dict’>, <class ‘str’>), default={}, label=’Text align’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x318e2be90>)

A mapping from column name to alignment or a fixed column alignment, which should be one of ‘left’, ‘center’, ‘right’.

titles = param.Dict(allow_refs=True, class_=<class ‘dict’>, default={}, label=’Titles’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x318e2b0d0>)

A mapping from column name to a title to override the name with.

widths = param.ClassSelector(allow_refs=True, class_=(<class ‘dict’>, <class ‘int’>), default={}, label=’Widths’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x318e2ae90>)

A mapping from column name to column width or a fixed column width.

value = param.Parameter(allow_None=True, allow_refs=True, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318659510>)

add_filter(filter, column=None)[source]#

Adds a filter to the table which can be a static value or dynamic parameter based object which will automatically update the table when changed..

When a static value, widget or parameter is supplied the filtering will follow a few well defined behaviors:

  • scalar: Filters by checking for equality

  • tuple: A tuple will be interpreted as range.

  • list: A list will be interpreted as a set of discrete

    scalars and the filter will check if the values in the column match any of the items in the list.

Parameters:
  • filter (Widget, param.Parameter or FunctionType) – The value by which to filter the DataFrame along the declared column, or a function accepting the DataFrame to be filtered and returning a filtered copy of the DataFrame.

  • column (str or None) – Column to which the filter will be applied, if the filter is a constant value, widget or parameter.

Raises:

ValueError – If the filter type is not supported or no column: was declared.

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

property current_view#

Returns the current view of the table after filtering and sorting are applied.

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 from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.

patch(patch_value, as_index=True)[source]#

Efficiently patches (updates) the existing value with the patch_value.

Parameters:
  • patch_value ((pd.DataFrame | pd.Series | Dict)) – The value(s) to patch the existing value with.

  • as_index (boolean) – Whether to treat the patch index as DataFrame indexes (True) or as simple integer index.

Raises:

ValueError – Raised if the patch_value is not a supported type.:

Examples

Patch a DataFrame with a Dictionary row. >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> patch_value = {“x”: [(0, 3)]} >>> tabulator.patch(patch_value) >>> tabulator.value.to_dict(“list”) {‘x’: [3, 2], ‘y’: [‘a’, ‘b’]}

Patch a Dataframe with a Dictionary of Columns. >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> patch_value = {“x”: [(slice(2), (3,4))], “y”: [(1,’d’)]} >>> tabulator.patch(patch_value) >>> tabulator.value.to_dict(“list”) {‘x’: [3, 4], ‘y’: [‘a’, ‘d’]}

Patch a DataFrame with a Series. Please note the index is used in the update. >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> patch_value = pd.Series({“index”: 1, “x”: 4, “y”: “d”}) >>> tabulator.patch(patch_value) >>> tabulator.value.to_dict(“list”) {‘x’: [1, 4], ‘y’: [‘a’, ‘d’]}

Patch a Dataframe with a Dataframe. Please note the index is used in the update. >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> patch_value = pd.DataFrame({“x”: [3, 4], “y”: [“c”, “d”]}) >>> tabulator.patch(patch_value) >>> tabulator.value.to_dict(“list”) {‘x’: [3, 4], ‘y’: [‘c’, ‘d’]}

remove_filter(filter)[source]#

Removes a filter which was previously added.

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)

property selected_dataframe#

Returns a DataFrame of the currently selected rows.

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

stream(stream_value, rollover=None, reset_index=True)[source]#

Streams (appends) the stream_value provided to the existing value in an efficient manner.

Parameters:
  • stream_value ((pd.DataFrame | pd.Series | Dict)) – The new value(s) to append to the existing value.

  • rollover (int) – A maximum column size, above which data from the start of the column begins to be discarded. If None, then columns will continue to grow unbounded.

  • reset_index ((bool, default=True)) – If True and the stream_value is a DataFrame, then its index is reset. Helps to keep the index unique and named index

Raises:

ValueError – Raised if the stream_value is not a supported type.:

Examples

Stream a Series to a DataFrame >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> stream_value = pd.Series({“x”: 4, “y”: “d”}) >>> tabulator.stream(stream_value) >>> tabulator.value.to_dict(“list”) {‘x’: [1, 2, 4], ‘y’: [‘a’, ‘b’, ‘d’]}

Stream a Dataframe to a Dataframe >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> stream_value = pd.DataFrame({“x”: [3, 4], “y”: [“c”, “d”]}) >>> tabulator.stream(stream_value) >>> tabulator.value.to_dict(“list”) {‘x’: [1, 2, 3, 4], ‘y’: [‘a’, ‘b’, ‘c’, ‘d’]}

Stream a Dictionary row to a DataFrame >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> stream_value = {“x”: 4, “y”: “d”} >>> tabulator.stream(stream_value) >>> tabulator.value.to_dict(“list”) {‘x’: [1, 2, 4], ‘y’: [‘a’, ‘b’, ‘d’]}

Stream a Dictionary of Columns to a Dataframe >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> stream_value = {“x”: [3, 4], “y”: [“c”, “d”]} >>> tabulator.stream(stream_value) >>> tabulator.value.to_dict(“list”) {‘x’: [1, 2, 3, 4], ‘y’: [‘a’, ‘b’, ‘c’, ‘d’]}

class panel.widgets.tables.DataFrame(value=None, **params)[source]#

Bases: BaseTable

The DataFrame widget allows displaying and editing a pandas DataFrame.

Note that editing is not possible for multi-indexed DataFrames, in which case you will need to reduce the DataFrame to a single index.

Also note that the DataFrame widget will eventually be replaced with the Tabulator widget, and so new code should be written to use Tabulator instead.

Reference: https://panel.holoviz.org/reference/widgets/DataFrame.html

Example:

>>> DataFrame(df, name='DataFrame')

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.tables.BaseTable: selection, aggregators, editors, formatters, hierarchical, row_height, show_index, sorters, text_align, titles, widths, value

auto_edit = param.Boolean(allow_refs=False, default=False, label=’Auto edit’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318efe4d0>)

Whether clicking on a table cell automatically starts edit mode.

autosize_mode = param.ObjectSelector(allow_refs=False, default=’force_fit’, label=’Autosize mode’, names={}, nested_refs=False, objects=[‘none’, ‘fit_columns’, ‘fit_viewport’, ‘force_fit’], rx=<param.reactive.reactive_ops object at 0x318ee94d0>)

Determines the column autosizing mode, as one of the following options: "fit_columns" Compute column widths based on cell contents while ensuring the table fits into the available viewport. This results in no horizontal scrollbar showing up, but data can get unreadable if there is not enough space available. "fit_viewport" Adjust the viewport size after computing column widths based on cell contents. "force_fit" Fit columns into available space dividing the table width across the columns equally (equivalent to fit_columns=True). This results in no horizontal scrollbar showing up, but data can get unreadable if there is not enough space available. "none" Do not automatically compute column widths.

fit_columns = param.Boolean(allow_None=True, allow_refs=False, label=’Fit columns’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318eeb7d0>)

Whether columns should expand to the available width. This results in no horizontal scrollbar showing up, but data can get unreadable if there is no enough space available.

frozen_columns = param.Integer(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Frozen columns’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318ef1c90>)

Integer indicating the number of columns to freeze. If set, the first N columns will be frozen, which prevents them from scrolling out of frame.

frozen_rows = param.Integer(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Frozen rows’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318ef3b90>)

Integer indicating the number of rows to freeze. If set, the first N rows will be frozen, which prevents them from scrolling out of frame; if set to a negative value the last N rows will be frozen.

reorderable = param.Boolean(allow_refs=False, default=True, label=’Reorderable’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318eeb490>)

Allows the reordering of a table’s columns. To reorder a column, click and drag a table’s header to the desired location in the table. The columns on either side will remain in their previous order.

sortable = param.Boolean(allow_refs=False, default=True, label=’Sortable’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318eeb7d0>)

Allows to sort table’s contents. By default natural order is preserved. To sort a column, click on its header. Clicking one more time changes sort direction. Use Ctrl + click to return to natural order. Use Shift + click to sort multiple columns simultaneously.

add_filter(filter, column=None)[source]#

Adds a filter to the table which can be a static value or dynamic parameter based object which will automatically update the table when changed..

When a static value, widget or parameter is supplied the filtering will follow a few well defined behaviors:

  • scalar: Filters by checking for equality

  • tuple: A tuple will be interpreted as range.

  • list: A list will be interpreted as a set of discrete

    scalars and the filter will check if the values in the column match any of the items in the list.

Parameters:
  • filter (Widget, param.Parameter or FunctionType) – The value by which to filter the DataFrame along the declared column, or a function accepting the DataFrame to be filtered and returning a filtered copy of the DataFrame.

  • column (str or None) – Column to which the filter will be applied, if the filter is a constant value, widget or parameter.

Raises:

ValueError – If the filter type is not supported or no column: was declared.

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

property current_view#

Returns the current view of the table after filtering and sorting are applied.

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 from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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.

patch(patch_value, as_index=True)[source]#

Efficiently patches (updates) the existing value with the patch_value.

Parameters:
  • patch_value ((pd.DataFrame | pd.Series | Dict)) – The value(s) to patch the existing value with.

  • as_index (boolean) – Whether to treat the patch index as DataFrame indexes (True) or as simple integer index.

Raises:

ValueError – Raised if the patch_value is not a supported type.:

Examples

Patch a DataFrame with a Dictionary row. >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> patch_value = {“x”: [(0, 3)]} >>> tabulator.patch(patch_value) >>> tabulator.value.to_dict(“list”) {‘x’: [3, 2], ‘y’: [‘a’, ‘b’]}

Patch a Dataframe with a Dictionary of Columns. >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> patch_value = {“x”: [(slice(2), (3,4))], “y”: [(1,’d’)]} >>> tabulator.patch(patch_value) >>> tabulator.value.to_dict(“list”) {‘x’: [3, 4], ‘y’: [‘a’, ‘d’]}

Patch a DataFrame with a Series. Please note the index is used in the update. >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> patch_value = pd.Series({“index”: 1, “x”: 4, “y”: “d”}) >>> tabulator.patch(patch_value) >>> tabulator.value.to_dict(“list”) {‘x’: [1, 4], ‘y’: [‘a’, ‘d’]}

Patch a Dataframe with a Dataframe. Please note the index is used in the update. >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> patch_value = pd.DataFrame({“x”: [3, 4], “y”: [“c”, “d”]}) >>> tabulator.patch(patch_value) >>> tabulator.value.to_dict(“list”) {‘x’: [3, 4], ‘y’: [‘c’, ‘d’]}

remove_filter(filter)[source]#

Removes a filter which was previously added.

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)

property selected_dataframe#

Returns a DataFrame of the currently selected rows.

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

stream(stream_value, rollover=None, reset_index=True)[source]#

Streams (appends) the stream_value provided to the existing value in an efficient manner.

Parameters:
  • stream_value ((pd.DataFrame | pd.Series | Dict)) – The new value(s) to append to the existing value.

  • rollover (int) – A maximum column size, above which data from the start of the column begins to be discarded. If None, then columns will continue to grow unbounded.

  • reset_index ((bool, default=True)) – If True and the stream_value is a DataFrame, then its index is reset. Helps to keep the index unique and named index

Raises:

ValueError – Raised if the stream_value is not a supported type.:

Examples

Stream a Series to a DataFrame >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> stream_value = pd.Series({“x”: 4, “y”: “d”}) >>> tabulator.stream(stream_value) >>> tabulator.value.to_dict(“list”) {‘x’: [1, 2, 4], ‘y’: [‘a’, ‘b’, ‘d’]}

Stream a Dataframe to a Dataframe >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> stream_value = pd.DataFrame({“x”: [3, 4], “y”: [“c”, “d”]}) >>> tabulator.stream(stream_value) >>> tabulator.value.to_dict(“list”) {‘x’: [1, 2, 3, 4], ‘y’: [‘a’, ‘b’, ‘c’, ‘d’]}

Stream a Dictionary row to a DataFrame >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> stream_value = {“x”: 4, “y”: “d”} >>> tabulator.stream(stream_value) >>> tabulator.value.to_dict(“list”) {‘x’: [1, 2, 4], ‘y’: [‘a’, ‘b’, ‘d’]}

Stream a Dictionary of Columns to a Dataframe >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> stream_value = {“x”: [3, 4], “y”: [“c”, “d”]} >>> tabulator.stream(stream_value) >>> tabulator.value.to_dict(“list”) {‘x’: [1, 2, 3, 4], ‘y’: [‘a’, ‘b’, ‘c’, ‘d’]}

class panel.widgets.tables.Tabulator(value=None, **params)[source]#

Bases: BaseTable

The Tabulator widget wraps the [Tabulator js](http://tabulator.info/) table to provide a full-featured, very powerful interactive table.

Reference: https://panel.holoviz.org/reference/widgets/Tabulator.html

Example:

>>> Tabulator(df, theme='site', pagination='remote', page_size=25)

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.tables.BaseTable: selection, aggregators, editors, formatters, hierarchical, show_index, sorters, text_align, titles, widths, value

row_height = param.Integer(allow_refs=True, default=30, inclusive_bounds=(True, True), label=’Row height’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318f184d0>)

The height of each table row.

buttons = param.Dict(allow_refs=True, class_=<class ‘dict’>, default={}, label=’Buttons’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x318efc2d0>)

Dictionary mapping from column name to a HTML element to use as the button icon.

expanded = param.List(allow_refs=True, bounds=(0, None), default=[], label=’Expanded’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x318f19a10>)

List of expanded rows, only applicable if a row_content function has been defined.

embed_content = param.Boolean(allow_refs=True, default=False, label=’Embed content’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318f1a590>)

Whether to embed the row_content or render it dynamically when a row is expanded.

filters = param.List(allow_refs=True, bounds=(0, None), default=[], label=’Filters’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318f19210>)

List of client-side filters declared as dictionaries containing ‘field’, ‘type’ and ‘value’ keys.

frozen_columns = param.ClassSelector(allow_refs=True, class_=(<class ‘list’>, <class ‘dict’>), default=[], label=’Frozen columns’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x318f1ab90>)

One of: - List indicating the columns to freeze. The column(s) may be selected by name or index. - Dict indicating columns to freeze as keys and their freeze location as values, freeze location is either ‘right’ or ‘left’.

frozen_rows = param.List(allow_refs=True, bounds=(0, None), default=[], label=’Frozen rows’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x318f19210>)

List indicating the rows to freeze. If set, the first N rows will be frozen, which prevents them from scrolling out of frame; if set to a negative value the last N rows will be frozen.

groups = param.Dict(allow_refs=True, class_=<class ‘dict’>, default={}, label=’Groups’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x318f1ab90>)

Dictionary mapping defining the groups.

groupby = param.List(allow_refs=True, bounds=(0, None), default=[], label=’Groupby’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x318f19210>)

Groups rows in the table by one or more columns.

header_align = param.ClassSelector(allow_refs=True, class_=(<class ‘dict’>, <class ‘str’>), default={}, label=’Header align’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x318f1ab90>)

A mapping from column name to alignment or a fixed column alignment, which should be one of ‘left’, ‘center’, ‘right’.

header_filters = param.ClassSelector(allow_None=True, allow_refs=True, class_=(<class ‘bool’>, <class ‘dict’>), label=’Header filters’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x318f19210>)

Whether to enable filters in the header or dictionary configuring filters for each column.

hidden_columns = param.List(allow_refs=True, bounds=(0, None), default=[], label=’Hidden columns’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x318f1ab90>)

List of columns to hide.

layout = param.ObjectSelector(allow_refs=True, default=’fit_data_table’, label=’Layout’, names={}, nested_refs=False, objects=[‘fit_data’, ‘fit_data_fill’, ‘fit_data_stretch’, ‘fit_data_table’, ‘fit_columns’], rx=<param.reactive.reactive_ops object at 0x318f18890>)

pagination = param.ObjectSelector(allow_None=True, allow_refs=True, label=’Pagination’, names={}, nested_refs=False, objects=[‘local’, ‘remote’], rx=<param.reactive.reactive_ops object at 0x318f19a10>)

page = param.Integer(allow_refs=True, default=1, inclusive_bounds=(True, True), label=’Page’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318eff890>)

Currently selected page (indexed starting at 1), if pagination is enabled.

page_size = param.Integer(allow_refs=True, bounds=(1, None), default=20, inclusive_bounds=(True, True), label=’Page size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318eff210>)

Number of rows to render per page, if pagination is enabled.

row_content = param.Callable(allow_None=True, allow_refs=True, label=’Row content’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318f18610>)

A function which is given the DataFrame row and should return a Panel object to render as additional detail below the row.

selectable = param.ClassSelector(allow_refs=True, class_=(<class ‘bool’>, <class ‘str’>, <class ‘int’>), default=True, label=’Selectable’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318f1a590>)

Defines the selection mode of the Tabulator. - True Selects rows on click. To select multiple use Ctrl-select, to select a range use Shift-select - False Disables selection - ‘checkbox’ Adds a column of checkboxes to toggle selections - ‘checkbox-single’ Same as ‘checkbox’ but header does not allow select/deselect all - ‘toggle’ Selection toggles when clicked - int The maximum number of selectable rows.

selectable_rows = param.Callable(allow_None=True, allow_refs=True, label=’Selectable rows’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318f18890>)

A function which given a DataFrame should return a list of rows by integer index, which are selectable.

sortable = param.ClassSelector(allow_refs=True, class_=(<class ‘bool’>, <class ‘dict’>), default=True, label=’Sortable’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318f19b50>)

Whether the columns in the table should be sortable. Can either be specified as a simple boolean toggling the behavior on and off or as a dictionary specifying the option per column.

theme = param.ObjectSelector(allow_refs=True, default=’simple’, label=’Theme’, names={}, nested_refs=False, objects=[‘default’, ‘site’, ‘simple’, ‘midnight’, ‘modern’, ‘bootstrap’, ‘bootstrap4’, ‘materialize’, ‘bulma’, ‘semantic-ui’, ‘fast’, ‘bootstrap5’], rx=<param.reactive.reactive_ops object at 0x318f18610>)

Tabulator CSS theme to apply to table.

theme_classes = param.List(allow_refs=True, bounds=(0, None), class_=<class ‘str’>, default=[], item_type=<class ‘str’>, label=’Theme classes’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x318f19a10>)

List of extra CSS classes to apply to the Tabulator element to customize the theme.

title_formatters = param.Dict(allow_refs=True, class_=<class ‘dict’>, default={}, label=’Title formatters’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x318f18890>)

Tabulator formatter specification to use for a particular column header title.

add_filter(filter, column=None)[source]#

Adds a filter to the table which can be a static value or dynamic parameter based object which will automatically update the table when changed..

When a static value, widget or parameter is supplied the filtering will follow a few well defined behaviors:

  • scalar: Filters by checking for equality

  • tuple: A tuple will be interpreted as range.

  • list: A list will be interpreted as a set of discrete

    scalars and the filter will check if the values in the column match any of the items in the list.

Parameters:
  • filter (Widget, param.Parameter or FunctionType) – The value by which to filter the DataFrame along the declared column, or a function accepting the DataFrame to be filtered and returning a filtered copy of the DataFrame.

  • column (str or None) – Column to which the filter will be applied, if the filter is a constant value, widget or parameter.

Raises:

ValueError – If the filter type is not supported or no column: was declared.

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

property current_view: pd.DataFrame#

Returns the current view of the table after filtering and sorting are applied.

download(filename: str = 'table.csv')[source]#

Triggers downloading of the table as a CSV or JSON.

Parameters:

filename (str) – The filename to save the table as.

download_menu(text_kwargs={}, button_kwargs={})[source]#

Returns a menu containing a TextInput and Button widget to set the filename and trigger a client-side download of the data.

Parameters:
  • text_kwargs (dict) – Keyword arguments passed to the TextInput constructor

  • button_kwargs (dict) – Keyword arguments passed to the Button constructor

Returns:

  • filename (TextInput) – The TextInput widget setting a filename.

  • button (Button) – The Button that triggers a download.

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 from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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_click(callback: Callable[[CellClickEvent], None], column: Optional[str] = None)[source]#

Register a callback to be executed when any cell is clicked. The callback is given a CellClickEvent declaring the column and row of the cell that was clicked.

Parameters:
  • callback ((callable)) – The callback to run on edit events.

  • column ((str)) – Optional argument restricting the callback to a specific column.

on_edit(callback: Callable[[TableEditEvent], None])[source]#

Register a callback to be executed when a cell is edited. Whenever a cell is edited on_edit callbacks are called with a TableEditEvent as the first argument containing the column, row and value of the edited cell.

Parameters:

callback ((callable)) – The callback to run on edit events.

patch(patch_value, as_index=True)[source]#

Efficiently patches (updates) the existing value with the patch_value.

Parameters:
  • patch_value ((pd.DataFrame | pd.Series | Dict)) – The value(s) to patch the existing value with.

  • as_index (boolean) – Whether to treat the patch index as DataFrame indexes (True) or as simple integer index.

Raises:

ValueError – Raised if the patch_value is not a supported type.:

Examples

Patch a DataFrame with a Dictionary row. >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> patch_value = {“x”: [(0, 3)]} >>> tabulator.patch(patch_value) >>> tabulator.value.to_dict(“list”) {‘x’: [3, 2], ‘y’: [‘a’, ‘b’]}

Patch a Dataframe with a Dictionary of Columns. >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> patch_value = {“x”: [(slice(2), (3,4))], “y”: [(1,’d’)]} >>> tabulator.patch(patch_value) >>> tabulator.value.to_dict(“list”) {‘x’: [3, 4], ‘y’: [‘a’, ‘d’]}

Patch a DataFrame with a Series. Please note the index is used in the update. >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> patch_value = pd.Series({“index”: 1, “x”: 4, “y”: “d”}) >>> tabulator.patch(patch_value) >>> tabulator.value.to_dict(“list”) {‘x’: [1, 4], ‘y’: [‘a’, ‘d’]}

Patch a Dataframe with a Dataframe. Please note the index is used in the update. >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> patch_value = pd.DataFrame({“x”: [3, 4], “y”: [“c”, “d”]}) >>> tabulator.patch(patch_value) >>> tabulator.value.to_dict(“list”) {‘x’: [3, 4], ‘y’: [‘c’, ‘d’]}

remove_filter(filter)[source]#

Removes a filter which was previously added.

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)

property selected_dataframe#

Returns a DataFrame of the currently selected rows.

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

stream(stream_value, rollover=None, reset_index=True, follow=True)[source]#

Streams (appends) the stream_value provided to the existing value in an efficient manner.

Parameters:
  • stream_value ((pd.DataFrame | pd.Series | Dict)) – The new value(s) to append to the existing value.

  • rollover (int) – A maximum column size, above which data from the start of the column begins to be discarded. If None, then columns will continue to grow unbounded.

  • reset_index ((bool, default=True)) – If True and the stream_value is a DataFrame, then its index is reset. Helps to keep the index unique and named index

Raises:

ValueError – Raised if the stream_value is not a supported type.:

Examples

Stream a Series to a DataFrame >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> stream_value = pd.Series({“x”: 4, “y”: “d”}) >>> tabulator.stream(stream_value) >>> tabulator.value.to_dict(“list”) {‘x’: [1, 2, 4], ‘y’: [‘a’, ‘b’, ‘d’]}

Stream a Dataframe to a Dataframe >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> stream_value = pd.DataFrame({“x”: [3, 4], “y”: [“c”, “d”]}) >>> tabulator.stream(stream_value) >>> tabulator.value.to_dict(“list”) {‘x’: [1, 2, 3, 4], ‘y’: [‘a’, ‘b’, ‘c’, ‘d’]}

Stream a Dictionary row to a DataFrame >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> stream_value = {“x”: 4, “y”: “d”} >>> tabulator.stream(stream_value) >>> tabulator.value.to_dict(“list”) {‘x’: [1, 2, 4], ‘y’: [‘a’, ‘b’, ‘d’]}

Stream a Dictionary of Columns to a Dataframe >>> value = pd.DataFrame({“x”: [1, 2], “y”: [“a”, “b”]}) >>> tabulator = Tabulator(value=value) >>> stream_value = {“x”: [3, 4], “y”: [“c”, “d”]} >>> tabulator.stream(stream_value) >>> tabulator.value.to_dict(“list”) {‘x’: [1, 2, 3, 4], ‘y’: [‘a’, ‘b’, ‘c’, ‘d’]}


terminal Module#

Inheritance diagram of panel.widgets.terminal

The Terminal Widget makes it easy to create Panel Applications with Terminals.

  • For example apps which streams the output of processes or logs.

  • For example apps which provide interactive bash, python or ipython terminals

class panel.widgets.terminal.Terminal(output=None, **params)[source]#

Bases: Widget

The Terminal widget renders a live terminal in the browser using the xterm.js library making it possible to display logs or even provide an interactive terminal in a Panel application.

Reference: https://panel.holoviz.org/reference/widgets/Terminal.html

Example:

>>> Terminal(
...     "Welcome to the Panel Terminal!", options={"cursorBlink": True}
... )

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

clear = param.Action(allow_None=True, allow_refs=False, constant=True, label=’Clear’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31972b550>)

Clears the Terminal.

options = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Options’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x319727f50>)

Initial Options for the Terminal Constructor. cf. https://xtermjs.org/docs/api/terminal/interfaces/iterminaloptions/

output = param.String(allow_refs=False, default=’’, label=’Output’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31972be50>)

System output written to the Terminal

ncols = param.Integer(allow_refs=False, constant=True, default=0, inclusive_bounds=(True, True), label=’Ncols’, nested_refs=False, readonly=True, rx=<param.reactive.reactive_ops object at 0x319728210>)

The number of columns in the terminal.

nrows = param.Integer(allow_refs=False, constant=True, default=0, inclusive_bounds=(True, True), label=’Nrows’, nested_refs=False, readonly=True, rx=<param.reactive.reactive_ops object at 0x319727750>)

The number of rows in the terminal.

value = param.String(allow_refs=False, constant=True, default=’’, nested_refs=False, readonly=True, rx=<param.reactive.reactive_ops object at 0x319728a90>)

User input received from the Terminal. Sent one character at the time.

write_to_console = param.Boolean(allow_refs=False, default=False, label=’Write to console’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3194dab90>)

Whether or not to write to the server console.

_clears = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’ clears’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31972bbd0>)

Sends a signal to clear the terminal

_output = param.String(allow_refs=False, default=’’, label=’ output’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x318da9390>)

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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

property subprocess#

The subprocess enables running commands like ‘ls’, [‘ls’, ‘-l’], ‘bash’, ‘python’ and ‘ipython’ in the terminal.

class panel.widgets.terminal.TerminalSubprocess(terminal, **kwargs)[source]#

Bases: Parameterized

The TerminalSubProcess is a utility class that makes running subprocesses via the Terminal easy.

args = param.ClassSelector(allow_None=True, allow_refs=False, class_=(<class ‘str’>, <class ‘list’>), label=’Args’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31959be10>)

The arguments used to run the subprocess. This may be a string or a list. The string cannot contain spaces. See subprocess.run docs for more details.

kill = param.Action(allow_None=True, allow_refs=False, constant=True, label=’Kill’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x3197495d0>)

Kills the running process

kwargs = param.Dict(allow_None=True, allow_refs=False, class_=<class ‘dict’>, label=’Kwargs’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x319749dd0>)

Any other arguments to run the subprocess. See subprocess.run docs for more details.

running = param.Boolean(allow_refs=False, constant=True, default=False, label=’Running’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31974b210>)

Whether or not the subprocess is running.

_child_pid = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’ child pid’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31974a8d0>)

Child process id

_fd = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’ fd’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x319727510>)

Child file descriptor.

_max_read_bytes = param.Integer(allow_refs=False, default=20480, inclusive_bounds=(True, True), label=’ max read bytes’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x319749950>)

_periodic_callback = param.ClassSelector(allow_None=True, allow_refs=False, class_=<class ‘panel.io.callbacks.PeriodicCallback’>, label=’ periodic callback’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31974a0d0>)

Watches the subprocess for output

_period = param.Integer(allow_refs=False, default=50, inclusive_bounds=(True, True), label=’ period’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x319749390>)

Period length of _periodic_callback

_terminal = param.Parameter(allow_None=True, allow_refs=False, constant=True, label=’ terminal’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x319727510>)

The Terminal to which the subprocess is connected.

_timeout_sec = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’ timeout sec’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x31974a1d0>)

_watcher = param.Parameter(allow_None=True, allow_refs=False, label=’ watcher’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x319726710>)

Watches the subprocess for user input

run(*args, **kwargs)[source]#

Runs a subprocess command.


text_to_speech Module#

Inheritance diagram of panel.widgets.text_to_speech

The Panel TextToSpeak Widget provides functionality for text to speech via the the HTML5 SpeechSynthesis API.

See https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis

The term utterance is used throughout the API. It is the smallest unit of speech in spoken language analysis.

class panel.widgets.text_to_speech.TextToSpeech(*, _voices, auto_speak, cancel, pause, resume, speak, lang, pitch, rate, value, voice, volume, disabled, 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: Utterance, Widget

The TextToSpeech widget wraps the HTML5 SpeechSynthesis API

See https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis

Reference: https://panel.holoviz.org/reference/widgets/TextToSpeech.html

Example:

>>> TextToSpeech(name="Speech Synthesis", value="Data apps are nice")

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width, disabled

panel.widgets.text_to_speech.Utterance: value, lang, pitch, rate, voice, volume

auto_speak = param.Boolean(allow_refs=False, default=True, label=’Auto speak’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x319a91110>)

Whether or not to automatically speak when the value changes.

cancel = param.Event(allow_refs=False, default=False, label=’Cancel’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x319ab2350>)

Removes all utterances from the utterance queue.

pause = param.Event(allow_refs=False, default=False, label=’Pause’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x319a91690>)

Puts the TextToSpeak object into a paused state.

resume = param.Event(allow_refs=False, default=False, label=’Resume’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x319ab2210>)

Puts the TextToSpeak object into a non-paused state: resumes it if it was already paused.

paused = param.Boolean(allow_refs=False, constant=True, default=False, label=’Paused’, nested_refs=False, readonly=True, rx=<param.reactive.reactive_ops object at 0x319a91350>)

A Boolean that returns true if the TextToSpeak object is in a paused state.

pending = param.Boolean(allow_refs=False, constant=True, default=False, label=’Pending’, nested_refs=False, readonly=True, rx=<param.reactive.reactive_ops object at 0x319ab3190>)

A Boolean that returns true if the utterance queue contains as-yet-unspoken utterances.

speak = param.Event(allow_refs=False, default=False, label=’Speak’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x319a91690>)

Speak. I.e. send a new Utterance to the browser

speaking = param.Boolean(allow_refs=False, constant=True, default=False, label=’Speaking’, nested_refs=False, readonly=True, rx=<param.reactive.reactive_ops object at 0x319ab2110>)

A Boolean that returns true if an utterance is currently in the process of being spoken — even if TextToSpeak is in a paused state.

voices = param.List(allow_refs=False, bounds=(0, None), constant=True, default=[], label=’Voices’, nested_refs=False, readonly=True, rx=<param.reactive.reactive_ops object at 0x319a91350>)

Returns a list of Voice objects representing all the available voices on the current device.

_voices = param.List(allow_refs=False, bounds=(0, None), default=[], label=’ voices’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x319ab2210>)

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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

set_voices(voices)[source]#

Updates the lang and voice parameter objects, default and value

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

to_dict(include_uuid=True)[source]#

Returns the object parameter values in a dictionary

Returns:

[description]

Return type:

Dict

class panel.widgets.text_to_speech.Utterance(*, lang, pitch, rate, value, voice, volume, name)[source]#

Bases: Parameterized

An utterance is the smallest unit of speech in spoken language analysis.

The Utterance Model wraps the HTML5 SpeechSynthesisUtterance API

See https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesisUtterance

value = param.String(allow_refs=False, default=’’, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x319a36710>)

The text that will be synthesised when the utterance is spoken. The text may be provided as plain text, or a well-formed SSML document.

lang = param.ObjectSelector(allow_refs=False, default=’’, label=’Lang’, names={}, nested_refs=False, objects=[‘’], rx=<param.reactive.reactive_ops object at 0x319aeb1d0>)

The language of the utterance.

pitch = param.Number(allow_refs=False, bounds=(0.0, 2.0), default=1.0, inclusive_bounds=(True, True), label=’Pitch’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x319aeb510>)

The pitch at which the utterance will be spoken at expressed as a number between 0 and 2.

rate = param.Number(allow_refs=False, bounds=(0.1, 10.0), default=1.0, inclusive_bounds=(True, True), label=’Rate’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x319aea950>)

The speed at which the utterance will be spoken at expressed as a number between 0.1 and 10.

voice = param.ObjectSelector(allow_refs=False, label=’Voice’, names={}, nested_refs=False, objects=[], rx=<param.reactive.reactive_ops object at 0x319a3dd90>)

The voice that will be used to speak the utterance.

volume = param.Number(allow_refs=False, bounds=(0.0, 1.0), default=1.0, inclusive_bounds=(True, True), label=’Volume’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x319aeb8d0>)

The volume that the utterance will be spoken at expressed as a number between 0 and 1.

set_voices(voices)[source]#

Updates the lang and voice parameter objects, default and value

to_dict(include_uuid=True)[source]#

Returns the object parameter values in a dictionary

Returns:

[description]

Return type:

Dict

class panel.widgets.text_to_speech.Voice(*, default, lang, local_service, voice_uri, name)[source]#

Bases: Parameterized

The current device (i.e. OS and Browser) provides a list of Voices. Each with a unique name and speaking a specific language.

Wraps the HTML5 SpeecSynthesisVoice API

See https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesisVoice

default = param.Boolean(allow_refs=False, constant=True, default=False, label=’Default’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x319a65810>)

A Boolean indicating whether the voice is the default voice for the current app language (True), or not (False.)

lang = param.String(allow_refs=False, constant=True, default=’’, label=’Lang’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x319aeadd0>)

Returns a BCP 47 language tag indicating the language of the voice.

local_service = param.Boolean(allow_refs=False, constant=True, default=False, label=’Local service’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x319aebcd0>)

A Boolean indicating whether the voice is supplied by a local speech synthesizer service (True), or a remote speech synthesizer service (False.)

voice_uri = param.String(allow_refs=False, constant=True, default=’’, label=’Voice uri’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x319aeb090>)

Returns the type of URI and location of the speech synthesis service for this voice.

static group_by_lang(voices)[source]#

Returns a dictionary where the key is the lang and the value is a list of voices for that language.

static to_voices_list(voices)[source]#

Returns a list of Voice objects from the list of dicts provided


texteditor Module#

Inheritance diagram of panel.widgets.texteditor

Defines a WYSIWYG TextEditor widget based on quill.js.

class panel.widgets.texteditor.TextEditor(*, mode, placeholder, toolbar, value, disabled, 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: Widget

The TextEditor widget provides a WYSIWYG (what-you-see-is-what-you-get) rich text editor which outputs HTML.

The editor is built on top of the [Quill.js](https://quilljs.com/) library.

Reference: https://panel.holoviz.org/reference/widgets/TextEditor.html

Example:

>>> TextEditor(placeholder='Enter some text')

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, visible

panel.viewable.Viewable: loading

panel.widgets.base.Widget: height, margin, width

disabled = param.Boolean(allow_refs=False, default=False, label=’Disabled’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x319d70510>)

Whether the editor is disabled.

mode = param.Selector(allow_refs=False, default=’toolbar’, label=’Mode’, names={}, nested_refs=False, objects=[‘bubble’, ‘toolbar’], rx=<param.reactive.reactive_ops object at 0x319d73450>)

Whether to display a toolbar or a bubble menu on highlight.

toolbar = param.ClassSelector(allow_refs=False, class_=(<class ‘list’>, <class ‘bool’>), default=True, label=’Toolbar’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x319d73ad0>)

Toolbar configuration either as a boolean toggle or a configuration specified as a list.

placeholder = param.String(allow_refs=False, default=’’, label=’Placeholder’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x319d71a10>)

Placeholder output when the editor is empty.

value = param.String(allow_refs=False, default=’’, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x319d70a90>)

State of the current text in the editor

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

classmethod from_param(parameter: param.Parameter, **params) T[source]#

Construct a widget from a Parameter and link the two bi-directionally.

Parameters:

parameter (param.Parameter) – A parameter to create the widget from.

Return type:

Widget instance linked to the supplied parameter

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:

Callback

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

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


widget Module#

Inheritance diagram of panel.widgets.widget
class panel.widgets.widget.fixed(value: Any, **kwargs: Any)[source]#

Bases: Parameterized

A pseudo-widget whose value is fixed and never synced to the client.

description = param.String(allow_refs=False, default=’’, label=’Description’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x319fa5c90>)

value = param.Parameter(allow_None=True, allow_refs=False, label=’Value’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x319fa6690>)

Any Python object

get_interact_value()[source]#

Return the value for this widget which should be passed to interactive functions. Custom widgets can change this method to process the raw value self.value.

class panel.widgets.widget.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:

Widget

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.

static widget_from_single_value(o, name)[source]#

Make widgets from single values, which can be used as parameter defaults.

static widget_from_tuple(o, name, default)[source]#

Make widgets from a tuple abbreviation.