panel.pane Package#


pane Package#

Panel panes renders the Python objects you know and love ❤️#

Panes may render anything including plots, text, images, equations etc.

For example Panel contains Bokeh, HoloViews, Matplotlib and Plotly panes.

Check out the Panel gallery of panes https://panel.holoviz.org/reference/index.html#panes for inspiration.

How to use Panel panes in 2 simple steps#

  1. Define your Python objects

>>> some_python_object = ...
>>> another_python_object = ...
  1. Define your panes

>>> pn.pane.SomePane(some_python_object).servable()
>>> pn.pane.AnotherPane(another_python_object).servable()

Most often you don’t have to wrap your Python object into a specific pane. Just add your Python object to pn.panel, pn.Column, pn.Row or other layouts, then Panel will automatically wrap it in the right pane.

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

class panel.pane.Alert(object=None, **params)[source]#

Bases: Markdown

The Alert pane allows providing contextual feedback messages for typical user actions. The Alert supports markdown strings.

Reference: https://panel.holoviz.org/reference/panes/Alert.html

Example:

>>> Alert('Some important message', alert_type='warning')

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

panel.pane.markup.Markdown: dedent, disable_math, extensions, plugins, renderer, renderer_options

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

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.Audio(object=None, **params)[source]#

Bases: _MediaBase

The Audio pane displays an audio player given a local or remote audio file, a NumPy Array or Torch Tensor.

The pane also allows access and control over the player state including toggling of playing/paused and loop state, the current time, and the volume.

The audio player supports ogg, mp3, and wav files

If SciPy is installed, 1-dim Numpy Arrays and 1-dim Torch Tensors are also supported. The dtype must be one of the following

  • numpy: np.int16, np.uint16, np.float32, np.float64

  • torch: torch.short, torch.int16, torch.half, torch.float16, torch.float, torch.float32,

torch.double, torch.float64

The array or Tensor input will be downsampled to 16bit and converted to a wav file by SciPy.

Reference: https://panel.holoviz.org/reference/panes/Audio.html

Example:

>>> Audio('http://ccrma.stanford.edu/~jos/mp3/pno-cs.mp3', name='Audio')

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout

panel.pane.media._MediaBase: loop, time, throttle, paused, volume, autoplay, muted

object = param.ClassSelector(allow_None=True, allow_refs=True, class_=(<class ‘str’>, <class ‘numpy.ndarray’>, <class ‘panel.pane.media.TensorLike’>), default=’’, label=’Object’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1591798d0>)

The audio file either local or remote, a 1-dim NumPy ndarray or a 1-dim Torch Tensor.

sample_rate = param.Integer(allow_refs=False, default=44100, inclusive_bounds=(True, True), label=’Sample rate’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1587970d0>)

The sample_rate of the audio when given a NumPy array or Torch tensor.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.Bokeh(object=None, **params)[source]#

Bases: Pane

The Bokeh pane allows displaying any displayable Bokeh model inside a Panel app.

Reference: https://panel.holoviz.org/reference/panes/Bokeh.html

Example:

>>> Bokeh(some_bokeh_figure)

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

autodispatch = param.Boolean(allow_refs=False, default=True, label=’Autodispatch’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1591e1850>)

Whether to automatically dispatch events inside bokeh on_change and on_event callbacks in the notebook.

theme = param.ClassSelector(allow_None=True, allow_refs=False, class_=(<class ‘bokeh.themes.theme.Theme’>, <class ‘str’>), label=’Theme’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x159053910>)

Bokeh theme to apply to the plot.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.DataFrame(object=None, **params)[source]#

Bases: HTML

The DataFrame pane renders pandas, dask and streamz DataFrame types using their custom HTML repr.

In the case of a streamz DataFrame the rendered data will update periodically.

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

Example:

>>> DataFrame(df, index=False, max_rows=25, width=400)

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

panel.pane.markup.HTML: disable_math, sanitize_html, sanitize_hook

bold_rows = param.Boolean(allow_refs=False, default=True, label=’Bold rows’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1592c0550>)

Make the row labels bold in the output.

border = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Border’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1592c1ad0>)

A border=border attribute is included in the opening <table> tag.

classes = param.List(allow_refs=False, bounds=(0, None), default=[‘panel-df’], label=’Classes’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x158851a90>)

CSS class(es) to apply to the resulting html table.

col_space = param.ClassSelector(allow_None=True, allow_refs=False, class_=(<class ‘str’>, <class ‘int’>, <class ‘dict’>), label=’Col space’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1592c3890>)

The minimum width of each column in CSS length units. An int is assumed to be px units.

decimal = param.String(allow_refs=False, default=’.’, label=’Decimal’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x158990350>)

Character recognized as decimal separator, e.g. ‘,’ in Europe.

escape = param.Boolean(allow_refs=False, default=True, label=’Escape’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1592c3190>)

Whether or not to escape the dataframe HTML. For security reasons the default value is True.

float_format = param.Callable(allow_None=True, allow_refs=False, label=’Float format’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15911a9d0>)

Formatter function to apply to columns’ elements if they are floats. The result of this function must be a unicode string.

formatters = param.ClassSelector(allow_None=True, allow_refs=False, class_=(<class ‘dict’>, <class ‘list’>), label=’Formatters’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1592c2510>)

Formatter functions to apply to columns’ elements by position or name. The result of each function must be a unicode string.

header = param.Boolean(allow_refs=False, default=True, label=’Header’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x151ba8910>)

Whether to print column labels.

index = param.Boolean(allow_refs=False, default=True, label=’Index’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1592c3050>)

Whether to print index (row) labels.

index_names = param.Boolean(allow_refs=False, default=True, label=’Index names’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x151ba8910>)

Prints the names of the indexes.

justify = param.ObjectSelector(allow_None=True, allow_refs=False, label=’Justify’, names={}, nested_refs=False, objects=[‘left’, ‘right’, ‘center’, ‘justify’, ‘justify-all’, ‘start’, ‘end’, ‘inherit’, ‘match-parent’, ‘initial’, ‘unset’], rx=<param.reactive.reactive_ops object at 0x1592c3b90>)

How to justify the column labels.

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 0x1592c3190>)

Maximum number of rows to display.

max_cols = param.Integer(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Max cols’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1592c1990>)

Maximum number of columns to display.

na_rep = param.String(allow_refs=False, default=’NaN’, label=’Na rep’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x158694ad0>)

String representation of NAN to use.

render_links = param.Boolean(allow_refs=False, default=False, label=’Render links’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1592c2510>)

Convert URLs to HTML links.

show_dimensions = param.Boolean(allow_refs=False, default=False, label=’Show dimensions’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x151ba8910>)

Display DataFrame dimensions (number of rows by number of columns).

sparsify = param.Boolean(allow_refs=False, default=True, label=’Sparsify’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1592c2e50>)

Set to False for a DataFrame with a hierarchical index to print every multi-index key at each row.

text_align = param.Selector(allow_refs=False, label=’Text align’, names={}, nested_refs=False, objects=[‘start’, ‘end’, ‘center’], rx=<param.reactive.reactive_ops object at 0x158a38bd0>)

Alignment of non-header cells.

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

Hidden parameter.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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.

priority: ClassVar[float | bool | None] = None#
save(filename: str | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.DeckGL(object=None, **params)[source]#

Bases: ModelPane

The DeckGL pane renders the Deck.gl JSON specification as well as PyDeck plots inside a panel.

Deck.gl is a very powerful WebGL-powered framework for visual exploratory data analysis of large datasets.

Reference: https://panel.holoviz.org/reference/panes/DeckGL.html

Example:

>>> pn.extension('deckgl')
>>> DeckGL(
...    some_deckgl_dict_or_pydeck_object,
...    mapbox_api_key=MAPBOX_KEY, height=600
... )

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

mapbox_api_key = param.String(allow_None=True, allow_refs=False, label=’Mapbox api key’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15907dc90>)

The MapBox API key if not supplied by a PyDeck object.

tooltips = param.ClassSelector(allow_refs=False, class_=(<class ‘bool’>, <class ‘dict’>), default=True, label=’Tooltips’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15908d5d0>)

Whether to enable tooltips

configuration = param.String(allow_refs=False, default=’’, label=’Configuration’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15907e310>)

Custom configuration dictionary as json string

click_state = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Click state’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x158958190>)

Contains the last click event on the DeckGL plot.

hover_state = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Hover state’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15907df10>)

The current hover state of the DeckGL plot.

view_state = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={}, label=’View state’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15908e690>)

The current view state of the DeckGL plot.

throttle = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={‘view’: 200, ‘hover’: 200}, label=’Throttle’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15907df10>)

Throttling timeout (in milliseconds) for view state and hover events sent from the frontend.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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.

priority: ClassVar[float | bool | None] = None#
save(filename: str | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.ECharts(object=None, **params)[source]#

Bases: ModelPane

ECharts panes allow rendering echarts.js dictionaries and pyecharts plots.

Reference: https://panel.holoviz.org/reference/panes/ECharts.html

Example:

>>> pn.extension('echarts')
>>> ECharts(some_echart_dict_or_pyecharts_object, height=480, width=640)

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout

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

The Echarts object being wrapped. Can be an Echarts dictionary or a pyecharts chart

options = param.Parameter(allow_None=True, allow_refs=False, label=’Options’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15935f390>)

An optional dict of options passed to Echarts.setOption. Allows to fine-tune the rendering behavior. For example, you might want to use options={ “replaceMerge”: [‘series’] }) when updating the objects with a value containing a smaller number of series.

renderer = param.ObjectSelector(allow_refs=False, default=’canvas’, label=’Renderer’, names={}, nested_refs=False, objects=[‘canvas’, ‘svg’], rx=<param.reactive.reactive_ops object at 0x15935d6d0>)

Whether to render as HTML canvas or SVG

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

Theme to apply to plots.

classmethod applies(obj: Any, **params) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

Returns the bokeh model corresponding to this panel object

js_on_event(event: str, callback: str | CustomJS, query: str | None = None, **args)[source]#

Register a Javascript event handler which triggers when the specified event is triggered. The callback can be a snippet of Javascript code or a bokeh CustomJS object making it possible to manipulate other models in response to an event.

Reference: https://apache.github.io/echarts-handbook/en/concepts/event/

Arguments#

event: str

The name of the event to register a handler on, e.g. ‘click’.

code: str

The event handler to be executed when the event fires.

query: str | None

A query that determines when the event fires.

args: Viewable

A dictionary of Viewables to make available in the namespace of the 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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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(event: str, callback: Callable, query: str | None = None)[source]#

Register anevent handler which triggers when the specified event is triggered.

Reference: https://apache.github.io/echarts-handbook/en/concepts/event/

Arguments#

event: str

The name of the event to register a handler on, e.g. ‘click’.

callback: str | CustomJS

The event handler to be executed when the event fires.

query: str | None

A query that determines when the event fires.

priority: ClassVar[float | bool | None] = None#
save(filename: str | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.GIF(object=None, **params)[source]#

Bases: ImageBase

The GIF pane embeds a .gif image file in a panel if provided a local path, or will link to a remote image if provided a URL.

Reference: https://panel.holoviz.org/reference/panes/GIF.html

Example:

>>> GIF(
...     'https://upload.wikimedia.org/wikipedia/commons/b/b1/Loading_icon.gif',
...     alt_text='A loading spinner',
...     link_url='https://commons.wikimedia.org/wiki/File:Loading_icon.gif',
...     width=500
... )

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

panel.pane.image.FileBase: embed

panel.pane.image.ImageBase: alt_text, caption, fixed_aspect, link_url

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.HTML(object=None, **params)[source]#

Bases: HTMLBasePane

HTML panes renders HTML strings and objects with a _repr_html_ method.

The height and width can optionally be specified, to allow room for whatever is being wrapped.

Reference: https://panel.holoviz.org/reference/panes/HTML.html

Example:

>>> HTML(
...     "<h1>This is a HTML pane</h1>",
...     styles={'background-color': '#F6F6F6'}
... )

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

disable_math = param.Boolean(allow_refs=False, default=True, label=’Disable math’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1593fdad0>)

Whether to disable support for MathJax math rendering for strings escaped with $$ delimiters.

sanitize_html = param.Boolean(allow_refs=False, default=False, label=’Sanitize html’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15915b250>)

Whether to sanitize HTML sent to the frontend.

sanitize_hook = param.Callable(allow_refs=False, label=’Sanitize hook’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15632c050>)

Sanitization callback to apply if sanitize_html=True.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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.

priority: ClassVar[float | bool | None] = None#
save(filename: str | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.HoloViews(object=None, **params)[source]#

Bases: Pane

HoloViews panes render any HoloViews object using the currently selected backend (‘bokeh’ (default), ‘matplotlib’ or ‘plotly’).

To be able to use the plotly backend you must add plotly to pn.extension.

Reference: https://panel.holoviz.org/reference/panes/HoloViews.html

Example:

>>> HoloViews(some_holoviews_object)

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

backend = param.ObjectSelector(allow_refs=False, label=’Backend’, names={}, nested_refs=False, objects=[‘bokeh’, ‘matplotlib’, ‘plotly’], rx=<param.reactive.reactive_ops object at 0x159162ed0>)

The HoloViews backend used to render the plot (if None defaults to the currently selected renderer).

center = param.Boolean(allow_refs=False, default=False, label=’Center’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15940c290>)

Whether to center the plot.

format = param.Selector(allow_refs=False, default=’png’, label=’Format’, names={}, nested_refs=False, objects=[‘png’, ‘svg’], rx=<param.reactive.reactive_ops object at 0x159162ed0>)

The format to render Matplotlib plots with.

linked_axes = param.Boolean(allow_refs=False, default=True, label=’Linked axes’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x159404f90>)

Whether to link the axes of bokeh plots inside this pane across a panel layout.

renderer = param.Parameter(allow_None=True, allow_refs=False, label=’Renderer’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x153c13890>)

Explicit renderer instance to use for rendering the HoloViews plot. Overrides the backend.

theme = param.ClassSelector(allow_None=True, allow_refs=False, class_=(<class ‘bokeh.themes.theme.Theme’>, <class ‘str’>), label=’Theme’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1594059d0>)

Bokeh theme to apply to the HoloViews plot.

widget_location = param.ObjectSelector(allow_refs=False, default=’right_top’, label=’Widget location’, names={}, nested_refs=False, objects=[‘left’, ‘bottom’, ‘right’, ‘top’, ‘top_left’, ‘top_right’, ‘bottom_left’, ‘bottom_right’, ‘left_top’, ‘left_bottom’, ‘right_top’, ‘right_bottom’], rx=<param.reactive.reactive_ops object at 0x159405c10>)

The layout of the plot and the widgets. The value refers to the position of the widgets relative to the plot.

widget_layout = param.ObjectSelector(allow_refs=False, constant=True, default=<class ‘panel.layout.base.WidgetBox’>, label=’Widget layout’, names={}, nested_refs=False, objects=[<class ‘panel.layout.base.WidgetBox’>, <class ‘panel.layout.base.Row’>, <class ‘panel.layout.base.Column’>], rx=<param.reactive.reactive_ops object at 0x1594059d0>)

The layout object to display the widgets in.

widget_type = param.ObjectSelector(allow_refs=False, default=’individual’, label=’Widget type’, names={}, nested_refs=False, objects=[‘individual’, ‘scrubber’], rx=<param.reactive.reactive_ops object at 0x159405c10>)

) Whether to generate individual widgets for each dimension or on global scrubber.

widgets = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Widgets’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x159404c90>)

