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#
Define your Python objects
>>> some_python_object = ...
>>> another_python_object = ...
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, background, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.pane.base.PaneBase
: margin, default_layout, objectpanel.pane.markup.Markdown
: dedent, disable_math, extensions, plugins, rendereralert_type
= param.ObjectSelector(default=’primary’, label=’Alert type’, objects=[‘primary’, ‘secondary’, ‘success’, ‘danger’, ‘warning’, ‘info’, ‘light’, ‘dark’])- app(notebook_url: str = 'localhost:8888', port: int = 0) Server #
Displays a bokeh server app inline in the notebook.
- Parameters:
notebook_url (str) – URL to the notebook server
port (int (optional, default=0)) – Allows specifying a specific port
- classmethod applies(obj: Any) float | bool | None [source]#
Returns boolean or float indicating whether the Pane can render the object.
If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.
- clone(object: Optional[Any] = None, **params) T #
Makes a copy of the Pane sharing the same parameters.
- Parameters:
object (Optional new object to render) –
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned Pane object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel #
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None #
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- Parameters:
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for JSON filename
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=False)) – Whether to report progress
states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
- classmethod get_pane_type(obj: Any, **kwargs) Type[PaneBase] #
Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.
- Parameters:
(object) (obj) –
- Return type:
The applicable Pane type with the highest precedence.
- get_root(doc: Optional[Document] = None, comm: Comm | None = None, preprocess: bool = True) Model #
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.document.Document) – Optional Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (bool (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback #
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link #
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: param.Parameterized, callbacks: Optional[Dict[str, str | Callable]] = None, bidirectional: bool = False, **links: str) Watcher #
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- pprint() None #
Prints a compositional repr of the class.
- save(filename: str | os.PathLike | IO, title: Optional[str] = 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: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None #
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector: Optional[type | Callable[['Viewable'], bool]] = None) List['Viewable'] #
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin #
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document #
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) threading.Thread | 'Server' #
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or threading.Thread
- 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, background, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.pane.base.PaneBase
: margin, default_layoutpanel.pane.media._MediaBase
: loop, time, throttle, paused, volume, autoplay, mutedobject
= param.ClassSelector(allow_None=True, class_=(<class ‘str’>, <class ‘numpy.ndarray’>, <class ‘panel.pane.media.TensorLike’>), default=’’, label=’Object’)The audio file either local or remote, a 1-dim NumPy ndarray or a 1-dim Torch Tensor.
sample_rate
= param.Integer(default=44100, inclusive_bounds=(True, True), label=’Sample rate’)The sample_rate of the audio when given a NumPy array or Torch tensor.
- app(notebook_url: str = 'localhost:8888', port: int = 0) Server #
Displays a bokeh server app inline in the notebook.
- Parameters:
notebook_url (str) – URL to the notebook server
port (int (optional, default=0)) – Allows specifying a specific port
- classmethod applies(obj: Any) float | bool | None [source]#
Returns boolean or float indicating whether the Pane can render the object.
If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.
- clone(object: Optional[Any] = None, **params) T #
Makes a copy of the Pane sharing the same parameters.
- Parameters:
object (Optional new object to render) –
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned Pane object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel #
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None #
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- Parameters:
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for JSON filename
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=False)) – Whether to report progress
states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
- classmethod get_pane_type(obj: Any, **kwargs) Type[PaneBase] #
Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.
- Parameters:
(object) (obj) –
- Return type:
The applicable Pane type with the highest precedence.
- get_root(doc: Optional[Document] = None, comm: Comm | None = None, preprocess: bool = True) Model #
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.document.Document) – Optional Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (bool (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback #
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link #
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: param.Parameterized, callbacks: Optional[Dict[str, str | Callable]] = None, bidirectional: bool = False, **links: str) Watcher #
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- pprint() None #
Prints a compositional repr of the class.
- save(filename: str | os.PathLike | IO, title: Optional[str] = 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: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None #
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector: Optional[type | Callable[['Viewable'], bool]] = None) List['Viewable'] #
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin #
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document #
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) threading.Thread | 'Server' #
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or threading.Thread
- class panel.pane.Bokeh(object=None, **params)[source]#
Bases:
PaneBase
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, background, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.pane.base.PaneBase
: margin, default_layout, objectautodispatch
= param.Boolean(bounds=(0, 1), default=True, label=’Autodispatch’)Whether to automatically dispatch events inside bokeh on_change and on_event callbacks in the notebook.
theme
= param.ClassSelector(allow_None=True, class_=(<class ‘bokeh.themes.theme.Theme’>, <class ‘str’>), label=’Theme’)Bokeh theme to apply to the plot.
- app(notebook_url: str = 'localhost:8888', port: int = 0) Server #
Displays a bokeh server app inline in the notebook.
- Parameters:
notebook_url (str) – URL to the notebook server
port (int (optional, default=0)) – Allows specifying a specific port
- classmethod applies(obj: Any) float | bool | None [source]#
Returns boolean or float indicating whether the Pane can render the object.
If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.
- clone(object: Optional[Any] = None, **params) T #
Makes a copy of the Pane sharing the same parameters.
- Parameters:
object (Optional new object to render) –
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned Pane object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel #
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None #
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- Parameters:
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for JSON filename
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=False)) – Whether to report progress
states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
- classmethod get_pane_type(obj: Any, **kwargs) Type[PaneBase] #
Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.
- Parameters:
(object) (obj) –
- Return type:
The applicable Pane type with the highest precedence.
- get_root(doc: Optional[Document] = None, comm: Comm | None = None, preprocess: bool = True) Model #
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.document.Document) – Optional Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (bool (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback #
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link #
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: param.Parameterized, callbacks: Optional[Dict[str, str | Callable]] = None, bidirectional: bool = False, **links: str) Watcher #
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- pprint() None #
Prints a compositional repr of the class.
- save(filename: str | os.PathLike | IO, title: Optional[str] = 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: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None #
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector: Optional[type | Callable[['Viewable'], bool]] = None) List['Viewable'] #
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin #
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document #
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) threading.Thread | 'Server' #
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or threading.Thread
- 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, background, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.pane.base.PaneBase
: margin, default_layout, objectpanel.pane.markup.HTML
: disable_mathbold_rows
= param.Boolean(bounds=(0, 1), default=True, label=’Bold rows’)Make the row labels bold in the output.
border
= param.Integer(default=0, inclusive_bounds=(True, True), label=’Border’)A
border=border
attribute is included in the opening <table> tag.classes
= param.List(bounds=(0, None), default=[‘panel-df’], label=’Classes’)CSS class(es) to apply to the resulting html table.
col_space
= param.ClassSelector(allow_None=True, class_=(<class ‘str’>, <class ‘int’>, <class ‘dict’>), label=’Col space’)The minimum width of each column in CSS length units. An int is assumed to be px units.
decimal
= param.String(default=’.’, label=’Decimal’)Character recognized as decimal separator, e.g. ‘,’ in Europe.
escape
= param.Boolean(bounds=(0, 1), default=True, label=’Escape’)Whether or not to escape the dataframe HTML. For security reasons the default value is True.
float_format
= param.Callable(allow_None=True, label=’Float format’)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, class_=(<class ‘dict’>, <class ‘list’>), label=’Formatters’)Formatter functions to apply to columns’ elements by position or name. The result of each function must be a unicode string.
header
= param.Boolean(bounds=(0, 1), default=True, label=’Header’)Whether to print column labels.
index
= param.Boolean(bounds=(0, 1), default=True, label=’Index’)Whether to print index (row) labels.
index_names
= param.Boolean(bounds=(0, 1), default=True, label=’Index names’)Prints the names of the indexes.
justify
= param.ObjectSelector(allow_None=True, label=’Justify’, objects=[‘left’, ‘right’, ‘center’, ‘justify’, ‘justify-all’, ‘start’, ‘end’, ‘inherit’, ‘match-parent’, ‘initial’, ‘unset’])How to justify the column labels.
max_rows
= param.Integer(allow_None=True, inclusive_bounds=(True, True), label=’Max rows’)Maximum number of rows to display.
max_cols
= param.Integer(allow_None=True, inclusive_bounds=(True, True), label=’Max cols’)Maximum number of columns to display.
na_rep
= param.String(default=’NaN’, label=’Na rep’)String representation of NAN to use.
render_links
= param.Boolean(bounds=(0, 1), default=False, label=’Render links’)Convert URLs to HTML links.
show_dimensions
= param.Boolean(bounds=(0, 1), default=False, label=’Show dimensions’)Display DataFrame dimensions (number of rows by number of columns).
sparsify
= param.Boolean(bounds=(0, 1), default=True, label=’Sparsify’)Set to False for a DataFrame with a hierarchical index to print every multi-index key at each row.
_object
= param.Parameter(allow_None=True, label=’ object’)Hidden parameter.
- app(notebook_url: str = 'localhost:8888', port: int = 0) Server #
Displays a bokeh server app inline in the notebook.
- Parameters:
notebook_url (str) – URL to the notebook server
port (int (optional, default=0)) – Allows specifying a specific port
- classmethod applies(obj: Any) float | bool | None [source]#
Returns boolean or float indicating whether the Pane can render the object.
If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.
- clone(object: Optional[Any] = None, **params) T #
Makes a copy of the Pane sharing the same parameters.
- Parameters:
object (Optional new object to render) –
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned Pane object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel #
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None #
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- Parameters:
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for JSON filename
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=False)) – Whether to report progress
states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
- classmethod get_pane_type(obj: Any, **kwargs) Type[PaneBase] #
Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.
- Parameters:
(object) (obj) –
- Return type:
The applicable Pane type with the highest precedence.
- get_root(doc: Optional[Document] = None, comm: Comm | None = None, preprocess: bool = True) Model #
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.document.Document) – Optional Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (bool (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback #
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link #
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: param.Parameterized, callbacks: Optional[Dict[str, str | Callable]] = None, bidirectional: bool = False, **links: str) Watcher #
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- pprint() None #
Prints a compositional repr of the class.
- priority: ClassVar[float | bool | None] = None#
- save(filename: str | os.PathLike | IO, title: Optional[str] = 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: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None #
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector: Optional[type | Callable[['Viewable'], bool]] = None) List['Viewable'] #
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin #
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document #
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) threading.Thread | 'Server' #
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or threading.Thread
- 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, background, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.pane.base.PaneBase
: margin, default_layout, objectmapbox_api_key
= param.String(allow_None=True, label=’Mapbox api key’)The MapBox API key if not supplied by a PyDeck object.
tooltips
= param.ClassSelector(class_=(<class ‘bool’>, <class ‘dict’>), default=True, label=’Tooltips’)Whether to enable tooltips
click_state
= param.Dict(class_=<class ‘dict’>, default={}, label=’Click state’)Contains the last click event on the DeckGL plot.
hover_state
= param.Dict(class_=<class ‘dict’>, default={}, label=’Hover state’)The current hover state of the DeckGL plot.
view_state
= param.Dict(class_=<class ‘dict’>, default={}, label=’View state’)The current view state of the DeckGL plot.
throttle
= param.Dict(class_=<class ‘dict’>, default={‘view’: 200, ‘hover’: 200}, label=’Throttle’)Throttling timeout (in milliseconds) for view state and hover events sent from the frontend.
- app(notebook_url: str = 'localhost:8888', port: int = 0) Server #
Displays a bokeh server app inline in the notebook.
- Parameters:
notebook_url (str) – URL to the notebook server
port (int (optional, default=0)) – Allows specifying a specific port
- classmethod applies(obj: Any) float | bool | None [source]#
Returns boolean or float indicating whether the Pane can render the object.
If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.
- clone(object: Optional[Any] = None, **params) T #
Makes a copy of the Pane sharing the same parameters.
- Parameters:
object (Optional new object to render) –
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned Pane object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel #
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None #
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- Parameters:
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for JSON filename
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=False)) – Whether to report progress
states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
- classmethod get_pane_type(obj: Any, **kwargs) Type[PaneBase] #
Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.
- Parameters:
(object) (obj) –
- Return type:
The applicable Pane type with the highest precedence.
- get_root(doc: Optional[Document] = None, comm: Comm | None = None, preprocess: bool = True) Model #
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.document.Document) – Optional Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (bool (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback #
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link #
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: param.Parameterized, callbacks: Optional[Dict[str, str | Callable]] = None, bidirectional: bool = False, **links: str) Watcher #
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- pprint() None #
Prints a compositional repr of the class.
- priority: ClassVar[float | bool | None] = None#
- save(filename: str | os.PathLike | IO, title: Optional[str] = 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: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None #
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector: Optional[type | Callable[['Viewable'], bool]] = None) List['Viewable'] #
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin #
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document #
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) threading.Thread | 'Server' #
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or threading.Thread
- 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, background, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.pane.base.PaneBase
: margin, default_layoutobject
= param.Parameter(allow_None=True, label=’Object’)The Echarts object being wrapped. Can be an Echarts dictionary or a pyecharts chart
renderer
= param.ObjectSelector(default=’canvas’, label=’Renderer’, objects=[‘canvas’, ‘svg’])Whether to render as HTML canvas or SVG
theme
= param.ObjectSelector(default=’default’, label=’Theme’, objects=[‘default’, ‘light’, ‘dark’])Theme to apply to plots.
- app(notebook_url: str = 'localhost:8888', port: int = 0) Server #
Displays a bokeh server app inline in the notebook.
- Parameters:
notebook_url (str) – URL to the notebook server
port (int (optional, default=0)) – Allows specifying a specific port
- 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: Optional[Any] = None, **params) T #
Makes a copy of the Pane sharing the same parameters.
- Parameters:
object (Optional new object to render) –
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned Pane object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel #
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None #
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- Parameters:
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for JSON filename
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=False)) – Whether to report progress
states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
- classmethod get_pane_type(obj: Any, **kwargs) Type[PaneBase] #
Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.
- Parameters:
(object) (obj) –
- Return type:
The applicable Pane type with the highest precedence.
- get_root(doc: Optional[Document] = None, comm: Comm | None = None, preprocess: bool = True) Model #
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.document.Document) – Optional Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (bool (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- 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/
- Parameters:
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 #
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link #
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: param.Parameterized, callbacks: Optional[Dict[str, str | Callable]] = None, bidirectional: bool = False, **links: str) Watcher #
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- on_event(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/
- Parameters:
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.
- pprint() None #
Prints a compositional repr of the class.
- priority: ClassVar[float | bool | None] = None#
- save(filename: str | os.PathLike | IO, title: Optional[str] = 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: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None #
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector: Optional[type | Callable[['Viewable'], bool]] = None) List['Viewable'] #
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin #
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document #
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) threading.Thread | 'Server' #
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or threading.Thread
- 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, background, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.pane.base.PaneBase
: margin, default_layout, objectpanel.pane.image.FileBase
: embedpanel.pane.image.ImageBase
: alt_text, fixed_aspect, link_url- app(notebook_url: str = 'localhost:8888', port: int = 0) Server #
Displays a bokeh server app inline in the notebook.
- Parameters:
notebook_url (str) – URL to the notebook server
port (int (optional, default=0)) – Allows specifying a specific port
- classmethod applies(obj: Any) float | bool | None #
Returns boolean or float indicating whether the Pane can render the object.
If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.
- clone(object: Optional[Any] = None, **params) T #
Makes a copy of the Pane sharing the same parameters.
- Parameters:
object (Optional new object to render) –
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned Pane object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel #
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- classmethod get_pane_type(obj: Any, **kwargs) Type[PaneBase] #
Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.
- Parameters:
(object) (obj) –
- Return type:
The applicable Pane type with the highest precedence.
- get_root(doc: Optional[Document] = None, comm: Comm | None = None, preprocess: bool = True) Model #
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.document.Document) – Optional Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (bool (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback #
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link #
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: param.Parameterized, callbacks: Optional[Dict[str, str | Callable]] = None, bidirectional: bool = False, **links: str) Watcher #
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- pprint() None #
Prints a compositional repr of the class.
- save(filename: str | os.PathLike | IO, title: Optional[str] = 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: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None #
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector: Optional[type | Callable[['Viewable'], bool]] = None) List['Viewable'] #
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin #
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document #
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) threading.Thread | 'Server' #
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or threading.Thread
- 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, background, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.pane.base.PaneBase
: margin, default_layout, objectdisable_math
= param.Boolean(bounds=(0, 1), default=True, label=’Disable math’)Whether to disable support for MathJax math rendering for strings escaped with $$ delimiters.
- app(notebook_url: str = 'localhost:8888', port: int = 0) Server #
Displays a bokeh server app inline in the notebook.
- Parameters:
notebook_url (str) – URL to the notebook server
port (int (optional, default=0)) – Allows specifying a specific port
- classmethod applies(obj: Any) float | bool | None [source]#
Returns boolean or float indicating whether the Pane can render the object.
If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.
- clone(object: Optional[Any] = None, **params) T #
Makes a copy of the Pane sharing the same parameters.
- Parameters:
object (Optional new object to render) –
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned Pane object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel #
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None #
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- Parameters:
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for JSON filename
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=False)) – Whether to report progress
states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
- classmethod get_pane_type(obj: Any, **kwargs) Type[PaneBase] #
Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.
- Parameters:
(object) (obj) –
- Return type:
The applicable Pane type with the highest precedence.
- get_root(doc: Optional[Document] = None, comm: Comm | None = None, preprocess: bool = True) Model #
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.document.Document) – Optional Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (bool (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback #
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link #
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: param.Parameterized, callbacks: Optional[Dict[str, str | Callable]] = None, bidirectional: bool = False, **links: str) Watcher #
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- pprint() None #
Prints a compositional repr of the class.
- priority: ClassVar[float | bool | None] = None#
- save(filename: str | os.PathLike | IO, title: Optional[str] = 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: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None #
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector: Optional[type | Callable[['Viewable'], bool]] = None) List['Viewable'] #
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin #
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document #
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) threading.Thread | 'Server' #
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or threading.Thread
- class panel.pane.HoloViews(object=None, **params)[source]#
Bases:
PaneBase
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, background, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.pane.base.PaneBase
: margin, default_layout, objectbackend
= param.ObjectSelector(label=’Backend’, objects=[‘bokeh’, ‘plotly’, ‘matplotlib’])The HoloViews backend used to render the plot (if None defaults to the currently selected renderer).
center
= param.Boolean(bounds=(0, 1), default=False, label=’Center’)Whether to center the plot.
linked_axes
= param.Boolean(bounds=(0, 1), default=True, label=’Linked axes’)Whether to link the axes of bokeh plots inside this pane across a panel layout.
renderer
= param.Parameter(allow_None=True, label=’Renderer’)Explicit renderer instance to use for rendering the HoloViews plot. Overrides the backend.
theme
= param.ClassSelector(allow_None=True, class_=(<class ‘bokeh.themes.theme.Theme’>, <class ‘str’>), label=’Theme’)Bokeh theme to apply to the HoloViews plot.
widget_location
= param.ObjectSelector(default=’right_top’, label=’Widget location’, objects=[‘left’, ‘bottom’, ‘right’, ‘top’, ‘top_left’, ‘top_right’, ‘bottom_left’, ‘bottom_right’, ‘left_top’, ‘left_bottom’, ‘right_top’, ‘right_bottom’])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(constant=True, default=<class ‘panel.layout.base.WidgetBox’>, label=’Widget layout’, objects=[<class ‘panel.layout.base.WidgetBox’>, <class ‘panel.layout.base.Row’>, <class ‘panel.layout.base.Column’>])The layout object to display the widgets in.
widget_type
= param.ObjectSelector(default=’individual’, label=’Widget type’, objects=[‘individual’, ‘scrubber’])) Whether to generate individual widgets for each dimension or on global scrubber.
widgets
= param.Dict(class_=<class ‘dict’>, default={}, label=’Widgets’)A mapping from dimension name to a widget instance which will be used to override the default widgets.
- app(notebook_url: str = 'localhost:8888', port: int = 0) Server #
Displays a bokeh server app inline in the notebook.
- Parameters:
notebook_url (str) – URL to the notebook server
port (int (optional, default=0)) – Allows specifying a specific port
- classmethod applies(obj: Any) float | bool | None [source]#
Returns boolean or float indicating whether the Pane can render the object.
If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.
- clone(object: Optional[Any] = None, **params) T #
Makes a copy of the Pane sharing the same parameters.
- Parameters:
object (Optional new object to render) –
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned Pane object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel #
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None #
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- Parameters:
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for JSON filename
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=False)) – Whether to report progress
states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
- classmethod get_pane_type(obj: Any, **kwargs) Type[PaneBase] #
Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.
- Parameters:
(object) (obj) –
- Return type:
The applicable Pane type with the highest precedence.
- get_root(doc: Optional[Document] = None, comm: Comm | None = None, preprocess: bool = True) Model #
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.document.Document) – Optional Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (bool (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback #
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target, code=None, args=None, bidirectional=False, **links)[source]#
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: param.Parameterized, callbacks: Optional[Dict[str, str | Callable]] = None, bidirectional: bool = False, **links: str) Watcher #
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- pprint() None #
Prints a compositional repr of the class.
- save(filename: str | os.PathLike | IO, title: Optional[str] = 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: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None #
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector: Optional[type | Callable[['Viewable'], bool]] = None) List['Viewable'] #
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin #
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document #
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) threading.Thread | 'Server' #
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or threading.Thread
- 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, background, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.pane.base.PaneBase
: margin, default_layout, objectpanel.pane.image.FileBase
: embedpanel.pane.image.ImageBase
: alt_text, fixed_aspect, link_url- app(notebook_url: str = 'localhost:8888', port: int = 0) Server #
Displays a bokeh server app inline in the notebook.
- Parameters:
notebook_url (str) – URL to the notebook server
port (int (optional, default=0)) – Allows specifying a specific port
- classmethod applies(obj: Any) float | bool | None #
Returns boolean or float indicating whether the Pane can render the object.
If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.
- clone(object: Optional[Any] = None, **params) T #
Makes a copy of the Pane sharing the same parameters.
- Parameters:
object (Optional new object to render) –
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned Pane object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel #
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- classmethod get_pane_type(obj: Any, **kwargs) Type[PaneBase] #
Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.
- Parameters:
(object) (obj) –
- Return type:
The applicable Pane type with the highest precedence.
- get_root(doc: Optional[Document] = None, comm: Comm | None = None, preprocess: bool = True) Model #
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.document.Document) – Optional Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (bool (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback #
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link #
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: param.Parameterized, callbacks: Optional[Dict[str, str | Callable]] = None, bidirectional: bool = False, **links: str) Watcher #
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- pprint() None #
Prints a compositional repr of the class.
- save(filename: str | os.PathLike | IO, title: Optional[str] = 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: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None #
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector: Optional[type | Callable[['Viewable'], bool]] = None) List['Viewable'] #
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin #
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document #
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) threading.Thread | 'Server' #
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or threading.Thread
- class panel.pane.IPyLeaflet(object=None, **params)[source]#
Bases:
IPyWidget
Parameters inherited from:
panel.viewable.Layoutable
: align, aspect_ratio, background, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, visiblepanel.viewable.Viewable
: loadingpanel.pane.base.PaneBase
: margin, default_layout, objectsizing_mode
= param.ObjectSelector(default=’stretch_width’, label=’Sizing mode’, objects=[‘fixed’, ‘stretch_width’, ‘stretch_height’, ‘stretch_both’, ‘scale_width’, ‘scale_height’, ‘scale_both’, None])How the component should size itself. This is a high-level setting for maintaining width and height of the component. To gain more fine grained control over sizing, use
width_policy
,height_policy
andaspect_ratio
instead (those take precedence oversizing_mode
)."fixed"
Component is not responsive. It will retain its original width and height regardless of any subsequent browser window resize events."stretch_width"
Component will responsively resize to stretch to the available width, without maintaining any aspect ratio. The height of the component depends on the type of the component and may be fixed or fit to component’s contents."stretch_height"
Component will responsively resize to stretch to the available height, without maintaining any aspect ratio. The width of the component depends on the type of the component and may be fixed or fit to component’s contents."stretch_both"
Component is completely responsive, independently in width and height, and will occupy all the available horizontal and vertical space, even if this changes the aspect ratio of the component."scale_width"
Component will responsively resize to stretch to the available width, while maintaining the original or provided aspect ratio."scale_height"
Component will responsively resize to stretch to the available height, while maintaining the original or provided aspect ratio."scale_both"
Component will responsively resize to both the available width and height, while maintaining the original or provided aspect ratio.
- app(notebook_url: str = 'localhost:8888', port: int = 0) Server #
Displays a bokeh server app inline in the notebook.
- Parameters:
notebook_url (str) – URL to the notebook server
port (int (optional, default=0)) – Allows specifying a specific port
- classmethod applies(obj: Any) float | bool | None [source]#
Returns boolean or float indicating whether the Pane can render the object.
If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.
- clone(object: Optional[Any] = None, **params) T #
Makes a copy of the Pane sharing the same parameters.
- Parameters:
object (Optional new object to render) –
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned Pane object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel #
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None #
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- Parameters:
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for JSON filename
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=False)) – Whether to report progress
states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
- classmethod get_pane_type(obj: Any, **kwargs) Type[PaneBase] #
Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.
- Parameters:
(object) (obj) –
- Return type:
The applicable Pane type with the highest precedence.
- get_root(doc: Optional[Document] = None, comm: Comm | None = None, preprocess: bool = True) Model #
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.document.Document) – Optional Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (bool (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback #
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link #
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: param.Parameterized, callbacks: Optional[Dict[str, str | Callable]] = None, bidirectional: bool = False, **links: str) Watcher #
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- pprint() None #
Prints a compositional repr of the class.
- save(filename: str | os.PathLike | IO, title: Optional[str] = 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: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None #
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector: Optional[type | Callable[['Viewable'], bool]] = None) List['Viewable'] #
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin #
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document #
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) threading.Thread | 'Server' #
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or threading.Thread
- class panel.pane.IPyWidget(object=None, **params)[source]#
Bases:
PaneBase
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, background, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.pane.base.PaneBase
: margin, default_layout, object- app(notebook_url: str = 'localhost:8888', port: int = 0) Server #
Displays a bokeh server app inline in the notebook.
- Parameters:
notebook_url (str) – URL to the notebook server
port (int (optional, default=0)) – Allows specifying a specific port
- classmethod applies(obj: Any) float | bool | None [source]#
Returns boolean or float indicating whether the Pane can render the object.
If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.
- clone(object: Optional[Any] = None, **params) T #
Makes a copy of the Pane sharing the same parameters.
- Parameters:
object (Optional new object to render) –
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned Pane object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel #
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None #
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- Parameters:
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for JSON filename
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=False)) – Whether to report progress
states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
- classmethod get_pane_type(obj: Any, **kwargs) Type[PaneBase] #
Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.
- Parameters:
(object) (obj) –
- Return type:
The applicable Pane type with the highest precedence.
- get_root(doc: Optional[Document] = None, comm: Comm | None = None, preprocess: bool = True) Model #
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.document.Document) – Optional Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (bool (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback #
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link #
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: param.Parameterized, callbacks: Optional[Dict[str, str | Callable]] = None, bidirectional: bool = False, **links: str) Watcher #
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- pprint() None #
Prints a compositional repr of the class.
- save(filename: str | os.PathLike | IO, title: Optional[str] = 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: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None #
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector: Optional[type | Callable[['Viewable'], bool]] = None) List['Viewable'] #
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin #
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document #
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) threading.Thread | 'Server' #
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or threading.Thread
- class panel.pane.Interactive(object=None, **params)[source]#
Bases:
PaneBase
Parameters inherited from:
panel.viewable.Layoutable
: align, aspect_ratio, background, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.pane.base.PaneBase
: margin, default_layout, object- app(notebook_url: str = 'localhost:8888', port: int = 0) Server #
Displays a bokeh server app inline in the notebook.
- Parameters:
notebook_url (str) – URL to the notebook server
port (int (optional, default=0)) – Allows specifying a specific port
- 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: Optional[Any] = None, **params) T #
Makes a copy of the Pane sharing the same parameters.
- Parameters:
object (Optional new object to render) –
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned Pane object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel #
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None #
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- Parameters:
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for JSON filename
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=False)) – Whether to report progress
states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
- classmethod get_pane_type(obj: Any, **kwargs) Type[PaneBase] #
Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.
- Parameters:
(object) (obj) –
- Return type:
The applicable Pane type with the highest precedence.
- get_root(doc: Optional[Document] = None, comm: Comm | None = None, preprocess: bool = True) Model #
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.document.Document) – Optional Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (bool (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback #
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link #
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: param.Parameterized, callbacks: Optional[Dict[str, str | Callable]] = None, bidirectional: bool = False, **links: str) Watcher #
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- pprint() None #
Prints a compositional repr of the class.
- priority: ClassVar[float | bool | None] = None#
- save(filename: str | os.PathLike | IO, title: Optional[str] = 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: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None #
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector: Optional[type | Callable[['Viewable'], bool]] = None) List['Viewable'] #
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin #
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document #
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) threading.Thread | 'Server' #
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or threading.Thread
- 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, background, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.pane.base.PaneBase
: margin, default_layout, objectpanel.pane.image.FileBase
: embedpanel.pane.image.ImageBase
: alt_text, fixed_aspect, link_url- app(notebook_url: str = 'localhost:8888', port: int = 0) Server #
Displays a bokeh server app inline in the notebook.
- Parameters:
notebook_url (str) – URL to the notebook server
port (int (optional, default=0)) – Allows specifying a specific port
- classmethod applies(obj: Any) float | bool | None #
Returns boolean or float indicating whether the Pane can render the object.
If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.
- clone(object: Optional[Any] = None, **params) T #
Makes a copy of the Pane sharing the same parameters.
- Parameters:
object (Optional new object to render) –
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned Pane object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel #
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- classmethod get_pane_type(obj: Any, **kwargs) Type[PaneBase] #
Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.
- Parameters:
(object) (obj) –
- Return type:
The applicable Pane type with the highest precedence.
- get_root(doc: Optional[Document] = None, comm: Comm | None = None, preprocess: bool = True) Model #
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.document.Document) – Optional Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (bool (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback #
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link #
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: param.Parameterized, callbacks: Optional[Dict[str, str | Callable]] = None, bidirectional: bool = False, **links: str) Watcher #
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- pprint() None #
Prints a compositional repr of the class.
- save(filename: str | os.PathLike | IO, title: Optional[str] = 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: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None #
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector: Optional[type | Callable[['Viewable'], bool]] = None) List['Viewable'] #
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin #
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document #
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) threading.Thread | 'Server' #
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or threading.Thread
- 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, background, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.pane.base.PaneBase
: margin, default_layout, objectdepth
= param.Integer(bounds=(-1, None), default=1, inclusive_bounds=(True, True), label=’Depth’)Depth to which the JSON tree will be expanded on initialization.
encoder
= param.ClassSelector(allow_None=True, class_=<class ‘json.encoder.JSONEncoder’>, label=’Encoder’)Custom JSONEncoder class used to serialize objects to JSON string.
hover_preview
= param.Boolean(bounds=(0, 1), default=False, label=’Hover preview’)Whether to display a hover preview for collapsed nodes.
theme
= param.ObjectSelector(default=’dark’, label=’Theme’, objects=[‘light’, ‘dark’])Whether the JSON tree view is expanded by default.
- app(notebook_url: str = 'localhost:8888', port: int = 0) Server #
Displays a bokeh server app inline in the notebook.
- Parameters:
notebook_url (str) – URL to the notebook server
port (int (optional, default=0)) – Allows specifying a specific port
- 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: Optional[Any] = None, **params) T #
Makes a copy of the Pane sharing the same parameters.
- Parameters:
object (Optional new object to render) –
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned Pane object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel #
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None #
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- Parameters:
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for JSON filename
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=False)) – Whether to report progress
states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
- classmethod get_pane_type(obj: Any, **kwargs) Type[PaneBase] #
Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.
- Parameters:
(object) (obj) –
- Return type:
The applicable Pane type with the highest precedence.
- get_root(doc: Optional[Document] = None, comm: Comm | None = None, preprocess: bool = True) Model #
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.document.Document) – Optional Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (bool (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback #
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link #
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: param.Parameterized, callbacks: Optional[Dict[str, str | Callable]] = None, bidirectional: bool = False, **links: str) Watcher #
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- pprint() None #
Prints a compositional repr of the class.
- priority: ClassVar[float | bool | None] = None#
- save(filename: str | os.PathLike | IO, title: Optional[str] = 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: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None #
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector: Optional[type | Callable[['Viewable'], bool]] = None) List['Viewable'] #
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin #
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document #
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) threading.Thread | 'Server' #
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or threading.Thread
- class panel.pane.LaTeX(object=None, **params)[source]#
Bases:
ModelPane
The LaTeX pane allows rendering LaTeX equations. It uses either MathJax or KaTeX depending on the defined renderer.
By default it will use the renderer loaded in the extension (e.g. pn.extension(‘katex’)), defaulting to KaTeX.
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, background, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.pane.base.PaneBase
: margin, default_layout, objectrenderer
= param.ObjectSelector(allow_None=True, label=’Renderer’, objects=[‘katex’, ‘mathjax’])The JS renderer used to render the LaTeX expression.
- app(notebook_url: str = 'localhost:8888', port: int = 0) Server #
Displays a bokeh server app inline in the notebook.
- Parameters:
notebook_url (str) – URL to the notebook server
port (int (optional, default=0)) – Allows specifying a specific port
- classmethod applies(obj: Any) float | bool | None [source]#
Returns boolean or float indicating whether the Pane can render the object.
If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.
- clone(object: Optional[Any] = None, **params) T #
Makes a copy of the Pane sharing the same parameters.
- Parameters:
object (Optional new object to render) –
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned Pane object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel #
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None #
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- Parameters:
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for JSON filename
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=False)) – Whether to report progress
states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
- classmethod get_pane_type(obj: Any, **kwargs) Type[PaneBase] #
Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.
- Parameters:
(object) (obj) –
- Return type:
The applicable Pane type with the highest precedence.
- get_root(doc: Optional[Document] = None, comm: Comm | None = None, preprocess: bool = True) Model #
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.document.Document) – Optional Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (bool (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback #
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link #
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: param.Parameterized, callbacks: Optional[Dict[str, str | Callable]] = None, bidirectional: bool = False, **links: str) Watcher #
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- pprint() None #
Prints a compositional repr of the class.
- priority: ClassVar[float | bool | None] = None#
- save(filename: str | os.PathLike | IO, title: Optional[str] = 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: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None #
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector: Optional[type | Callable[['Viewable'], bool]] = None) List['Viewable'] #
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin #
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document #
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) threading.Thread | 'Server' #
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or threading.Thread
- 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, background, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.pane.base.PaneBase
: margin, default_layout, objectdedent
= param.Boolean(bounds=(0, 1), default=True, label=’Dedent’)Whether to dedent common whitespace across all lines.
disable_math
= param.Boolean(bounds=(0, 1), default=False, label=’Disable math’)Whether to disable support for MathJax math rendering for strings escaped with $$ delimiters.
extensions
= param.List(bounds=(0, None), default=[‘extra’, ‘smarty’, ‘codehilite’], label=’Extensions’)Markdown extension to apply when transforming markup. Does not apply if renderer is set to ‘markdown-it’ or ‘myst’.
plugins
= param.List(bounds=(0, None), default=[], label=’Plugins’)Additional markdown-it-py plugins to use.
renderer
= param.Selector(default=’markdown-it’, label=’Renderer’, objects=[‘markdown-it’, ‘myst’, ‘markdown’])Markdown renderer implementation.
- app(notebook_url: str = 'localhost:8888', port: int = 0) Server #
Displays a bokeh server app inline in the notebook.
- Parameters:
notebook_url (str) – URL to the notebook server
port (int (optional, default=0)) – Allows specifying a specific port
- classmethod applies(obj: Any) float | bool | None [source]#
Returns boolean or float indicating whether the Pane can render the object.
If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.
- clone(object: Optional[Any] = None, **params) T #
Makes a copy of the Pane sharing the same parameters.
- Parameters:
object (Optional new object to render) –
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned Pane object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel #
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) – An explicit list of parameters to return controls for.
jslink (bool) – Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) – Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None, progress: bool = False, states={}) None #
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- Parameters:
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for JSON filename
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=False)) – Whether to report progress
states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
- classmethod get_pane_type(obj: Any, **kwargs) Type[PaneBase] #
Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.
- Parameters:
(object) (obj) –
- Return type:
The applicable Pane type with the highest precedence.
- get_root(doc: Optional[Document] = None, comm: Comm | None = None, preprocess: bool = True) Model #
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.document.Document) – Optional Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (bool (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback #
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) – A mapping of objects to make available to the JS callback
**callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback – The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: Dict[str, str] = None, args: Optional[Dict] = None, bidirectional: bool = False, **links: str) Link #
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) – The target to link the value to.
code (dict) – Custom code which will be executed when the widget value changes.
args (dict) – A mapping of objects to make available to the JS callback
bidirectional (boolean) – Whether to link source and target bi-directionally
**links (dict) – A mapping between properties on the source model and the target model property to link it to.
- Returns:
link – The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: param.Parameterized, callbacks: Optional[Dict[str, str | Callable]] = None, bidirectional: bool = False, **links: str) Watcher #
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) – The target object of the link.
callbacks (dict | None) – Maps from a parameter in the source object to a callback.
bidirectional (bool) – Whether to link source and target bi-directionally
**links (dict) – Maps between parameters on this object to the parameters on the supplied object.
- pprint() None #
Prints a compositional repr of the class.
- priority: ClassVar[float | bool | None] = None#
- save(filename: str | os.PathLike | IO, title: Optional[str] = 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: Optional[str] = None, progress: bool = True, embed_states: Dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None #
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
template – passed to underlying io.save
template_variables – passed to underlying io.save
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
progress (boolean (default=True)) – Whether to report progress
embed_states (dict (default={})) – A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) – To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector: Optional[type | Callable[['Viewable'], bool]] = None) List['Viewable'] #
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) ServableMixin #
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The Panel object itself
- server_doc(doc: Optional[Document] = None, title: Optional[str] = None, location: bool | 'Location' = True) Document #
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) threading.Thread | 'Server' #
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or threading.Thread