A mapping from dimension name to a widget instance which will be used to override the default widgets.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

widget_layout[source]#

alias of WidgetBox

class panel.pane.ICO(object=None, **params)[source]#

Bases: ImageBase

The ICO pane embeds an .ico image file in a panel if provided a local path, or will link to a remote image if provided a URL.

Reference: https://panel.holoviz.org/reference/panes/ICO.html

Example:

>>> ICO(
...     some_url,
...     alt_text='An .ico file',
...     link_url='https://en.wikipedia.org/wiki/ICO_(file_format)',
...     width=50
...

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

panel.pane.image.FileBase: embed

panel.pane.image.ImageBase: alt_text, caption, fixed_aspect, link_url

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.IPyLeaflet(object=None, **params)[source]#

Bases: IPyWidget

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout

panel.pane.ipywidget.IPyWidget: object

sizing_mode = param.ObjectSelector(allow_refs=False, default=’stretch_width’, 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 0x159186350>)

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.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.IPyWidget(object=None, **params)[source]#

Bases: Pane

The IPyWidget pane renders any ipywidgets model both in the notebook and in a deployed server.

When rendering ipywidgets on the server you must add ipywidgets to pn.extension. You must not do this in Jupyterlab as this may render Jupyterlab unusable.

Reference: https://panel.holoviz.org/reference/panes/IPyWidget.html

Example:

>>> IPyWidget(some_ipywidget)

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout

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

The IPywidget being wrapped, which will be converted to a Bokeh model.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.Interactive(object=None, **params)[source]#

Bases: Pane

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout

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

The object being wrapped, which will be converted to a Bokeh model.

classmethod applies(object: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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.

priority: ClassVar[float | bool | None] = None#
save(filename: str | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.JPG(object=None, **params)[source]#

Bases: ImageBase

The JPG pane embeds a .jpg or .jpeg image file in a panel if provided a local path, or will link to a remote image if provided a URL.

Reference: https://panel.holoviz.org/reference/panes/JPG.html

Example:

>>> JPG(
...     'https://www.gstatic.com/webp/gallery/4.sm.jpg',
...     alt_text='A nice tree',
...     link_url='https://en.wikipedia.org/wiki/JPEG',
...     width=500
... )

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

panel.pane.image.FileBase: embed

panel.pane.image.ImageBase: alt_text, caption, fixed_aspect, link_url

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.JSON(object=None, **params)[source]#

Bases: HTMLBasePane

The JSON pane allows rendering arbitrary JSON strings, dicts and other json serializable objects in a panel.

Reference: https://panel.holoviz.org/reference/panes/JSON.html

Example:

>>> JSON(json_obj, theme='light', height=300, width=500)

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

depth = param.Integer(allow_refs=False, bounds=(-1, None), default=1, inclusive_bounds=(True, True), label=’Depth’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x159173710>)

Depth to which the JSON tree will be expanded on initialization.

encoder = param.ClassSelector(allow_None=True, allow_refs=False, class_=<class ‘json.encoder.JSONEncoder’>, label=’Encoder’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x159048f10>)

Custom JSONEncoder class used to serialize objects to JSON string.

hover_preview = param.Boolean(allow_refs=False, default=False, label=’Hover preview’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x159171190>)

Whether to display a hover preview for collapsed nodes.

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

Whether the JSON tree view is expanded by default.

classmethod applies(obj: Any, **params) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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.

priority: ClassVar[float | bool | None] = None#
save(filename: str | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.LaTeX(object=None, **params)[source]#

Bases: ModelPane

The LaTeX pane allows rendering LaTeX equations. It uses either KaTeX or MathJax depending on the defined renderer.

By default it will use the renderer loaded in the extension (e.g. pn.extension(‘katex’)), defaulting to KaTeX if both are loaded.

Reference: https://panel.holoviz.org/reference/panes/LaTeX.html

Example:

>>> pn.extension('katex')
>>> LaTeX(
...     'The LaTeX pane supports two delimiters: $LaTeX$ and \(LaTeX\)',
...     styles={'font-size': '18pt'}, width=800
... )

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

renderer = param.ObjectSelector(allow_None=True, allow_refs=False, label=’Renderer’, names={}, nested_refs=False, objects=[‘katex’, ‘mathjax’], rx=<param.reactive.reactive_ops object at 0x158c31950>)

The JS renderer used to render the LaTeX expression. Defaults to katex.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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.

priority: ClassVar[float | bool | None] = None#
save(filename: str | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.Markdown(object=None, **params)[source]#

Bases: HTMLBasePane

The Markdown pane allows rendering arbitrary markdown strings in a panel.

It renders strings containing valid Markdown as well as objects with a _repr_markdown_ method, and may define custom CSS styles.

Reference: https://panel.holoviz.org/reference/panes/Markdown.html

Example:

>>> Markdown("# This is a header")

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

dedent = param.Boolean(allow_refs=False, default=True, label=’Dedent’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x158c714d0>)

Whether to dedent common whitespace across all lines.

disable_math = param.Boolean(allow_refs=False, default=False, label=’Disable math’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x159455c50>)

Whether to disable support for MathJax math rendering for strings escaped with $$ delimiters.

extensions = param.List(allow_refs=False, bounds=(0, None), default=[‘extra’, ‘smarty’, ‘codehilite’], label=’Extensions’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x158c70b90>)

Markdown extension to apply when transforming markup. Does not apply if renderer is set to ‘markdown-it’ or ‘myst’.

plugins = param.List(allow_refs=False, bounds=(0, None), default=[], label=’Plugins’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x159457950>)

Additional markdown-it-py plugins to use.

renderer = param.Selector(allow_refs=False, default=’markdown-it’, label=’Renderer’, names={}, nested_refs=False, objects=[‘markdown-it’, ‘myst’, ‘markdown’], rx=<param.reactive.reactive_ops object at 0x158c73e10>)

Markdown renderer implementation.

renderer_options = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Renderer options’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x159457010>)

Options to pass to the markdown renderer.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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.

priority: ClassVar[float | bool | None] = None#
save(filename: str | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.Matplotlib(object=None, **params)[source]#

Bases: Image, IPyWidget

The Matplotlib pane allows displaying any displayable Matplotlib figure inside a Panel app.

  • It will render the plot to PNG at the declared DPI and then embed it.

  • If you find the figure to be clipped on the edges, you can set tight=True

to automatically resize objects to fit within the pane. - If you have installed ipympl you will also be able to use the interactive backend.

Reference: https://panel.holoviz.org/reference/panes/Matplotlib.html

Example:

>>> Matplotlib(some_matplotlib_figure, dpi=144)

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout

panel.pane.markup.HTMLBasePane: enable_streaming

panel.pane.image.FileBase: embed

panel.pane.image.ImageBase: alt_text, caption, fixed_aspect, link_url

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

The Matplotlib Figure being wrapped, which will be rendered as a Bokeh model.

dpi = param.Integer(allow_refs=False, bounds=(1, None), default=144, inclusive_bounds=(True, True), label=’Dpi’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15944ed50>)

Scales the dpi of the matplotlib figure.

encode = param.Boolean(allow_refs=False, default=False, label=’Encode’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1594c0310>)

Whether to encode SVG out as base64.

format = param.Selector(allow_refs=False, default=’png’, label=’Format’, names={}, nested_refs=False, objects=[‘png’, ‘svg’], rx=<param.reactive.reactive_ops object at 0x1594c2d50>)

The format to render the plot as if the plot is not interactive.

high_dpi = param.Boolean(allow_refs=False, default=True, label=’High dpi’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1594c0310>)

Whether to optimize output for high-dpi displays.

interactive = param.Boolean(allow_refs=False, constant=True, default=False, label=’Interactive’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15944f910>)

Whether to render interactive matplotlib plot with ipympl.

tight = param.Boolean(allow_refs=False, default=False, label=’Tight’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1594c1fd0>)

Automatically adjust the figure size to fit the subplots and other artist elements.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.PDF(object=None, **params)[source]#

Bases: FileBase

The PDF pane embeds a .pdf image file in a panel if provided a local path, or will link to a remote image if provided a URL.

Reference: https://panel.holoviz.org/reference/panes/PDF.html

Example:

>>> PDF(
...     'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf',
...     width=300, height=410
... )

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

panel.pane.image.FileBase: embed

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

Start page of the pdf, by default the first page.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.PNG(object=None, **params)[source]#

Bases: ImageBase

The PNG pane embeds a .png image file in a panel if provided a local path, or will link to a remote image if provided a URL.

Reference: https://panel.holoviz.org/reference/panes/PNG.html

Example:

>>> PNG(
...     'https://panel.holoviz.org/_static/logo_horizontal.png',
...     alt_text='The Panel Logo',
...     link_url='https://panel.holoviz.org/index.html',
...     width=500
... )

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

panel.pane.image.FileBase: embed

panel.pane.image.ImageBase: alt_text, caption, fixed_aspect, link_url

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.Pane(object=None, **params)[source]#

Bases: PaneBase, Reactive

Pane is the abstract baseclass for all atomic displayable units in the Panel library.

Panes defines an extensible interface for wrapping arbitrary objects and transforming them into renderable components.

Panes are reactive in the sense that when the object they are wrapping is replaced or modified the UI will reflect the updated object.

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.PaneBase(object=None, **params)[source]#

Bases: Layoutable

PaneBase represents an abstract baseclass which can be used as a mix-in class to define a component that mirrors the Pane API. This means that this component will participate in the automatic resolution of the appropriate pane type when Panel is asked to render an object of unknown type.

The resolution of the appropriate pane type can be implemented using the applies method and the priority class attribute. The applies method should either return a boolean value indicating whether the pane can render the supplied object. If it can the priority determines which of the panes that apply will be selected. If the priority is None then the applies method must return a priority value.

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

margin = param.Margin(allow_None=True, allow_refs=False, default=(5, 10), label=’Margin’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x158d8e110>)

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

default_layout = param.ClassSelector(allow_refs=False, class_=<class ‘panel.layout.base.Panel’>, default=<class ‘panel.layout.base.Row’>, label=’Default layout’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x158cf3810>)

Defines the layout the model(s) returned by the pane will be placed in.

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

The object being wrapped, which will be converted to a Bokeh model.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

default_layout[source]#

alias of Row

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

class panel.pane.ParamFunction(object=None, **params)[source]#

Bases: ParamRef

ParamFunction panes wrap functions decorated with the param.depends decorator and rerenders the output when any of the function’s dependencies change. This allows building reactive components into a Panel which depend on other parameters, e.g. tying the value of a widget to some other output.

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout

panel.pane.base.ReplacementPane: object, inplace, _pane

panel.param.ParamRef: defer_load, generator_mode, lazy, loading_indicator

classmethod applies(obj: Any, **kwargs) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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 | None = None) list[Viewable][source]#

Iterates over the Viewable and any potential children in the applying the Selector.

Arguments#

selector: (type | callable | None)

The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.

Returns#

viewables: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.ParamMethod(object=None, **params)[source]#

Bases: ParamRef

ParamMethod panes wrap methods on parameterized classes and rerenders the plot when any of the method’s parameters change. By default ParamMethod will watch all parameters on the class owning the method or can be restricted to certain parameters by annotating the method using the param.depends decorator. The method may return any object which itself can be rendered as a Pane.

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout

panel.pane.base.ReplacementPane: object, inplace, _pane

panel.param.ParamRef: defer_load, generator_mode, lazy, loading_indicator

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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 | None = None) list[Viewable][source]#

Iterates over the Viewable and any potential children in the applying the Selector.

Arguments#

selector: (type | callable | None)

The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.

Returns#

viewables: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.ParamRef(object=None, **params)[source]#

Bases: ReplacementPane

ParamRef wraps any valid parameter reference and resolves it dynamically, re-rendering the output. If enabled it will attempt to update the previously rendered component inplace.

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout

panel.pane.base.ReplacementPane: object, inplace, _pane

defer_load = param.Boolean(allow_None=True, allow_refs=False, label=’Defer load’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x158de8190>)

Whether to defer load until after the page is rendered. Can be set as parameter or by setting panel.config.defer_load.

generator_mode = param.Selector(allow_refs=False, default=’replace’, label=’Generator mode’, names={}, nested_refs=False, objects=[‘append’, ‘replace’], rx=<param.reactive.reactive_ops object at 0x158df2610>)

Whether generators should ‘append’ to or ‘replace’ existing output.

lazy = param.Boolean(allow_refs=False, default=False, label=’Lazy’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x158de8a10>)

Whether to lazily evaluate the contents of the object only when it is required for rendering.

loading_indicator = param.Boolean(allow_refs=False, default=False, label=’Loading indicator’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x159259690>)

Whether to show a loading indicator while the pane is updating. Can be set as parameter or by setting panel.config.loading_indicator.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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 | None = None) list[Viewable][source]#

Iterates over the Viewable and any potential children in the applying the Selector.

Arguments#

selector: (type | callable | None)

The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.

Returns#

viewables: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.Perspective(object=None, **params)[source]#

Bases: ModelPane, ReactiveData

The Perspective pane provides an interactive visualization component for large, real-time datasets built on the Perspective project.

Reference: https://panel.holoviz.org/reference/panes/Perspective.html

Example:

>>> Perspective(df, plugin='hypergrid', theme='pro-dark')

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.reactive.SyncableData: selection

panel.pane.base.PaneBase: margin, default_layout

min_width = param.Integer(allow_refs=False, bounds=(0, None), default=420, inclusive_bounds=(True, True), label=’Min width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x158e30fd0>)

Minimal width of the component (in pixels) if width is adjustable.

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

The plot data declared as a dictionary of arrays or a DataFrame.

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

How to aggregate. For example {“x”: “distinct count”}

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

A list of source columns to show as columns. For example [“x”, “y”]

columns_config = param.Dict(allow_None=True, allow_refs=False, class_=<class ‘dict’>, label=’Columns config’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x158e307d0>)

Column configuration allowing specification of formatters, coloring and a variety of other attributes for each column.

editable = param.Boolean(allow_None=True, allow_refs=False, default=True, label=’Editable’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x158e40310>)

Whether items are editable.

expressions = param.ClassSelector(allow_None=True, allow_refs=False, class_=(<class ‘dict’>, <class ‘list’>), label=’Expressions’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x158e31250>)

A list of expressions computing new columns from existing columns. For example [“”x”+”index””]

split_by = param.List(allow_None=True, allow_refs=False, bounds=(0, None), label=’Split by’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x158e40310>)

A list of source columns to pivot by. For example [“x”, “y”]

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

How to filter. For example [[“x”, “<”, 3],[“y”, “contains”, “abc”]]

group_by = param.List(allow_None=True, allow_refs=False, bounds=(0, None), label=’Group by’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x158e409d0>)

A list of source columns to group by. For example [“x”, “y”]

selectable = param.Boolean(allow_None=True, allow_refs=False, default=True, label=’Selectable’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x158e32110>)

Whether items are selectable.

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

How to sort. For example[[“x”,”desc”]]

plugin = param.ObjectSelector(allow_refs=False, default=’datagrid’, label=’Plugin’, names={}, nested_refs=False, objects=[‘hypergrid’, ‘datagrid’, ‘d3_y_bar’, ‘d3_x_bar’, ‘d3_xy_line’, ‘d3_y_line’, ‘d3_y_area’, ‘d3_y_scatter’, ‘d3_xy_scatter’, ‘d3_treemap’, ‘d3_sunburst’, ‘d3_heatmap’, ‘d3_candlestick’, ‘d3_ohlc’], rx=<param.reactive.reactive_ops object at 0x158e32190>)

The name of a plugin to display the data. For example hypergrid or d3_xy_scatter.

plugin_config = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Plugin config’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x158e40310>)

Configuration for the PerspectiveViewerPlugin.

settings = param.Boolean(allow_refs=False, default=True, label=’Settings’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x158e33250>)

Whether to show the settings menu.

theme = param.ObjectSelector(allow_refs=False, default=’pro’, label=’Theme’, names={}, nested_refs=False, objects=[‘material’, ‘material-dark’, ‘monokai’, ‘solarized’, ‘solarized-dark’, ‘vaporwave’, ‘pro’, ‘pro-dark’], rx=<param.reactive.reactive_ops object at 0x158e409d0>)

The style of the PerspectiveViewer. For example pro-dark

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

Title for the Perspective viewer.

classmethod applies(object)[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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

Register a callback to be executed when any row is clicked. The callback is given a PerspectiveClickEvent declaring the config, column names, and row values of the row that was clicked.

Arguments#

callback: (callable)

The callback to run on edit events.

patch(patch_value: 'pd.DataFrame' | 'pd.Series' | dict) None[source]#

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

Arguments#

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’]}

priority: ClassVar[float | bool | None] = None#
save(filename: str | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

stream(stream_value: 'pd.DataFrame' | 'pd.Series' | dict, rollover: int | None = None, reset_index: bool = True) None[source]#

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

Arguments#

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.

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”]}) >>> 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.pane.Placeholder(object=None, **params)[source]#

Bases: ReplacementPane

The Placeholder pane serves as a placeholder for other Panel components. It can be used to display a message while a computation is running, for example.

Reference: https://panel.holoviz.org/reference/panes/Placeholder.html

Example:

>>> with Placeholder("⏳ Idle"):
...     placeholder.object = "🏃 Running..."

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout

panel.pane.base.ReplacementPane: object, inplace, _pane

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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 | None = None) list[Viewable][source]#

Iterates over the Viewable and any potential children in the applying the Selector.

Arguments#

selector: (type | callable | None)

The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.

Returns#

viewables: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

update(object)[source]#

Updates the object on the Placeholder.

Arguments#

object: The object to update the Placeholder with.

class panel.pane.Plotly(object=None, **params)[source]#

Bases: ModelPane

The Plotly pane renders Plotly plots inside a panel.

Note that

  • the Panel extension has to be loaded with plotly as an argument to

ensure that Plotly.js is initialized. - it supports click, hover and selection events. - it optimizes the plot rendering by using binary serialization for any array data found on the Plotly object.

Reference: https://panel.holoviz.org/reference/panes/Plotly.html

Example:

>>> pn.extension('plotly')
>>> Plotly(some_plotly_figure, width=500, height=500)

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

click_data = param.Dict(allow_None=True, allow_refs=False, class_=<class ‘dict’>, label=’Click data’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x158e1c850>)

Click event data from plotly_click event.

clickannotation_data = param.Dict(allow_None=True, allow_refs=False, class_=<class ‘dict’>, label=’Clickannotation data’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x158e20350>)

Clickannotation event data from plotly_clickannotation event.

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

Plotly configuration options. See https://plotly.com/javascript/configuration-options/

hover_data = param.Dict(allow_None=True, allow_refs=False, class_=<class ‘dict’>, label=’Hover data’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x158e20350>)

Hover event data from plotly_hover and plotly_unhover events.

link_figure = param.Boolean(allow_refs=False, default=True, label=’Link figure’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x158e1ef50>)

Attach callbacks to the Plotly figure to update output when it is modified in place.

relayout_data = param.Dict(allow_None=True, allow_refs=False, class_=<class ‘dict’>, label=’Relayout data’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x158e22c10>)

Relayout event data from plotly_relayout event

restyle_data = param.List(allow_refs=False, bounds=(0, None), default=[], label=’Restyle data’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x158e1c850>)

Restyle event data from plotly_restyle event

selected_data = param.Dict(allow_None=True, allow_refs=False, class_=<class ‘dict’>, label=’Selected data’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x158e22f90>)

Selected event data from plotly_selected and plotly_deselect events.

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

Current viewport state, i.e. the x- and y-axis limits of the displayed plot. Updated on plotly_relayout, plotly_relayouting and plotly_restyle events.

viewport_update_policy = param.Selector(allow_refs=False, default=’mouseup’, label=’Viewport update policy’, names={}, nested_refs=False, objects=[‘mouseup’, ‘continuous’, ‘throttle’], rx=<param.reactive.reactive_ops object at 0x158e23d50>)

Policy by which the viewport parameter is updated during user interactions. * “mouseup”: updates are synchronized when mouse button is released after panning * “continuous”: updates are synchronized continually while panning * “throttle”: updates are synchronized while panning, at intervals determined by the viewport_update_throttle parameter

viewport_update_throttle = param.Integer(allow_refs=False, bounds=(0, None), default=200, inclusive_bounds=(True, True), label=’Viewport update throttle’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x158e22b50>)

Time interval in milliseconds at which viewport updates are synchronized when viewport_update_policy is “throttle”.

_render_count = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’ render count’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x158e75290>)

Number of renders, increment to trigger re-render

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.RGGPlot(object=None, **params)[source]#

Bases: PNG

An RGGPlot pane renders an r2py-based ggplot2 figure to png and wraps the base64-encoded data in a bokeh Div model.

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.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

panel.pane.image.FileBase: embed

panel.pane.image.ImageBase: alt_text, caption, fixed_aspect, link_url

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

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=400, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x159276910>)

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

dpi = param.Integer(allow_refs=False, bounds=(1, None), default=144, inclusive_bounds=(True, True), label=’Dpi’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1593d5a90>)

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.ReactiveExpr(object=None, **params)[source]#

Bases: Pane

ReactiveExpr generates a UI for param.rx objects by rendering the widgets and outputs.

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout

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

The object being wrapped, which will be converted to a Bokeh model.

center = param.Boolean(allow_refs=False, default=False, label=’Center’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x158ed5210>)

Whether to center the output.

show_widgets = param.Boolean(allow_refs=False, default=True, label=’Show widgets’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x158ee5d90>)

Whether to display the widget inputs.

widget_layout = param.Selector(allow_refs=False, constant=True, default=<class ‘panel.layout.base.WidgetBox’>, label=’Widget layout’, names={}, nested_refs=False, objects=[<class ‘panel.layout.base.WidgetBox’>, <class ‘panel.layout.base.Row’>, <class ‘panel.layout.base.Column’>], rx=<param.reactive.reactive_ops object at 0x158ed5ad0>)

The layout object to display the widgets in.

widget_location = param.Selector(allow_refs=False, default=’left_top’, label=’Widget location’, names={}, nested_refs=False, objects=[‘left’, ‘right’, ‘top’, ‘bottom’, ‘top_left’, ‘top_right’, ‘bottom_left’, ‘bottom_right’, ‘left_top’, ‘right_top’, ‘right_bottom’], rx=<param.reactive.reactive_ops object at 0x158ed6590>)

The location of the widgets relative to the output of the reactive expression.

classmethod applies(object)[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

widget_layout[source]#

alias of WidgetBox

class panel.pane.Reacton(object=None, **params)[source]#

Bases: IPyWidget

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout

panel.pane.ipywidget.IPyWidget: object

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.SVG(object=None, **params)[source]#

Bases: ImageBase

The SVG pane embeds a .svg image file in a panel if provided a local path, or will link to a remote image if provided a URL.

Reference: https://panel.holoviz.org/reference/panes/SVG.html

Example:

>>> SVG(
...     'https://upload.wikimedia.org/wikipedia/commons/6/6b/Bitmap_VS_SVG.svg',
...     alt_text='A gif vs svg comparison',
...     link_url='https://en.wikipedia.org/wiki/SVG',
...     width=300, height=400
... )

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

panel.pane.image.FileBase: embed

panel.pane.image.ImageBase: alt_text, caption, fixed_aspect, link_url

encode = param.Boolean(allow_refs=False, default=True, label=’Encode’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x158f420d0>)

Whether to enable base64 encoding of the SVG, base64 encoded SVGs do not support links.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.Str(object=None, **params)[source]#

Bases: HTMLBasePane

The Str pane allows rendering arbitrary text and objects in a panel.

Unlike Markdown and HTML, a Str is interpreted as a raw string without applying any markup and is displayed in a fixed-width font by default.

The pane will render any text, and if given an object will display the object’s Python repr.

Reference: https://panel.holoviz.org/reference/panes/Str.html

Example:

>>> Str(
...    'This raw string will not be formatted, except for the applied style.',
...    styles={'font-size': '12pt'}
... )

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

classmethod applies(obj: Any) bool[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.Streamz(object=None, **params)[source]#

Bases: ReplacementPane

The Streamz pane renders streamz Stream objects emitting arbitrary objects, unlike the DataFrame pane which specifically handles streamz DataFrame and Series objects and exposes various formatting objects.

Reference: https://panel.holoviz.org/reference/panes/Streamz.html

Example:

>>> Streamz(some_streamz_stream_object, always_watch=True)

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout

panel.pane.base.ReplacementPane: object, inplace, _pane

always_watch = param.Boolean(allow_refs=False, default=False, label=’Always watch’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x158fb1b10>)

Whether to watch even when not displayed.

rate_limit = param.Number(allow_refs=False, bounds=(0, None), default=0.1, inclusive_bounds=(True, True), label=’Rate limit’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1592a1550>)

The minimum interval between events.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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 | None = None) list[Viewable][source]#

Iterates over the Viewable and any potential children in the applying the Selector.

Arguments#

selector: (type | callable | None)

The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.

Returns#

viewables: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.Textual(object=None, **params)[source]#

Bases: Pane

The Textual pane provides a wrapper around a Textual App component, rendering it inside a Terminal and running it on the existing Panel event loop, i.e. either on the server or the notebook asyncio.EventLoop.

Reference: https://panel.holoviz.org/reference/panes/Textual.html

Example:

>>> Textual(app)

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

classmethod applies(object)[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.VTK(obj, **params)[source]#

Bases: object

The VTK pane renders a VTK scene inside a panel, making it possible to interact with complex geometries in 3D.

Reference: https://panel.holoviz.org/reference/panes/VTK.html

Example:

>>> pn.extension('vtk')
>>> VTK(some_vtk_object, width=500, height=500)

This is a Class factory and allows to switch between VTKJS, VTKRenderWindow, and VTKRenderWindowSynchronized pane as a function of the object type and when the serialisation of the vtkRenderWindow occurs.

Once a pane is returned by this class (inst = VTK(object)), one can use pn.help(inst) to see parameters available for the current pane

class panel.pane.VTKVolume(object=None, **params)[source]#

Bases: AbstractVTK

The VTKVolume pane renders 3d volumetric data defined on regular grids. It may be constructed from a 3D NumPy array or a vtkVolume.

The pane provides a number of interactive control which can be set either through callbacks from Python or Javascript callbacks.

Reference: https://panel.holoviz.org/reference/panes/VTKVolume.html

Example:

>>> pn.extension('vtk')
>>> VTKVolume(
...    data_matrix, spacing=(3,2,1), interpolation='nearest',
...    edge_gradient=0, sampling=0,
...    sizing_mode='stretch_width', height=400,
... )

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.vtk.vtk.AbstractVTK: axes, camera, color_mappers, orientation_widget, interactive_orientation_widget

ambient = param.Number(allow_refs=False, default=0.2, inclusive_bounds=(True, True), label=’Ambient’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x158fe0810>, step=0.01)

Value to control the ambient lighting. It is the light an object gives even in the absence of strong light. It is constant in all directions.

controller_expanded = param.Boolean(allow_refs=False, default=True, label=’Controller expanded’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15962d3d0>)

If True the volume controller panel options is expanded in the view

colormap = param.Selector(allow_refs=False, default=’erdc_rainbow_bright’, label=’Colormap’, names={}, nested_refs=False, objects=[‘KAAMS’, ‘Cool to Warm’, ‘Cool to Warm (Extended)’, ‘Warm to Cool’, ‘Warm to Cool (Extended)’, ‘Rainbow Desaturated’, ‘Cold and Hot’, ‘Black-Body Radiation’, ‘X Ray’, ‘Grayscale’, ‘BkRd’, ‘BkGn’, ‘BkBu’, ‘BkMa’, ‘BkCy’, ‘Black, Blue and White’, ‘Black, Orange and White’, ‘Linear YGB 1211g’, ‘Linear Green (Gr4L)’, ‘Linear Blue (8_31f)’, ‘Blue to Red Rainbow’, ‘Red to Blue Rainbow’, ‘Rainbow Blended White’, ‘Rainbow Blended Grey’, ‘Rainbow Blended Black’, ‘Blue to Yellow’, ‘blot’, ‘CIELab Blue to Red’, ‘jet’, ‘rainbow’, ‘erdc_rainbow_bright’, ‘erdc_rainbow_dark’, ‘nic_CubicL’, ‘nic_CubicYF’, ‘gist_earth’, ‘2hot’, ‘erdc_red2yellow_BW’, ‘erdc_marine2gold_BW’, ‘erdc_blue2gold_BW’, ‘erdc_sapphire2gold_BW’, ‘erdc_red2purple_BW’, ‘erdc_purple2pink_BW’, ‘erdc_pbj_lin’, ‘erdc_blue2green_muted’, ‘erdc_blue2green_BW’, ‘GREEN-WHITE_LINEAR’, ‘erdc_green2yellow_BW’, ‘blue2cyan’, ‘erdc_blue2cyan_BW’, ‘erdc_blue_BW’, ‘BLUE-WHITE’, ‘erdc_purple_BW’, ‘erdc_magenta_BW’, ‘magenta’, ‘RED-PURPLE’, ‘erdc_red_BW’, ‘RED_TEMPERATURE’, ‘erdc_orange_BW’, ‘heated_object’, ‘erdc_gold_BW’, ‘erdc_brown_BW’, ‘copper_Matlab’, ‘pink_Matlab’, ‘bone_Matlab’, ‘gray_Matlab’, ‘Purples’, ‘Blues’, ‘Greens’, ‘PuBu’, ‘BuPu’, ‘BuGn’, ‘GnBu’, ‘GnBuPu’, ‘BuGnYl’, ‘PuRd’, ‘RdPu’, ‘Oranges’, ‘Reds’, ‘RdOr’, ‘BrOrYl’, ‘RdOrYl’, ‘CIELab_blue2red’, ‘blue2yellow’, ‘erdc_blue2gold’, ‘erdc_blue2yellow’, ‘erdc_cyan2orange’, ‘erdc_purple2green’, ‘erdc_purple2green_dark’, ‘coolwarm’, ‘BuRd’, ‘Spectral_lowBlue’, ‘GnRP’, ‘GYPi’, ‘GnYlRd’, ‘GBBr’, ‘PuOr’, ‘PRGn’, ‘PiYG’, ‘OrPu’, ‘BrBG’, ‘GyRd’, ‘erdc_divHi_purpleGreen’, ‘erdc_divHi_purpleGreen_dim’, ‘erdc_divLow_icePeach’, ‘erdc_divLow_purpleGreen’, ‘Haze_green’, ‘Haze_lime’, ‘Haze’, ‘Haze_cyan’, ‘nic_Edge’, ‘erdc_iceFire_H’, ‘erdc_iceFire_L’, ‘hsv’, ‘hue_L60’, ‘Spectrum’, ‘Warm’, ‘Cool’, ‘Blues’, ‘Wild Flower’, ‘Citrus’, ‘Brewer Diverging Purple-Orange (11)’, ‘Brewer Diverging Purple-Orange (10)’, ‘Brewer Diverging Purple-Orange (9)’, ‘Brewer Diverging Purple-Orange (8)’, ‘Brewer Diverging Purple-Orange (7)’, ‘Brewer Diverging Purple-Orange (6)’, ‘Brewer Diverging Purple-Orange (5)’, ‘Brewer Diverging Purple-Orange (4)’, ‘Brewer Diverging Purple-Orange (3)’, ‘Brewer Diverging Spectral (11)’, ‘Brewer Diverging Spectral (10)’, ‘Brewer Diverging Spectral (9)’, ‘Brewer Diverging Spectral (8)’, ‘Brewer Diverging Spectral (7)’, ‘Brewer Diverging Spectral (6)’, ‘Brewer Diverging Spectral (5)’, ‘Brewer Diverging Spectral (4)’, ‘Brewer Diverging Spectral (3)’, ‘Brewer Diverging Brown-Blue-Green (11)’, ‘Brewer Diverging Brown-Blue-Green (10)’, ‘Brewer Diverging Brown-Blue-Green (9)’, ‘Brewer Diverging Brown-Blue-Green (8)’, ‘Brewer Diverging Brown-Blue-Green (7)’, ‘Brewer Diverging Brown-Blue-Green (6)’, ‘Brewer Diverging Brown-Blue-Green (5)’, ‘Brewer Diverging Brown-Blue-Green (4)’, ‘Brewer Diverging Brown-Blue-Green (3)’, ‘Brewer Sequential Blue-Green (9)’, ‘Brewer Sequential Blue-Green (8)’, ‘Brewer Sequential Blue-Green (7)’, ‘Brewer Sequential Blue-Green (6)’, ‘Brewer Sequential Blue-Green (5)’, ‘Brewer Sequential Blue-Green (4)’, ‘Brewer Sequential Blue-Green (3)’, ‘Brewer Sequential Yellow-Orange-Brown (9)’, ‘Brewer Sequential Yellow-Orange-Brown (8)’, ‘Brewer Sequential Yellow-Orange-Brown (7)’, ‘Brewer Sequential Yellow-Orange-Brown (6)’, ‘Brewer Sequential Yellow-Orange-Brown (5)’, ‘Brewer Sequential Yellow-Orange-Brown (4)’, ‘Brewer Sequential Yellow-Orange-Brown (3)’, ‘Brewer Sequential Blue-Purple (9)’, ‘Brewer Sequential Blue-Purple (8)’, ‘Brewer Sequential Blue-Purple (7)’, ‘Brewer Sequential Blue-Purple (6)’, ‘Brewer Sequential Blue-Purple (5)’, ‘Brewer Sequential Blue-Purple (4)’, ‘Brewer Sequential Blue-Purple (3)’, ‘Brewer Qualitative Accent’, ‘Brewer Qualitative Dark2’, ‘Brewer Qualitative Set2’, ‘Brewer Qualitative Pastel2’, ‘Brewer Qualitative Pastel1’, ‘Brewer Qualitative Set1’, ‘Brewer Qualitative Paired’, ‘Brewer Qualitative Set3’, ‘Traffic Lights’, ‘Traffic Lights For Deuteranopes’, ‘Traffic Lights For Deuteranopes 2’, ‘Muted Blue-Green’, ‘Green-Blue Asymmetric Divergent (62Blbc)’, ‘Asymmtrical Earth Tones (6_21b)’, ‘Yellow 15’, ‘Magma (matplotlib)’, ‘Inferno (matplotlib)’, ‘Plasma (matplotlib)’, ‘Viridis (matplotlib)’, ‘BlueObeliskElements’], rx=<param.reactive.reactive_ops object at 0x159073950>)

Name of the colormap used to transform pixel value in color.

diffuse = param.Number(allow_refs=False, default=0.7, inclusive_bounds=(True, True), label=’Diffuse’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15962d150>, step=0.01)

Value to control the diffuse Lighting. It relies on both the light direction and the object surface normal.

display_volume = param.Boolean(allow_refs=False, default=True, label=’Display volume’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x159072810>)

If set to True, the 3D representation of the volume is displayed using ray casting.

display_slices = param.Boolean(allow_refs=False, default=False, label=’Display slices’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15962dbd0>)

If set to true, the orthgonal slices in the three (X, Y, Z) directions are displayed. Position of each slice can be controlled using slice_(i,j,k) parameters.

edge_gradient = param.Number(allow_refs=False, bounds=(0, 1), default=0.4, inclusive_bounds=(True, True), label=’Edge gradient’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15962d3d0>, step=0.01)

Parameter to adjust the opacity of the volume based on the gradient between voxels.

interpolation = param.Selector(allow_refs=False, default=’fast_linear’, label=’Interpolation’, names={}, nested_refs=False, objects=[‘fast_linear’, ‘linear’, ‘nearest’], rx=<param.reactive.reactive_ops object at 0x15962da10>)

interpolation type for sampling a volume. nearest interpolation will snap to the closest voxel, linear will perform trilinear interpolation to compute a scalar value from surrounding voxels. fast_linear under WebGL 1 will perform bilinear interpolation on X and Y but use nearest for Z. This is slightly faster than full linear at the cost of no Z axis linear interpolation.

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

Lookup Table in format {low, high, palette}

max_data_size = param.Number(allow_refs=False, default=33.554432, inclusive_bounds=(True, True), label=’Max data size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15962d590>)

Maximum data size transfer allowed without subsampling

nan_opacity = param.Number(allow_refs=False, bounds=(0.0, 1.0), default=1.0, inclusive_bounds=(True, True), label=’Nan opacity’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15962cd90>)

Opacity applied to nan values in slices

origin = param.Tuple(allow_None=True, allow_refs=False, label=’Origin’, length=3, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x158f88b90>)

render_background = param.Color(allow_named=True, allow_refs=False, default=’#52576e’, label=’Render background’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x159073cd0>)

Allows to specify the background color of the 3D rendering. The value must be specified as an hexadecimal color string.

rescale = param.Boolean(allow_refs=False, default=False, label=’Rescale’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15962f990>)

If set to True the colormap is rescaled between min and max value of the non-transparent pixel, otherwise the full range of the pixel values are used.

shadow = param.Boolean(allow_refs=False, default=True, label=’Shadow’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x159072d90>)

If set to False, then the mapper for the volume will not perform shading computations, it is the same as setting ambient=1, diffuse=0, specular=0.

sampling = param.Number(allow_refs=False, bounds=(0, 1), default=0.4, inclusive_bounds=(True, True), label=’Sampling’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15962d390>, step=0.01)

Parameter to adjust the distance between samples used for rendering. The lower the value is the more precise is the representation but it is more computationally intensive.

spacing = param.Tuple(allow_refs=False, default=(1, 1, 1), label=’Spacing’, length=3, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x159072810>)

Distance between voxel in each direction

specular = param.Number(allow_refs=False, default=0.3, inclusive_bounds=(True, True), label=’Specular’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15962cd90>, step=0.01)

Value to control specular lighting. It is the light reflects back toward the camera when hitting the object.

specular_power = param.Number(allow_refs=False, default=8.0, inclusive_bounds=(True, True), label=’Specular power’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15962ccd0>)

Specular power refers to how much light is reflected in a mirror like fashion, rather than scattered randomly in a diffuse manner.

slice_i = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Slice i’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15962d0d0>)

Integer parameter to control the position of the slice normal to the X direction.

slice_j = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Slice j’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15962ce10>)

Integer parameter to control the position of the slice normal to the Y direction.

slice_k = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Slice k’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15962dbd0>)

Integer parameter to control the position of the slice normal to the Z direction.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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.

classmethod register_serializer(class_type, serializer)[source]#

Register a serializer for a given type of class. A serializer is a function which take an instance of class_type (like a vtk.vtkImageData) as input and return a numpy array of the data

save(filename: str | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.Vega(object=None, **params)[source]#

Bases: ModelPane

The Vega pane renders Vega-lite based plots (including those from Altair) inside a panel.

Note

  • to use the Vega pane, the Panel extension has to be

loaded with ‘vega’ as an argument to ensure that vega.js is initialized. - it supports selection events - it optimizes the plot rendering by using binary serialization for any array data found on the Vega/Altair object, providing huge speedups over the standard JSON serialization employed by Vega natively.

Reference: https://panel.holoviz.org/reference/panes/Vega.html

Example:

>>> pn.extension('vega')
>>> Vega(some_vegalite_dict_or_altair_object, height=240)

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

debounce = param.ClassSelector(allow_refs=False, class_=(<class ‘int’>, <class ‘dict’>), default=20, label=’Debounce’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x159580490>)

Declares the debounce time in milliseconds either for all events or if a dictionary is provided for individual events.

selection = param.ClassSelector(allow_None=True, allow_refs=False, class_=<class ‘param.parameterized.Parameterized’>, label=’Selection’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x159582dd0>)

The Selection object reflects any selections available on the supplied vega plot into Python.

show_actions = param.Boolean(allow_refs=False, default=False, label=’Show actions’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1595803d0>)

Whether to show Vega actions.

theme = param.ObjectSelector(allow_None=True, allow_refs=False, label=’Theme’, names={}, nested_refs=False, objects=[‘excel’, ‘ggplot2’, ‘quartz’, ‘vox’, ‘fivethirtyeight’, ‘dark’, ‘latimes’, ‘urbaninstitute’, ‘googlecharts’], rx=<param.reactive.reactive_ops object at 0x159581ad0>)

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.Video(object=None, **params)[source]#

Bases: _MediaBase

The Video Pane displays a video player given a local or remote video file.

The widget also allows access and control over the player state including toggling of playing/paused and loop state, the current time, and the volume.

Depending on the browser the video player supports mp4, webm, and ogg containers and a variety of codecs.

Reference: https://panel.holoviz.org/reference/panes/Video.html

Example:

>>> Video(
...     'https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_640_3MG.mp4',
...     width=640, height=360, loop=True
... )

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout

panel.pane.media._MediaBase: object, loop, time, throttle, paused, autoplay, muted

volume = param.Integer(allow_refs=False, bounds=(0, 100), default=100, inclusive_bounds=(True, True), label=’Volume’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15954e850>)

The volume of the media player.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.Vizzu(object=None, **params)[source]#

Bases: ModelPane, SyncableData

The Vizzu pane provides an interactive visualization component for large, real-time datasets built on the Vizzu project.

Reference: https://panel.holoviz.org/reference/panes/Vizzu.html

Example:

>>> Vizzu(df)

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.reactive.SyncableData: selection

panel.pane.base.PaneBase: margin, default_layout, object

animation = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Animation’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x159588a50>)

Animation settings (see https://lib.vizzuhq.com/latest/reference/modules/Anim/).

config = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Config’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x15958b150>)

The config contains all of the parameters needed to render a particular static chart or a state of an animated chart (see https://lib.vizzuhq.com/latest/reference/interfaces/Config.Chart/).

click = param.Parameter(allow_None=True, allow_refs=False, label=’Click’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x159588c10>)

Data associated with the latest click event.

column_types = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Column types’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x15958b250>)

Optional column definitions. If not defined will be inferred from the data.

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

The config contains all of the parameters needed to render a particular static chart or a state of an animated chart.

style = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Style’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x159588250>)

Style configuration of the chart.

tooltip = param.Boolean(allow_refs=False, default=False, label=’Tooltip’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x159588a50>)

Whether to enable tooltips on the chart.

animate(anim: dict[str, Any], options: int | dict[str, Any] | None = None) None[source]#

Updates the chart with a new configuration.

classmethod applies(object)[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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

Register a callback to be executed when any element in the chart is clicked on.

Arguments#

callback: (callable)

The callback to run on click events.

patch(patch_value: 'pd.DataFrame' | 'pd.Series' | dict) None[source]#

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

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

stream(stream_value: 'pd.DataFrame' | 'pd.Series' | dict, rollover: int | None = None, reset_index: bool = True) None[source]#

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

Arguments#

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.

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”]}) >>> 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.pane.YT(object=None, **params)[source]#

Bases: HTML

YT panes wrap plottable objects from the YT library. By default, the height and width are calculated by summing all contained plots, but can optionally be specified explicitly to provide additional space.

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

panel.pane.markup.HTML: disable_math, sanitize_html, sanitize_hook

classmethod applies(obj: bool) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

panel.pane.panel(obj: Any, **kwargs) Viewable[source]#

Creates a displayable Panel object given any valid Python object.

The appropriate Pane to render a specific object is determined by iterating over all defined Pane types and querying it’s .applies method for a priority value.

Any keyword arguments are passed down to the applicable Pane.

Setting loading_indicator=True will display a loading indicator while the function is being evaluated.

To lazily render components when the application loads, you may also provide a Python function, with or without bound parameter dependencies and set defer_load=True.

Reference: https://panel.holoviz.org/explanation/components/components_overview.html#panes

>>> pn.panel(some_python_object, width=500)

Arguments#

obj: object

Any object to be turned into a Panel

**kwargs: dict

Any keyword arguments to be passed to the applicable Pane

Returns#

layout: Viewable

A Viewable representation of the input object


_textual Module#

class panel.pane._textual.PanelDriver(app: App, /, **kwargs)[source]#

Bases: Driver

class SignalResume[source]#

Bases: Event

Event sent to the app when a resume signal should be published.

ALLOW_SELECTOR_MATCH: ClassVar[set[str]] = {}#

Additional attributes that can be used with the [on decorator][textual.on].

These attributes must be widgets.

can_replace(message: Message) bool[source]#

Check if another message may supersede this one.

Args:

message: Another message.

Returns:

True if this message may replace the given message

property control: DOMNode | None#

The widget associated with this message, or None by default.

handler_name: ClassVar[str] = 'on_driver_signal_resume'#

Name of the default message handler.

property is_forwarded: bool#

Has the message been forwarded?

prevent_default(prevent: bool = True) Message[source]#

Suppress the default action(s). This will prevent handlers in any base classes from being called.

Args:
prevent: True if the default action should be suppressed,

or False if the default actions should be performed.

set_sender(sender: MessagePump) Self[source]#

Set the sender of the message.

Args:

sender: The sender.

Note:

When creating a message the sender is automatically set. Normally there will be no need for this method to be called. This method will be used when strict control is required over the sender of a message.

Returns:

Self.

stop(stop: bool = True) Message[source]#

Stop propagation of the message to parent.

Args:

stop: The stop flag.

property can_suspend: bool#

Can this driver be suspended?

close()[source]#

Perform any final cleanup.

deliver_binary(binary: BinaryIO | TextIO, *, delivery_key: str, save_path: Path, open_method: Literal['browser', 'download'] = 'download', encoding: str | None = None, mime_type: str | None = None, name: str | None = None) None[source]#

Save the file path_or_file to save_path.

If running via web through Textual Web or Textual Serve, this will initiate a download in the web browser.

Args:

binary: The binary file to save. delivery_key: The unique key that was used to deliver the file. save_path: The location to save the file to. open_method: web only Whether to open the file in the browser or

to prompt the user to download it. When running via a standard (non-web) terminal, this is ignored.

encoding: web only The text encoding to use when saving the file.

This will be passed to Python’s open() built-in function. When running via web, this will be used to set the charset in the Content-Type header.

mime_type: web only The MIME type of the file. This will be used to

set the Content-Type header in the HTTP response.

name: A user-defined named which will be returned in [DeliveryComplete][textual.events.DeliveryComplete]

and [DeliveryComplete][textual.events.DeliveryComplete].

disable_input()[source]#

Disable further input.

flush()[source]#

Flush any buffered data.

property is_headless: bool#

Is the driver ‘headless’ (no output)?

property is_inline: bool#

Is the driver ‘inline’ (not full-screen)?

property is_web: bool#

Is the driver ‘web’ (running via a browser)?

no_automatic_restart() Iterator[None][source]#

A context manager used to tell the driver to not auto-restart.

For drivers that support the application being suspended by the operating system, this context manager is used to mark a body of code as one that will manage its own stop and start.

open_url(url: str, new_tab: bool = True) None[source]#

Open a URL in the default web browser.

Args:

url: The URL to open. new_tab: Whether to open the URL in a new tab.

This is only relevant when running via the WebDriver, and is ignored when called while running through the terminal.

process_event(event: Event) None[source]#

Perform additional processing on an event, prior to sending.

Args:

event: An event to send.

resume_application_mode() None[source]#

Resume application mode.

Used to resume application mode after it has been previously suspended.

send_event(event: Event) None[source]#

Send an event to the target app.

Args:

event: An event.

start_application_mode()[source]#

Start application mode.

stop_application_mode()[source]#

Stop application mode, restore state.

suspend_application_mode() None[source]#

Suspend application mode.

Used to suspend application mode and allow uninhibited access to the terminal.

write(data: str) None[source]#

Write data to the output device.

Args:

data: Raw data.


alert Module#

Bootstrap inspired Alerts

See https://getbootstrap.com/docs/4.0/components/alerts/

class panel.pane.alert.Alert(object=None, **params)[source]#

Bases: Markdown

The Alert pane allows providing contextual feedback messages for typical user actions. The Alert supports markdown strings.

Reference: https://panel.holoviz.org/reference/panes/Alert.html

Example:

>>> Alert('Some important message', alert_type='warning')

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

panel.pane.markup.Markdown: dedent, disable_math, extensions, plugins, renderer, renderer_options

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

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)


base Module#

Defines base classes for Pane components which allow wrapping a Python object transforming it into a Bokeh model that can be rendered.

class panel.pane.base.ModelPane(object=None, **params)[source]#

Bases: Pane

ModelPane provides a baseclass that allows quickly wrapping a Bokeh model and translating parameters defined on the class with properties defined on the model.

In simple cases subclasses only have to define the Bokeh model to render to and the _transform_object method which transforms the Python object being wrapped into properties that the bokeh.model.Model can consume.

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.base.Pane(object=None, **params)[source]#

Bases: PaneBase, Reactive

Pane is the abstract baseclass for all atomic displayable units in the Panel library.

Panes defines an extensible interface for wrapping arbitrary objects and transforming them into renderable components.

Panes are reactive in the sense that when the object they are wrapping is replaced or modified the UI will reflect the updated object.

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.base.PaneBase(object=None, **params)[source]#

Bases: Layoutable

PaneBase represents an abstract baseclass which can be used as a mix-in class to define a component that mirrors the Pane API. This means that this component will participate in the automatic resolution of the appropriate pane type when Panel is asked to render an object of unknown type.

The resolution of the appropriate pane type can be implemented using the applies method and the priority class attribute. The applies method should either return a boolean value indicating whether the pane can render the supplied object. If it can the priority determines which of the panes that apply will be selected. If the priority is None then the applies method must return a priority value.

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

margin = param.Margin(allow_None=True, allow_refs=False, default=(5, 10), label=’Margin’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1595c0850>)

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

default_layout = param.ClassSelector(allow_refs=False, class_=<class ‘panel.layout.base.Panel’>, default=<class ‘panel.layout.base.Row’>, label=’Default layout’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1595d82d0>)

Defines the layout the model(s) returned by the pane will be placed in.

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

The object being wrapped, which will be converted to a Bokeh model.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

default_layout[source]#

alias of Row

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

class panel.pane.base.ReplacementPane(object: Any = None, **params)[source]#

Bases: Pane

ReplacementPane provides a baseclass for dynamic components that may have to dynamically update or switch out their contents, e.g. a dynamic callback that may return different objects to be rendered.

When the pane updates it either entirely replaces the underlying bokeh.model.Model, by creating an internal layout to replace the children on, or updates the existing model in place.

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout

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

The object being wrapped, which will be converted to a Bokeh model.

inplace = param.Boolean(allow_refs=False, default=False, label=’Inplace’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x159020690>)

Whether to update the object inplace.

_pane = param.ClassSelector(allow_None=True, allow_refs=False, class_=<class ‘panel.viewable.Viewable’>, label=’ pane’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15960b450>)

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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 | None = None) list[Viewable][source]#

Iterates over the Viewable and any potential children in the applying the Selector.

Arguments#

selector: (type | callable | None)

The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.

Returns#

viewables: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

exception panel.pane.base.RerenderError(*args, layout=None, **kwargs)[source]#

Bases: RuntimeError

Error raised when a pane requests re-rendering during initial render.

add_note()#

Exception.add_note(note) – add a note to the exception

with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

panel.pane.base.panel(obj: Any, **kwargs) Viewable[source]#

Creates a displayable Panel object given any valid Python object.

The appropriate Pane to render a specific object is determined by iterating over all defined Pane types and querying it’s .applies method for a priority value.

Any keyword arguments are passed down to the applicable Pane.

Setting loading_indicator=True will display a loading indicator while the function is being evaluated.

To lazily render components when the application loads, you may also provide a Python function, with or without bound parameter dependencies and set defer_load=True.

Reference: https://panel.holoviz.org/explanation/components/components_overview.html#panes

>>> pn.panel(some_python_object, width=500)

Arguments#

obj: object

Any object to be turned into a Panel

**kwargs: dict

Any keyword arguments to be passed to the applicable Pane

Returns#

layout: Viewable

A Viewable representation of the input object


deckgl Module#

Defines a PyDeck Pane which renders a PyDeck plot using a PyDeckPlot bokeh model.

class panel.pane.deckgl.DeckGL(object=None, **params)[source]#

Bases: ModelPane

The DeckGL pane renders the Deck.gl JSON specification as well as PyDeck plots inside a panel.

Deck.gl is a very powerful WebGL-powered framework for visual exploratory data analysis of large datasets.

Reference: https://panel.holoviz.org/reference/panes/DeckGL.html

Example:

>>> pn.extension('deckgl')
>>> DeckGL(
...    some_deckgl_dict_or_pydeck_object,
...    mapbox_api_key=MAPBOX_KEY, height=600
... )

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

mapbox_api_key = param.String(allow_None=True, allow_refs=False, label=’Mapbox api key’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15e014290>)

The MapBox API key if not supplied by a PyDeck object.

tooltips = param.ClassSelector(allow_refs=False, class_=(<class ‘bool’>, <class ‘dict’>), default=True, label=’Tooltips’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15dfbe450>)

Whether to enable tooltips

configuration = param.String(allow_refs=False, default=’’, label=’Configuration’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15dff4cd0>)

Custom configuration dictionary as json string

click_state = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Click state’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15dfbd0d0>)

Contains the last click event on the DeckGL plot.

hover_state = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Hover state’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15dff4d50>)

The current hover state of the DeckGL plot.

view_state = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={}, label=’View state’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15dfbe250>)

The current view state of the DeckGL plot.

throttle = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={‘view’: 200, ‘hover’: 200}, label=’Throttle’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15dff4d50>)

Throttling timeout (in milliseconds) for view state and hover events sent from the frontend.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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.

priority: ClassVar[float | bool | None] = None#
save(filename: str | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

panel.pane.deckgl.lower_camel_case_keys(attrs)[source]#

Makes all the keys in a dictionary camel-cased and lower-case

Parameters#

attrsdict

Dictionary for which all the keys should be converted to camel-case

panel.pane.deckgl.to_camel_case(snake_case: str) str[source]#

Makes a snake case string into a camel case one

Parameters#

snake_casestr

Snake-cased string (e.g., “snake_cased”) to be converted to camel-case (e.g., “camelCase”)


echarts Module#

class panel.pane.echarts.ECharts(object=None, **params)[source]#

Bases: ModelPane

ECharts panes allow rendering echarts.js dictionaries and pyecharts plots.

Reference: https://panel.holoviz.org/reference/panes/ECharts.html

Example:

>>> pn.extension('echarts')
>>> ECharts(some_echart_dict_or_pyecharts_object, height=480, width=640)

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout

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

The Echarts object being wrapped. Can be an Echarts dictionary or a pyecharts chart

options = param.Parameter(allow_None=True, allow_refs=False, label=’Options’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15e1e4dd0>)

An optional dict of options passed to Echarts.setOption. Allows to fine-tune the rendering behavior. For example, you might want to use options={ “replaceMerge”: [‘series’] }) when updating the objects with a value containing a smaller number of series.

renderer = param.ObjectSelector(allow_refs=False, default=’canvas’, label=’Renderer’, names={}, nested_refs=False, objects=[‘canvas’, ‘svg’], rx=<param.reactive.reactive_ops object at 0x15e1e47d0>)

Whether to render as HTML canvas or SVG

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

Theme to apply to plots.

classmethod applies(obj: Any, **params) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

Returns the bokeh model corresponding to this panel object

js_on_event(event: str, callback: str | CustomJS, query: str | None = None, **args)[source]#

Register a Javascript event handler which triggers when the specified event is triggered. The callback can be a snippet of Javascript code or a bokeh CustomJS object making it possible to manipulate other models in response to an event.

Reference: https://apache.github.io/echarts-handbook/en/concepts/event/

Arguments#

event: str

The name of the event to register a handler on, e.g. ‘click’.

code: str

The event handler to be executed when the event fires.

query: str | None

A query that determines when the event fires.

args: Viewable

A dictionary of Viewables to make available in the namespace of the 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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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(event: str, callback: Callable, query: str | None = None)[source]#

Register anevent handler which triggers when the specified event is triggered.

Reference: https://apache.github.io/echarts-handbook/en/concepts/event/

Arguments#

event: str

The name of the event to register a handler on, e.g. ‘click’.

callback: str | CustomJS

The event handler to be executed when the event fires.

query: str | None

A query that determines when the event fires.

priority: ClassVar[float | bool | None] = None#
save(filename: str | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)


equation Module#

Renders objects representing equations including LaTeX strings and SymPy objects.

class panel.pane.equation.LaTeX(object=None, **params)[source]#

Bases: ModelPane

The LaTeX pane allows rendering LaTeX equations. It uses either KaTeX or MathJax depending on the defined renderer.

By default it will use the renderer loaded in the extension (e.g. pn.extension(‘katex’)), defaulting to KaTeX if both are loaded.

Reference: https://panel.holoviz.org/reference/panes/LaTeX.html

Example:

>>> pn.extension('katex')
>>> LaTeX(
...     'The LaTeX pane supports two delimiters: $LaTeX$ and \(LaTeX\)',
...     styles={'font-size': '18pt'}, width=800
... )

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

renderer = param.ObjectSelector(allow_None=True, allow_refs=False, label=’Renderer’, names={}, nested_refs=False, objects=[‘katex’, ‘mathjax’], rx=<param.reactive.reactive_ops object at 0x15e3b6890>)

The JS renderer used to render the LaTeX expression. Defaults to katex.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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.

priority: ClassVar[float | bool | None] = None#
save(filename: str | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)


holoviews Module#

HoloViews integration for Panel including a Pane to render HoloViews

objects and their widgets and support for Links

class panel.pane.holoviews.HoloViews(object=None, **params)[source]#

Bases: Pane

HoloViews panes render any HoloViews object using the currently selected backend (‘bokeh’ (default), ‘matplotlib’ or ‘plotly’).

To be able to use the plotly backend you must add plotly to pn.extension.

Reference: https://panel.holoviz.org/reference/panes/HoloViews.html

Example:

>>> HoloViews(some_holoviews_object)

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

backend = param.ObjectSelector(allow_refs=False, label=’Backend’, names={}, nested_refs=False, objects=[‘bokeh’, ‘matplotlib’, ‘plotly’], rx=<param.reactive.reactive_ops object at 0x15e5f92d0>)

The HoloViews backend used to render the plot (if None defaults to the currently selected renderer).

center = param.Boolean(allow_refs=False, default=False, label=’Center’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15e5ed610>)

Whether to center the plot.

format = param.Selector(allow_refs=False, default=’png’, label=’Format’, names={}, nested_refs=False, objects=[‘png’, ‘svg’], rx=<param.reactive.reactive_ops object at 0x15e42d090>)

The format to render Matplotlib plots with.

linked_axes = param.Boolean(allow_refs=False, default=True, label=’Linked axes’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15e5dc490>)

Whether to link the axes of bokeh plots inside this pane across a panel layout.

renderer = param.Parameter(allow_None=True, allow_refs=False, label=’Renderer’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15bc19d10>)

Explicit renderer instance to use for rendering the HoloViews plot. Overrides the backend.

theme = param.ClassSelector(allow_None=True, allow_refs=False, class_=(<class ‘bokeh.themes.theme.Theme’>, <class ‘str’>), label=’Theme’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15e5dc150>)

Bokeh theme to apply to the HoloViews plot.

widget_location = param.ObjectSelector(allow_refs=False, default=’right_top’, label=’Widget location’, names={}, nested_refs=False, objects=[‘left’, ‘bottom’, ‘right’, ‘top’, ‘top_left’, ‘top_right’, ‘bottom_left’, ‘bottom_right’, ‘left_top’, ‘left_bottom’, ‘right_top’, ‘right_bottom’], rx=<param.reactive.reactive_ops object at 0x15e5dc1d0>)

The layout of the plot and the widgets. The value refers to the position of the widgets relative to the plot.

widget_layout = param.ObjectSelector(allow_refs=False, constant=True, default=<class ‘panel.layout.base.WidgetBox’>, label=’Widget layout’, names={}, nested_refs=False, objects=[<class ‘panel.layout.base.WidgetBox’>, <class ‘panel.layout.base.Row’>, <class ‘panel.layout.base.Column’>], rx=<param.reactive.reactive_ops object at 0x15e5dc2d0>)

The layout object to display the widgets in.

widget_type = param.ObjectSelector(allow_refs=False, default=’individual’, label=’Widget type’, names={}, nested_refs=False, objects=[‘individual’, ‘scrubber’], rx=<param.reactive.reactive_ops object at 0x15e5dc510>)

) Whether to generate individual widgets for each dimension or on global scrubber.

widgets = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Widgets’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15e5dc6d0>)

A mapping from dimension name to a widget instance which will be used to override the default widgets.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

widget_layout[source]#

alias of WidgetBox

class panel.pane.holoviews.Interactive(object=None, **params)[source]#

Bases: Pane

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout

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

The object being wrapped, which will be converted to a Bokeh model.

classmethod applies(object: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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.

priority: ClassVar[float | bool | None] = None#
save(filename: str | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

Traverses the supplied Viewable searching for Links between any HoloViews based panes.

panel.pane.holoviews.generate_panel_bokeh_map(root_model, panel_views)[source]#

mapping panel elements to its bokeh models

panel.pane.holoviews.is_bokeh_element_plot(plot)[source]#

Checks whether plotting instance is a HoloViews ElementPlot rendered with the bokeh backend.

Pre-processing hook to allow linking axes across HoloViews bokeh plots.


image Module#

Contains Image panes including renderers for PNG, SVG, GIF and JPG file types.

class panel.pane.image.FileBase(object=None, **params)[source]#

Bases: HTMLBasePane

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

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

Whether to embed the file as base64.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.image.GIF(object=None, **params)[source]#

Bases: ImageBase

The GIF pane embeds a .gif image file in a panel if provided a local path, or will link to a remote image if provided a URL.

Reference: https://panel.holoviz.org/reference/panes/GIF.html

Example:

>>> GIF(
...     'https://upload.wikimedia.org/wikipedia/commons/b/b1/Loading_icon.gif',
...     alt_text='A loading spinner',
...     link_url='https://commons.wikimedia.org/wiki/File:Loading_icon.gif',
...     width=500
... )

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

panel.pane.image.FileBase: embed

panel.pane.image.ImageBase: alt_text, caption, fixed_aspect, link_url

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.image.ICO(object=None, **params)[source]#

Bases: ImageBase

The ICO pane embeds an .ico image file in a panel if provided a local path, or will link to a remote image if provided a URL.

Reference: https://panel.holoviz.org/reference/panes/ICO.html

Example:

>>> ICO(
...     some_url,
...     alt_text='An .ico file',
...     link_url='https://en.wikipedia.org/wiki/ICO_(file_format)',
...     width=50
...

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

panel.pane.image.FileBase: embed

panel.pane.image.ImageBase: alt_text, caption, fixed_aspect, link_url

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.image.Image(object=None, **params)[source]#

Bases: ImageBase

The Image pane embeds any known image format in a panel if provided a local path, bytes or remote image link.

Example:

>>> Image(
...     'https://panel.holoviz.org/_static/logo_horizontal.png',
...     alt_text='The Panel Logo',
...     link_url='https://panel.holoviz.org/index.html',
...     width=500
... )

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

panel.pane.image.FileBase: embed

panel.pane.image.ImageBase: alt_text, caption, fixed_aspect, link_url

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.image.ImageBase(object=None, **params)[source]#

Bases: FileBase

Encodes an image as base64 and wraps it in a Bokeh Div model. This is an abstract base class that needs the image type to be specified and specific code for determining the image shape.

The filetype determines the filetype, extension, and MIME type for this image. Each image type (png,jpg,gif) has a base class that supports anything with a _repr_X_ method (where X is png, gif, etc.), a local file with the given file extension, or a HTTP(S) url with the given extension. Subclasses of each type can provide their own way of obtaining or generating a PNG.

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

panel.pane.image.FileBase: embed

alt_text = param.String(allow_None=True, allow_refs=False, label=’Alt text’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15e9fe750>)

alt text to add to the image tag. The alt text is shown when a user cannot load or display the image.

caption = param.String(allow_None=True, allow_refs=False, label=’Caption’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15e9fff50>)

Optional caption for the image.

fixed_aspect = param.Boolean(allow_refs=False, default=True, label=’Fixed aspect’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15e9fe3d0>)

Whether the aspect ratio of the image should be forced to be equal.

link_url = param.String(allow_None=True, allow_refs=False, label=’Link url’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15e9ffe50>)

A link URL to make the image clickable and link to some other website.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.image.JPG(object=None, **params)[source]#

Bases: ImageBase

The JPG pane embeds a .jpg or .jpeg image file in a panel if provided a local path, or will link to a remote image if provided a URL.

Reference: https://panel.holoviz.org/reference/panes/JPG.html

Example:

>>> JPG(
...     'https://www.gstatic.com/webp/gallery/4.sm.jpg',
...     alt_text='A nice tree',
...     link_url='https://en.wikipedia.org/wiki/JPEG',
...     width=500
... )

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

panel.pane.image.FileBase: embed

panel.pane.image.ImageBase: alt_text, caption, fixed_aspect, link_url

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.image.PDF(object=None, **params)[source]#

Bases: FileBase

The PDF pane embeds a .pdf image file in a panel if provided a local path, or will link to a remote image if provided a URL.

Reference: https://panel.holoviz.org/reference/panes/PDF.html

Example:

>>> PDF(
...     'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf',
...     width=300, height=410
... )

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

panel.pane.image.FileBase: embed

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

Start page of the pdf, by default the first page.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.image.PNG(object=None, **params)[source]#

Bases: ImageBase

The PNG pane embeds a .png image file in a panel if provided a local path, or will link to a remote image if provided a URL.

Reference: https://panel.holoviz.org/reference/panes/PNG.html

Example:

>>> PNG(
...     'https://panel.holoviz.org/_static/logo_horizontal.png',
...     alt_text='The Panel Logo',
...     link_url='https://panel.holoviz.org/index.html',
...     width=500
... )

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

panel.pane.image.FileBase: embed

panel.pane.image.ImageBase: alt_text, caption, fixed_aspect, link_url

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.image.SVG(object=None, **params)[source]#

Bases: ImageBase

The SVG pane embeds a .svg image file in a panel if provided a local path, or will link to a remote image if provided a URL.

Reference: https://panel.holoviz.org/reference/panes/SVG.html

Example:

>>> SVG(
...     'https://upload.wikimedia.org/wikipedia/commons/6/6b/Bitmap_VS_SVG.svg',
...     alt_text='A gif vs svg comparison',
...     link_url='https://en.wikipedia.org/wiki/SVG',
...     width=300, height=400
... )

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

panel.pane.image.FileBase: embed

panel.pane.image.ImageBase: alt_text, caption, fixed_aspect, link_url

encode = param.Boolean(allow_refs=False, default=True, label=’Encode’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15ea82dd0>)

Whether to enable base64 encoding of the SVG, base64 encoded SVGs do not support links.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.image.WebP(object=None, **params)[source]#

Bases: ImageBase

The WebP pane embeds a .webp image file in a panel if provided a local path, or will link to a remote image if provided a URL.

Reference: https://panel.holoviz.org/reference/panes/WebP.html

Example:

>>> WebP(
...     'https://assets.holoviz.org/panel/samples/webp_sample.webp',
...     alt_text='A nice tree',
...     link_url='https://en.wikipedia.org/wiki/WebP',
...     width=500,
...     caption='A nice tree'
... )

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

panel.pane.image.FileBase: embed

panel.pane.image.ImageBase: alt_text, caption, fixed_aspect, link_url

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)


ipywidget Module#

class panel.pane.ipywidget.IPyLeaflet(object=None, **params)[source]#

Bases: IPyWidget

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout

panel.pane.ipywidget.IPyWidget: object

sizing_mode = param.ObjectSelector(allow_refs=False, default=’stretch_width’, 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 0x15f19c290>)

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.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.ipywidget.IPyWidget(object=None, **params)[source]#

Bases: Pane

The IPyWidget pane renders any ipywidgets model both in the notebook and in a deployed server.

When rendering ipywidgets on the server you must add ipywidgets to pn.extension. You must not do this in Jupyterlab as this may render Jupyterlab unusable.

Reference: https://panel.holoviz.org/reference/panes/IPyWidget.html

Example:

>>> IPyWidget(some_ipywidget)

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout

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

The IPywidget being wrapped, which will be converted to a Bokeh model.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.ipywidget.Reacton(object=None, **params)[source]#

Bases: IPyWidget

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout

panel.pane.ipywidget.IPyWidget: object

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)


markup Module#

Pane class which render various markup languages including HTML, Markdown, and also regular strings.

class panel.pane.markup.DataFrame(object=None, **params)[source]#

Bases: HTML

The DataFrame pane renders pandas, dask and streamz DataFrame types using their custom HTML repr.

In the case of a streamz DataFrame the rendered data will update periodically.

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

Example:

>>> DataFrame(df, index=False, max_rows=25, width=400)

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

panel.pane.markup.HTML: disable_math, sanitize_html, sanitize_hook

bold_rows = param.Boolean(allow_refs=False, default=True, label=’Bold rows’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15fd9c290>)

Make the row labels bold in the output.

border = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Border’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15fe688d0>)

A border=border attribute is included in the opening <table> tag.

classes = param.List(allow_refs=False, bounds=(0, None), default=[‘panel-df’], label=’Classes’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15fe424d0>)

CSS class(es) to apply to the resulting html table.

col_space = param.ClassSelector(allow_None=True, allow_refs=False, class_=(<class ‘str’>, <class ‘int’>, <class ‘dict’>), label=’Col space’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15fe680d0>)

The minimum width of each column in CSS length units. An int is assumed to be px units.

decimal = param.String(allow_refs=False, default=’.’, label=’Decimal’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15fe4d950>)

Character recognized as decimal separator, e.g. ‘,’ in Europe.

escape = param.Boolean(allow_refs=False, default=True, label=’Escape’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15fe4e390>)

Whether or not to escape the dataframe HTML. For security reasons the default value is True.

float_format = param.Callable(allow_None=True, allow_refs=False, label=’Float format’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15fae4ad0>)

Formatter function to apply to columns’ elements if they are floats. The result of this function must be a unicode string.

formatters = param.ClassSelector(allow_None=True, allow_refs=False, class_=(<class ‘dict’>, <class ‘list’>), label=’Formatters’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15fc1ecd0>)

Formatter functions to apply to columns’ elements by position or name. The result of each function must be a unicode string.

header = param.Boolean(allow_refs=False, default=True, label=’Header’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15f311d50>)

Whether to print column labels.

index = param.Boolean(allow_refs=False, default=True, label=’Index’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15fd79490>)

Whether to print index (row) labels.

index_names = param.Boolean(allow_refs=False, default=True, label=’Index names’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15f311d50>)

Prints the names of the indexes.

justify = param.ObjectSelector(allow_None=True, allow_refs=False, label=’Justify’, names={}, nested_refs=False, objects=[‘left’, ‘right’, ‘center’, ‘justify’, ‘justify-all’, ‘start’, ‘end’, ‘inherit’, ‘match-parent’, ‘initial’, ‘unset’], rx=<param.reactive.reactive_ops object at 0x15fc1f950>)

How to justify the column labels.

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 0x15fe4ded0>)

Maximum number of rows to display.

max_cols = param.Integer(allow_None=True, allow_refs=False, inclusive_bounds=(True, True), label=’Max cols’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15fe680d0>)

Maximum number of columns to display.

na_rep = param.String(allow_refs=False, default=’NaN’, label=’Na rep’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15fc1f010>)

String representation of NAN to use.

render_links = param.Boolean(allow_refs=False, default=False, label=’Render links’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15fd79490>)

Convert URLs to HTML links.

show_dimensions = param.Boolean(allow_refs=False, default=False, label=’Show dimensions’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15f311d50>)

Display DataFrame dimensions (number of rows by number of columns).

sparsify = param.Boolean(allow_refs=False, default=True, label=’Sparsify’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15fd79490>)

Set to False for a DataFrame with a hierarchical index to print every multi-index key at each row.

text_align = param.Selector(allow_refs=False, label=’Text align’, names={}, nested_refs=False, objects=[‘start’, ‘end’, ‘center’], rx=<param.reactive.reactive_ops object at 0x15f311d50>)

Alignment of non-header cells.

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

Hidden parameter.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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.

priority: ClassVar[float | bool | None] = None#
save(filename: str | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.markup.HTML(object=None, **params)[source]#

Bases: HTMLBasePane

HTML panes renders HTML strings and objects with a _repr_html_ method.

The height and width can optionally be specified, to allow room for whatever is being wrapped.

Reference: https://panel.holoviz.org/reference/panes/HTML.html

Example:

>>> HTML(
...     "<h1>This is a HTML pane</h1>",
...     styles={'background-color': '#F6F6F6'}
... )

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

disable_math = param.Boolean(allow_refs=False, default=True, label=’Disable math’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15fddba90>)

Whether to disable support for MathJax math rendering for strings escaped with $$ delimiters.

sanitize_html = param.Boolean(allow_refs=False, default=False, label=’Sanitize html’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15fe7d610>)

Whether to sanitize HTML sent to the frontend.

sanitize_hook = param.Callable(allow_refs=False, label=’Sanitize hook’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15fddbe50>)

Sanitization callback to apply if sanitize_html=True.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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.

priority: ClassVar[float | bool | None] = None#
save(filename: str | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.markup.HTMLBasePane(object=None, **params)[source]#

Bases: ModelPane

Baseclass for Panes which render HTML inside a Bokeh Div. See the documentation for Bokeh Div for more detail about the supported options like style and sizing_mode.

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

enable_streaming = param.Boolean(allow_refs=False, default=False, label=’Enable streaming’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15fe90510>)

Whether to enable streaming of text snippets. This is useful when updating a string step by step, e.g. in a chat message.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.markup.JSON(object=None, **params)[source]#

Bases: HTMLBasePane

The JSON pane allows rendering arbitrary JSON strings, dicts and other json serializable objects in a panel.

Reference: https://panel.holoviz.org/reference/panes/JSON.html

Example:

>>> JSON(json_obj, theme='light', height=300, width=500)

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

depth = param.Integer(allow_refs=False, bounds=(-1, None), default=1, inclusive_bounds=(True, True), label=’Depth’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15fedc310>)

Depth to which the JSON tree will be expanded on initialization.

encoder = param.ClassSelector(allow_None=True, allow_refs=False, class_=<class ‘json.encoder.JSONEncoder’>, label=’Encoder’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15fedddd0>)

Custom JSONEncoder class used to serialize objects to JSON string.

hover_preview = param.Boolean(allow_refs=False, default=False, label=’Hover preview’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15feca790>)

Whether to display a hover preview for collapsed nodes.

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

Whether the JSON tree view is expanded by default.

classmethod applies(obj: Any, **params) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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.

priority: ClassVar[float | bool | None] = None#
save(filename: str | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.markup.Markdown(object=None, **params)[source]#

Bases: HTMLBasePane

The Markdown pane allows rendering arbitrary markdown strings in a panel.

It renders strings containing valid Markdown as well as objects with a _repr_markdown_ method, and may define custom CSS styles.

Reference: https://panel.holoviz.org/reference/panes/Markdown.html

Example:

>>> Markdown("# This is a header")

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

dedent = param.Boolean(allow_refs=False, default=True, label=’Dedent’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15fed1610>)

Whether to dedent common whitespace across all lines.

disable_math = param.Boolean(allow_refs=False, default=False, label=’Disable math’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15fef18d0>)

Whether to disable support for MathJax math rendering for strings escaped with $$ delimiters.

extensions = param.List(allow_refs=False, bounds=(0, None), default=[‘extra’, ‘smarty’, ‘codehilite’], label=’Extensions’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x15fef1a50>)

Markdown extension to apply when transforming markup. Does not apply if renderer is set to ‘markdown-it’ or ‘myst’.

plugins = param.List(allow_refs=False, bounds=(0, None), default=[], label=’Plugins’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x15fef1c10>)

Additional markdown-it-py plugins to use.

renderer = param.Selector(allow_refs=False, default=’markdown-it’, label=’Renderer’, names={}, nested_refs=False, objects=[‘markdown-it’, ‘myst’, ‘markdown’], rx=<param.reactive.reactive_ops object at 0x15fef1a50>)

Markdown renderer implementation.

renderer_options = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Renderer options’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x15fef1850>)

Options to pass to the markdown renderer.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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.

priority: ClassVar[float | bool | None] = None#
save(filename: str | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.markup.Str(object=None, **params)[source]#

Bases: HTMLBasePane

The Str pane allows rendering arbitrary text and objects in a panel.

Unlike Markdown and HTML, a Str is interpreted as a raw string without applying any markup and is displayed in a fixed-width font by default.

The pane will render any text, and if given an object will display the object’s Python repr.

Reference: https://panel.holoviz.org/reference/panes/Str.html

Example:

>>> Str(
...    'This raw string will not be formatted, except for the applied style.',
...    styles={'font-size': '12pt'}
... )

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

classmethod applies(obj: Any) bool[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)


media Module#

Contains Media panes including renderers for Audio and Video content.

class panel.pane.media.Audio(object=None, **params)[source]#

Bases: _MediaBase

The Audio pane displays an audio player given a local or remote audio file, a NumPy Array or Torch Tensor.

The pane also allows access and control over the player state including toggling of playing/paused and loop state, the current time, and the volume.

The audio player supports ogg, mp3, and wav files

If SciPy is installed, 1-dim Numpy Arrays and 1-dim Torch Tensors are also supported. The dtype must be one of the following

  • numpy: np.int16, np.uint16, np.float32, np.float64

  • torch: torch.short, torch.int16, torch.half, torch.float16, torch.float, torch.float32,

torch.double, torch.float64

The array or Tensor input will be downsampled to 16bit and converted to a wav file by SciPy.

Reference: https://panel.holoviz.org/reference/panes/Audio.html

Example:

>>> Audio('http://ccrma.stanford.edu/~jos/mp3/pno-cs.mp3', name='Audio')

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout

panel.pane.media._MediaBase: loop, time, throttle, paused, volume, autoplay, muted

object = param.ClassSelector(allow_None=True, allow_refs=True, class_=(<class ‘str’>, <class ‘numpy.ndarray’>, <class ‘panel.pane.media.TensorLike’>), default=’’, label=’Object’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1603e4290>)

The audio file either local or remote, a 1-dim NumPy ndarray or a 1-dim Torch Tensor.

sample_rate = param.Integer(allow_refs=False, default=44100, inclusive_bounds=(True, True), label=’Sample rate’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x16095e750>)

The sample_rate of the audio when given a NumPy array or Torch tensor.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.media.TensorLike[source]#

Bases: object

A class similar to torch.Tensor. We don’t want to make PyTorch a dependency of this project

class panel.pane.media.TensorLikeMeta[source]#

Bases: type

See https://blog.finxter.com/python-__instancecheck__-magic-method/

mro()#

Return a type’s method resolution order.

class panel.pane.media.Video(object=None, **params)[source]#

Bases: _MediaBase

The Video Pane displays a video player given a local or remote video file.

The widget also allows access and control over the player state including toggling of playing/paused and loop state, the current time, and the volume.

Depending on the browser the video player supports mp4, webm, and ogg containers and a variety of codecs.

Reference: https://panel.holoviz.org/reference/panes/Video.html

Example:

>>> Video(
...     'https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_640_3MG.mp4',
...     width=640, height=360, loop=True
... )

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout

panel.pane.media._MediaBase: object, loop, time, throttle, paused, autoplay, muted

volume = param.Integer(allow_refs=False, bounds=(0, 100), default=100, inclusive_bounds=(True, True), label=’Volume’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x160937750>)

The volume of the media player.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)


perspective Module#

class panel.pane.perspective.Perspective(object=None, **params)[source]#

Bases: ModelPane, ReactiveData

The Perspective pane provides an interactive visualization component for large, real-time datasets built on the Perspective project.

Reference: https://panel.holoviz.org/reference/panes/Perspective.html

Example:

>>> Perspective(df, plugin='hypergrid', theme='pro-dark')

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.reactive.SyncableData: selection

panel.pane.base.PaneBase: margin, default_layout

min_width = param.Integer(allow_refs=False, bounds=(0, None), default=420, inclusive_bounds=(True, True), label=’Min width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x160ccfc90>)

Minimal width of the component (in pixels) if width is adjustable.

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

The plot data declared as a dictionary of arrays or a DataFrame.

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

How to aggregate. For example {“x”: “distinct count”}

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

A list of source columns to show as columns. For example [“x”, “y”]

columns_config = param.Dict(allow_None=True, allow_refs=False, class_=<class ‘dict’>, label=’Columns config’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x160ccf9d0>)

Column configuration allowing specification of formatters, coloring and a variety of other attributes for each column.

editable = param.Boolean(allow_None=True, allow_refs=False, default=True, label=’Editable’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x16094a910>)

Whether items are editable.

expressions = param.ClassSelector(allow_None=True, allow_refs=False, class_=(<class ‘dict’>, <class ‘list’>), label=’Expressions’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x160cced90>)

A list of expressions computing new columns from existing columns. For example [“”x”+”index””]

split_by = param.List(allow_None=True, allow_refs=False, bounds=(0, None), label=’Split by’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x160cbd210>)

A list of source columns to pivot by. For example [“x”, “y”]

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

How to filter. For example [[“x”, “<”, 3],[“y”, “contains”, “abc”]]

group_by = param.List(allow_None=True, allow_refs=False, bounds=(0, None), label=’Group by’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x160cbd210>)

A list of source columns to group by. For example [“x”, “y”]

selectable = param.Boolean(allow_None=True, allow_refs=False, default=True, label=’Selectable’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x160ccef90>)

Whether items are selectable.

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

How to sort. For example[[“x”,”desc”]]

plugin = param.ObjectSelector(allow_refs=False, default=’datagrid’, label=’Plugin’, names={}, nested_refs=False, objects=[‘hypergrid’, ‘datagrid’, ‘d3_y_bar’, ‘d3_x_bar’, ‘d3_xy_line’, ‘d3_y_line’, ‘d3_y_area’, ‘d3_y_scatter’, ‘d3_xy_scatter’, ‘d3_treemap’, ‘d3_sunburst’, ‘d3_heatmap’, ‘d3_candlestick’, ‘d3_ohlc’], rx=<param.reactive.reactive_ops object at 0x1609cf950>)

The name of a plugin to display the data. For example hypergrid or d3_xy_scatter.

plugin_config = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Plugin config’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x160cbd210>)

Configuration for the PerspectiveViewerPlugin.

settings = param.Boolean(allow_refs=False, default=True, label=’Settings’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x160ccef10>)

Whether to show the settings menu.

theme = param.ObjectSelector(allow_refs=False, default=’pro’, label=’Theme’, names={}, nested_refs=False, objects=[‘material’, ‘material-dark’, ‘monokai’, ‘solarized’, ‘solarized-dark’, ‘vaporwave’, ‘pro’, ‘pro-dark’], rx=<param.reactive.reactive_ops object at 0x160ccf110>)

The style of the PerspectiveViewer. For example pro-dark

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

Title for the Perspective viewer.

classmethod applies(object)[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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

Register a callback to be executed when any row is clicked. The callback is given a PerspectiveClickEvent declaring the config, column names, and row values of the row that was clicked.

Arguments#

callback: (callable)

The callback to run on edit events.

patch(patch_value: 'pd.DataFrame' | 'pd.Series' | dict) None[source]#

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

Arguments#

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’]}

priority: ClassVar[float | bool | None] = None#
save(filename: str | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

stream(stream_value: 'pd.DataFrame' | 'pd.Series' | dict, rollover: int | None = None, reset_index: bool = True) None[source]#

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

Arguments#

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.

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”]}) >>> 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.pane.perspective.Plugin(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Bases: Enum

The plugins (grids/charts) available in Perspective. Pass these into the plugin arg in PerspectiveWidget or PerspectiveViewer.

static options()[source]#

Returns the list of options of the PerspectiveViewer, like Hypergrid, Grid etc.

Returns#

options: list

A list of available options

panel.pane.perspective.deconstruct_pandas(data, kwargs=None)[source]#

Given a dataframe, flatten it by resetting the index and memoizing the pivots that were applied.

This code was copied from the Perspective repository and is reproduced under Apache 2.0 license. See the original at:

finos/perspective

Arguments#

data: (pandas.dataframe)

A Pandas DataFrame to parse

Returns#

data: pandas.DataFrame

A flattened version of the DataFrame

kwargs: dict

A dictionary containing optional members columns, group_by, and split_by.


placeholder Module#

Defines the Placeholder pane which serves as a placeholder for other Panel components.

class panel.pane.placeholder.Placeholder(object=None, **params)[source]#

Bases: ReplacementPane

The Placeholder pane serves as a placeholder for other Panel components. It can be used to display a message while a computation is running, for example.

Reference: https://panel.holoviz.org/reference/panes/Placeholder.html

Example:

>>> with Placeholder("⏳ Idle"):
...     placeholder.object = "🏃 Running..."

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout

panel.pane.base.ReplacementPane: object, inplace, _pane

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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 | None = None) list[Viewable][source]#

Iterates over the Viewable and any potential children in the applying the Selector.

Arguments#

selector: (type | callable | None)

The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.

Returns#

viewables: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

update(object)[source]#

Updates the object on the Placeholder.

Arguments#

object: The object to update the Placeholder with.


plot Module#

Pane class which render plots from different libraries

class panel.pane.plot.Bokeh(object=None, **params)[source]#

Bases: Pane

The Bokeh pane allows displaying any displayable Bokeh model inside a Panel app.

Reference: https://panel.holoviz.org/reference/panes/Bokeh.html

Example:

>>> Bokeh(some_bokeh_figure)

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

autodispatch = param.Boolean(allow_refs=False, default=True, label=’Autodispatch’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x160951610>)

Whether to automatically dispatch events inside bokeh on_change and on_event callbacks in the notebook.

theme = param.ClassSelector(allow_None=True, allow_refs=False, class_=(<class ‘bokeh.themes.theme.Theme’>, <class ‘str’>), label=’Theme’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1610fcbd0>)

Bokeh theme to apply to the plot.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.plot.Folium(object=None, **params)[source]#

Bases: HTML

The Folium pane wraps Folium map components.

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

panel.pane.markup.HTML: disable_math, sanitize_html, sanitize_hook

sizing_mode = param.ObjectSelector(allow_refs=False, default=’stretch_width’, 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 0x16107d8d0>)

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.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.plot.Matplotlib(object=None, **params)[source]#

Bases: Image, IPyWidget

The Matplotlib pane allows displaying any displayable Matplotlib figure inside a Panel app.

  • It will render the plot to PNG at the declared DPI and then embed it.

  • If you find the figure to be clipped on the edges, you can set tight=True

to automatically resize objects to fit within the pane. - If you have installed ipympl you will also be able to use the interactive backend.

Reference: https://panel.holoviz.org/reference/panes/Matplotlib.html

Example:

>>> Matplotlib(some_matplotlib_figure, dpi=144)

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout

panel.pane.markup.HTMLBasePane: enable_streaming

panel.pane.image.FileBase: embed

panel.pane.image.ImageBase: alt_text, caption, fixed_aspect, link_url

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

The Matplotlib Figure being wrapped, which will be rendered as a Bokeh model.

dpi = param.Integer(allow_refs=False, bounds=(1, None), default=144, inclusive_bounds=(True, True), label=’Dpi’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x161120fd0>)

Scales the dpi of the matplotlib figure.

encode = param.Boolean(allow_refs=False, default=False, label=’Encode’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x16112f310>)

Whether to encode SVG out as base64.

format = param.Selector(allow_refs=False, default=’png’, label=’Format’, names={}, nested_refs=False, objects=[‘png’, ‘svg’], rx=<param.reactive.reactive_ops object at 0x161120810>)

The format to render the plot as if the plot is not interactive.

high_dpi = param.Boolean(allow_refs=False, default=True, label=’High dpi’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x16112f310>)

Whether to optimize output for high-dpi displays.

interactive = param.Boolean(allow_refs=False, constant=True, default=False, label=’Interactive’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x161120690>)

Whether to render interactive matplotlib plot with ipympl.

tight = param.Boolean(allow_refs=False, default=False, label=’Tight’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x16112f310>)

Automatically adjust the figure size to fit the subplots and other artist elements.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.plot.RGGPlot(object=None, **params)[source]#

Bases: PNG

An RGGPlot pane renders an r2py-based ggplot2 figure to png and wraps the base64-encoded data in a bokeh Div model.

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.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

panel.pane.image.FileBase: embed

panel.pane.image.ImageBase: alt_text, caption, fixed_aspect, link_url

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

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=400, inclusive_bounds=(True, True), label=’Width’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x16113dfd0>)

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

dpi = param.Integer(allow_refs=False, bounds=(1, None), default=144, inclusive_bounds=(True, True), label=’Dpi’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x16113c110>)

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.plot.YT(object=None, **params)[source]#

Bases: HTML

YT panes wrap plottable objects from the YT library. By default, the height and width are calculated by summing all contained plots, but can optionally be specified explicitly to provide additional space.

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.markup.HTMLBasePane: enable_streaming

panel.pane.markup.HTML: disable_math, sanitize_html, sanitize_hook

classmethod applies(obj: bool) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)


plotly Module#

Defines a PlotlyPane which renders a plotly plot using PlotlyPlot bokeh model.

class panel.pane.plotly.Plotly(object=None, **params)[source]#

Bases: ModelPane

The Plotly pane renders Plotly plots inside a panel.

Note that

  • the Panel extension has to be loaded with plotly as an argument to

ensure that Plotly.js is initialized. - it supports click, hover and selection events. - it optimizes the plot rendering by using binary serialization for any array data found on the Plotly object.

Reference: https://panel.holoviz.org/reference/panes/Plotly.html

Example:

>>> pn.extension('plotly')
>>> Plotly(some_plotly_figure, width=500, height=500)

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

click_data = param.Dict(allow_None=True, allow_refs=False, class_=<class ‘dict’>, label=’Click data’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x161624290>)

Click event data from plotly_click event.

clickannotation_data = param.Dict(allow_None=True, allow_refs=False, class_=<class ‘dict’>, label=’Clickannotation data’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x16196f250>)

Clickannotation event data from plotly_clickannotation event.

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

Plotly configuration options. See https://plotly.com/javascript/configuration-options/

hover_data = param.Dict(allow_None=True, allow_refs=False, class_=<class ‘dict’>, label=’Hover data’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x16196f250>)

Hover event data from plotly_hover and plotly_unhover events.

link_figure = param.Boolean(allow_refs=False, default=True, label=’Link figure’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x16196d610>)

Attach callbacks to the Plotly figure to update output when it is modified in place.

relayout_data = param.Dict(allow_None=True, allow_refs=False, class_=<class ‘dict’>, label=’Relayout data’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x16196f490>)

Relayout event data from plotly_relayout event

restyle_data = param.List(allow_refs=False, bounds=(0, None), default=[], label=’Restyle data’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x16196f410>)

Restyle event data from plotly_restyle event

selected_data = param.Dict(allow_None=True, allow_refs=False, class_=<class ‘dict’>, label=’Selected data’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x16196d990>)

Selected event data from plotly_selected and plotly_deselect events.

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

Current viewport state, i.e. the x- and y-axis limits of the displayed plot. Updated on plotly_relayout, plotly_relayouting and plotly_restyle events.

viewport_update_policy = param.Selector(allow_refs=False, default=’mouseup’, label=’Viewport update policy’, names={}, nested_refs=False, objects=[‘mouseup’, ‘continuous’, ‘throttle’], rx=<param.reactive.reactive_ops object at 0x16196ecd0>)

Policy by which the viewport parameter is updated during user interactions. * “mouseup”: updates are synchronized when mouse button is released after panning * “continuous”: updates are synchronized continually while panning * “throttle”: updates are synchronized while panning, at intervals determined by the viewport_update_throttle parameter

viewport_update_throttle = param.Integer(allow_refs=False, bounds=(0, None), default=200, inclusive_bounds=(True, True), label=’Viewport update throttle’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x16196f350>)

Time interval in milliseconds at which viewport updates are synchronized when viewport_update_policy is “throttle”.

_render_count = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’ render count’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x16196f7d0>)

Number of renders, increment to trigger re-render

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)


streamz Module#

Renders Streamz Stream objects.

class panel.pane.streamz.Streamz(object=None, **params)[source]#

Bases: ReplacementPane

The Streamz pane renders streamz Stream objects emitting arbitrary objects, unlike the DataFrame pane which specifically handles streamz DataFrame and Series objects and exposes various formatting objects.

Reference: https://panel.holoviz.org/reference/panes/Streamz.html

Example:

>>> Streamz(some_streamz_stream_object, always_watch=True)

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout

panel.pane.base.ReplacementPane: object, inplace, _pane

always_watch = param.Boolean(allow_refs=False, default=False, label=’Always watch’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x161b3a6d0>)

Whether to watch even when not displayed.

rate_limit = param.Number(allow_refs=False, bounds=(0, None), default=0.1, inclusive_bounds=(True, True), label=’Rate limit’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x161b07b90>)

The minimum interval between events.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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 | None = None) list[Viewable][source]#

Iterates over the Viewable and any potential children in the applying the Selector.

Arguments#

selector: (type | callable | None)

The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.

Returns#

viewables: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)


textual Module#

class panel.pane.textual.Textual(object=None, **params)[source]#

Bases: Pane

The Textual pane provides a wrapper around a Textual App component, rendering it inside a Terminal and running it on the existing Panel event loop, i.e. either on the server or the notebook asyncio.EventLoop.

Reference: https://panel.holoviz.org/reference/panes/Textual.html

Example:

>>> Textual(app)

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

classmethod applies(object)[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)


vega Module#

class panel.pane.vega.Vega(object=None, **params)[source]#

Bases: ModelPane

The Vega pane renders Vega-lite based plots (including those from Altair) inside a panel.

Note

  • to use the Vega pane, the Panel extension has to be

loaded with ‘vega’ as an argument to ensure that vega.js is initialized. - it supports selection events - it optimizes the plot rendering by using binary serialization for any array data found on the Vega/Altair object, providing huge speedups over the standard JSON serialization employed by Vega natively.

Reference: https://panel.holoviz.org/reference/panes/Vega.html

Example:

>>> pn.extension('vega')
>>> Vega(some_vegalite_dict_or_altair_object, height=240)

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

debounce = param.ClassSelector(allow_refs=False, class_=(<class ‘int’>, <class ‘dict’>), default=20, label=’Debounce’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x161d26790>)

Declares the debounce time in milliseconds either for all events or if a dictionary is provided for individual events.

selection = param.ClassSelector(allow_None=True, allow_refs=False, class_=<class ‘param.parameterized.Parameterized’>, label=’Selection’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x161ef00d0>)

The Selection object reflects any selections available on the supplied vega plot into Python.

show_actions = param.Boolean(allow_refs=False, default=False, label=’Show actions’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x161d261d0>)

Whether to show Vega actions.

theme = param.ObjectSelector(allow_None=True, allow_refs=False, label=’Theme’, names={}, nested_refs=False, objects=[‘excel’, ‘ggplot2’, ‘quartz’, ‘vox’, ‘fivethirtyeight’, ‘dark’, ‘latimes’, ‘urbaninstitute’, ‘googlecharts’], rx=<param.reactive.reactive_ops object at 0x161497950>)

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

panel.pane.vega.ds_as_cds(dataset)[source]#

Converts Vega dataset into Bokeh ColumnDataSource data


vizzu Module#

class panel.pane.vizzu.Vizzu(object=None, **params)[source]#

Bases: ModelPane, SyncableData

The Vizzu pane provides an interactive visualization component for large, real-time datasets built on the Vizzu project.

Reference: https://panel.holoviz.org/reference/panes/Vizzu.html

Example:

>>> Vizzu(df)

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.reactive.SyncableData: selection

panel.pane.base.PaneBase: margin, default_layout, object

animation = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Animation’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x16206c290>)

Animation settings (see https://lib.vizzuhq.com/latest/reference/modules/Anim/).

config = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Config’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x1620c6210>)

The config contains all of the parameters needed to render a particular static chart or a state of an animated chart (see https://lib.vizzuhq.com/latest/reference/interfaces/Config.Chart/).

click = param.Parameter(allow_None=True, allow_refs=False, label=’Click’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1620c4210>)

Data associated with the latest click event.

column_types = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Column types’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x1620c6150>)

Optional column definitions. If not defined will be inferred from the data.

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

The config contains all of the parameters needed to render a particular static chart or a state of an animated chart.

style = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Style’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x1620c4610>)

Style configuration of the chart.

tooltip = param.Boolean(allow_refs=False, default=False, label=’Tooltip’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x16206c290>)

Whether to enable tooltips on the chart.

animate(anim: dict[str, Any], options: int | dict[str, Any] | None = None) None[source]#

Updates the chart with a new configuration.

classmethod applies(object)[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[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.

Arguments#

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.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = 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.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

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.

Arguments#

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: Callback

The Callback which can be used to disable the 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.

Arguments#

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: GenericLink

The GenericLink which can be used unlink the widget and the target model.

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.

Arguments#

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

Register a callback to be executed when any element in the chart is clicked on.

Arguments#

callback: (callable)

The callback to run on click events.

patch(patch_value: 'pd.DataFrame' | 'pd.Series' | dict) None[source]#

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

Arguments#

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 | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | 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: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

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.

Arguments#

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: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean 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.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = 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.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

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

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

stream(stream_value: 'pd.DataFrame' | 'pd.Series' | dict, rollover: int | None = None, reset_index: bool = True) None[source]#

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

Arguments#

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.

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”]}) >>> 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’]}


Subpackages#