panel.template Package#
template
Package#
- class panel.template.BaseTemplate(template: str | _Template, items=None, nb_template: Optional[str | _Template] = None, **params)[source]#
Bases:
Parameterized
,MimeRenderMixin
,ServableMixin
,ResourceComponent
config
= param.ClassSelector(class_=<class ‘panel.config._base_config’>, constant=True, default=_base_config(css_files=[], js_files={}, js_modules={}, name=’_base_config00095’, raw_css=[]), label=’Config’)Configuration object declaring custom CSS and JS files to load specifically for this template.
design
= param.ClassSelector(class_=<class ‘panel.theme.base.Design’>, default=<class ‘panel.theme.base.Design’>, label=’Design’)A Design applies themes to a template.
location
= param.Boolean(default=False, label=’Location’)Whether to add a Location component to this Template. Note if this is set to true, the Jinja2 template must either insert all available roots or explicitly embed the location root with : {{ embed(roots.location) }}.
theme
= param.ClassSelector(class_=<class ‘panel.theme.base.Theme’>, constant=True, default=<class ‘panel.theme.base.DefaultTheme’>, label=’Theme’)- resolve_resources(cdn: bool | Literal['auto'] = 'auto') ResourcesType [source]#
Resolves the resources required for this template component.
- Parameters:
cdn (bool | Literal['auto']) – Whether to load resources from CDN or local server. If set to ‘auto’ value will be automatically determine based on global settings.
- Return type:
Dictionary containing JS and CSS resources.
- save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources=None, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None) None [source]#
Saves Panel objects to file.
- Parameters:
filename (string or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
- select(selector=None)[source]#
Iterates over the Template and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) BaseTemplate [source]#
Serves the template and returns self to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The template
- server_doc(doc: Optional[Document] = None, title: str = None, location: bool | Location = True) Document [source]#
Returns a servable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The Bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The Bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server #
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- theme#
alias of
DefaultTheme
- class panel.template.BootstrapTemplate(**params)[source]#
Bases:
BasicTemplate
Parameters inherited from:
panel.template.base.BaseTemplate
: config, themepanel.template.base.BasicTemplate
: location, busy_indicator, collapsed_sidebar, header, main, main_max_width, sidebar, modal, notifications, logo, favicon, title, site, site_url, manifest, meta_description, meta_keywords, meta_author, meta_refresh, meta_viewport, base_url, base_target, header_background, header_colordesign
= param.ClassSelector(class_=<class ‘panel.theme.base.Design’>, default=<class ‘panel.theme.bootstrap.Bootstrap’>, label=’Design’)A Design applies a specific design system to a template.
sidebar_width
= param.Integer(default=350, inclusive_bounds=(True, True), label=’Sidebar width’)The width of the sidebar in pixels. Default is 350.
_actions
= param.ClassSelector(class_=<class ‘panel.template.base.TemplateActions’>, default=BootstrapTemplateActions(), label=’ actions’)- close_modal() None #
Closes the modal area
- open_modal() None #
Opens the modal area
- resolve_resources(cdn: bool | Literal['auto'] = 'auto') ResourcesType #
Resolves the resources required for this template component.
- Parameters:
cdn (bool | Literal['auto']) – Whether to load resources from CDN or local server. If set to ‘auto’ value will be automatically determine based on global settings.
- Return type:
Dictionary containing JS and CSS resources.
- save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources=None, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None) None #
Saves Panel objects to file.
- Parameters:
filename (string or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
- select(selector=None)#
Iterates over the Template and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) BaseTemplate #
Serves the template and returns self to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The template
- server_doc(doc: Optional[Document] = None, title: str = None, location: bool | Location = True) Document #
Returns a servable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The Bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The Bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server #
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- theme#
alias of
DefaultTheme
- class panel.template.DarkTheme(**params)[source]#
Bases:
Theme
Baseclass for dark themes.
Parameters inherited from:
base_css
= param.Filename(default=PosixPath(‘/Users/runner/work/panel/panel/panel/theme/css/dark.css’), label=’Base css’, search_paths=[])A stylesheet declaring the base variables that define the color scheme. By default this is inherited from a base class.
bokeh_theme
= param.ClassSelector(class_=(<class ‘bokeh.themes.theme.Theme’>, <class ‘str’>), default=<bokeh.themes.theme.Theme object at 0x133bea310>, label=’Bokeh theme’)A Bokeh Theme class that declares properties to apply to Bokeh models. This is necessary to ensure that plots and other canvas based components are styled appropriately.
- class panel.template.DefaultTheme(**params)[source]#
Bases:
Theme
Baseclass for default or light themes.
Parameters inherited from:
panel.theme.base.Theme
: bokeh_theme, cssbase_css
= param.Filename(default=PosixPath(‘/Users/runner/work/panel/panel/panel/theme/css/default.css’), label=’Base css’, search_paths=[])A stylesheet declaring the base variables that define the color scheme. By default this is inherited from a base class.
- class panel.template.FastGridTemplate(**params)[source]#
Bases:
FastGridBaseTemplate
The FastGridTemplate is a grid based Template with a header, sidebar and main area. It is based on the fast.design style and works well in both default (light) and dark mode.
Reference: https://panel.holoviz.org/reference/templates/FastGridTemplate.html
Example:
>>> template = pn.template.FastGridTemplate( ... site="Panel", title="FastGridTemplate", accent="#A01346", ... sidebar=[pn.pane.Markdown("## Settings"), some_slider], ... ).servable() >>> template.main[0:6,:] = some_python_object
Some accent colors that work well are #A01346 (Fast), #00A170 (Mint), #DAA520 (Golden Rod), #2F4F4F (Dark Slate Grey), #F08080 (Light Coral) and #4099da (Summer Sky).
Please note the FastListTemplate cannot display in a notebook output cell.
Parameters inherited from:
panel.template.base.BaseTemplate
: config, themepanel.template.base.BasicTemplate
: location, busy_indicator, collapsed_sidebar, header, main_max_width, sidebar, sidebar_width, modal, notifications, logo, favicon, title, site, site_url, manifest, meta_description, meta_keywords, meta_author, meta_refresh, meta_viewport, base_url, base_target, header_background, header_color, _actionspanel.template.react.ReactTemplate
: main, compact, cols, breakpoints, row_height, dimensions, prevent_collision, save_layoutpanel.template.fast.base.FastBaseTemplate
: design, accent_base_color, background_color, corner_radius, font, font_url, header_neutral_color, header_accent_base_color, neutral_color, theme_toggle, shadow, sidebar_footer, main_layout- close_modal() None #
Closes the modal area
- open_modal() None #
Opens the modal area
- resolve_resources(cdn: bool | Literal['auto'] = 'auto') ResourcesType #
Resolves the resources required for this template component.
- Parameters:
cdn (bool | Literal['auto']) – Whether to load resources from CDN or local server. If set to ‘auto’ value will be automatically determine based on global settings.
- Return type:
Dictionary containing JS and CSS resources.
- save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources=None, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None) None #
Saves Panel objects to file.
- Parameters:
filename (string or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
- select(selector=None)#
Iterates over the Template and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) BaseTemplate #
Serves the template and returns self to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The template
- server_doc(doc: Optional[Document] = None, title: str = None, location: bool | Location = True) Document #
Returns a servable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The Bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The Bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server #
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- theme#
alias of
DefaultTheme
- class panel.template.FastListTemplate(**params)[source]#
Bases:
FastBaseTemplate
The FastListTemplate is a list based Template with a header, sidebar and main area. It is based on the fast.design style and works well in both default (light) and dark mode.
Reference: https://panel.holoviz.org/reference/templates/FastListTemplate.html
Example:
>>> pn.template.FastListTemplate( ... site="Panel", title="FastListTemplate", accent="#A01346", ... sidebar=[pn.pane.Markdown("## Settings"), some_slider], ... main=[some_python_object] ... ).servable()
Some accent colors that work well are #A01346 (Fast), #00A170 (Mint), #DAA520 (Golden Rod), #2F4F4F (Dark Slate Grey), #F08080 (Light Coral) and #4099da (Summer Sky).
You can also use the FastListTemplate as shown below
>>> pn.extension(..., template="fast") >>> pn.state.template.param.update(site="Panel", title="FastListTemplate", accent="#A01346") >>> pn.pane.Markdown("## Settings").servable(target="sidebar") >>> some_slider = pn.widgets.IntSlider(...).servable(target="sidebar") >>> ... >>> pn.panel(some_python_object).servable(target="main")
This api is great for more exploratory use cases.
Please note the FastListTemplate cannot display in a notebook output cell.
Parameters inherited from:
panel.template.base.BaseTemplate
: config, themepanel.template.base.BasicTemplate
: location, busy_indicator, collapsed_sidebar, header, main, main_max_width, sidebar, sidebar_width, modal, notifications, logo, favicon, title, site, site_url, manifest, meta_description, meta_keywords, meta_author, meta_refresh, meta_viewport, base_url, base_target, header_background, header_color, _actionspanel.template.fast.base.FastBaseTemplate
: design, accent_base_color, background_color, corner_radius, font, font_url, header_neutral_color, header_accent_base_color, neutral_color, theme_toggle, shadow, sidebar_footer, main_layout- close_modal() None #
Closes the modal area
- open_modal() None #
Opens the modal area
- resolve_resources(cdn: bool | Literal['auto'] = 'auto') ResourcesType #
Resolves the resources required for this template component.
- Parameters:
cdn (bool | Literal['auto']) – Whether to load resources from CDN or local server. If set to ‘auto’ value will be automatically determine based on global settings.
- Return type:
Dictionary containing JS and CSS resources.
- save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources=None, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None) None #
Saves Panel objects to file.
- Parameters:
filename (string or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
- select(selector=None)#
Iterates over the Template and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) BaseTemplate #
Serves the template and returns self to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The template
- server_doc(doc: Optional[Document] = None, title: str = None, location: bool | Location = True) Document #
Returns a servable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The Bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The Bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server #
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- theme#
alias of
DefaultTheme
- class panel.template.GoldenTemplate(**params)[source]#
Bases:
BasicTemplate
GoldenTemplate is built on top of golden-layout library.
Parameters inherited from:
panel.template.base.BaseTemplate
: config, design, themepanel.template.base.BasicTemplate
: location, busy_indicator, collapsed_sidebar, header, main, main_max_width, sidebar, modal, notifications, logo, favicon, title, site, site_url, manifest, meta_description, meta_keywords, meta_author, meta_refresh, meta_viewport, base_url, base_target, header_background, header_color, _actionssidebar_width
= param.Integer(constant=True, default=20, inclusive_bounds=(True, True), label=’Sidebar width’)The width of the sidebar in percent.
- close_modal() None #
Closes the modal area
- open_modal() None #
Opens the modal area
- resolve_resources(cdn: bool | Literal['auto'] = 'auto') ResourcesType [source]#
Resolves the resources required for this template component.
- Parameters:
cdn (bool | Literal['auto']) – Whether to load resources from CDN or local server. If set to ‘auto’ value will be automatically determine based on global settings.
- Return type:
Dictionary containing JS and CSS resources.
- save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources=None, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None) None #
Saves Panel objects to file.
- Parameters:
filename (string or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
- select(selector=None)#
Iterates over the Template and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) BaseTemplate #
Serves the template and returns self to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The template
- server_doc(doc: Optional[Document] = None, title: str = None, location: bool | Location = True) Document #
Returns a servable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The Bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The Bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server #
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- theme#
alias of
DefaultTheme
- class panel.template.MaterialTemplate(**params)[source]#
Bases:
BasicTemplate
MaterialTemplate is built on top of Material web components.
Parameters inherited from:
panel.template.base.BaseTemplate
: config, themepanel.template.base.BasicTemplate
: location, busy_indicator, collapsed_sidebar, header, main, main_max_width, sidebar, modal, notifications, logo, favicon, title, site, site_url, manifest, meta_description, meta_keywords, meta_author, meta_refresh, meta_viewport, base_url, base_target, header_background, header_colordesign
= param.ClassSelector(class_=<class ‘panel.theme.base.Design’>, default=<class ‘panel.theme.material.Material’>, label=’Design’)A Design applies a specific design system to a template.
sidebar_width
= param.Integer(default=370, inclusive_bounds=(True, True), label=’Sidebar width’)The width of the sidebar in pixels. Default is 370.
_actions
= param.ClassSelector(class_=<class ‘panel.template.base.TemplateActions’>, default=MaterialTemplateActions(), label=’ actions’)- close_modal() None #
Closes the modal area
- open_modal() None #
Opens the modal area
- resolve_resources(cdn: bool | Literal['auto'] = 'auto') ResourcesType #
Resolves the resources required for this template component.
- Parameters:
cdn (bool | Literal['auto']) – Whether to load resources from CDN or local server. If set to ‘auto’ value will be automatically determine based on global settings.
- Return type:
Dictionary containing JS and CSS resources.
- save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources=None, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None) None #
Saves Panel objects to file.
- Parameters:
filename (string or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
- select(selector=None)#
Iterates over the Template and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) BaseTemplate #
Serves the template and returns self to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The template
- server_doc(doc: Optional[Document] = None, title: str = None, location: bool | Location = True) Document #
Returns a servable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The Bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The Bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server #
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- theme#
alias of
DefaultTheme
- class panel.template.ReactTemplate(**params)[source]#
Bases:
BasicTemplate
ReactTemplate is built on top of React Grid Layout web components.
Parameters inherited from:
panel.template.base.BaseTemplate
: config, design, themepanel.template.base.BasicTemplate
: location, busy_indicator, collapsed_sidebar, header, main_max_width, sidebar, sidebar_width, modal, notifications, logo, favicon, title, site, site_url, manifest, meta_description, meta_keywords, meta_author, meta_refresh, meta_viewport, base_url, base_target, header_background, header_color, _actionsmain
= param.ClassSelector(allow_None=True, class_=<class ‘panel.layout.grid.GridSpec’>, constant=True, label=’Main’)A list-like container which populates the main area.
compact
= param.ObjectSelector(label=’Compact’, names={}, objects=[None, ‘vertical’, ‘horizontal’, ‘both’])cols
= param.Dict(class_=<class ‘dict’>, default={‘lg’: 12, ‘md’: 10, ‘sm’: 6, ‘xs’: 4, ‘xxs’: 2}, label=’Cols’)breakpoints
= param.Dict(class_=<class ‘dict’>, default={‘lg’: 1200, ‘md’: 996, ‘sm’: 768, ‘xs’: 480, ‘xxs’: 0}, label=’Breakpoints’)row_height
= param.Integer(default=150, inclusive_bounds=(True, True), label=’Row height’)dimensions
= param.Dict(class_=<class ‘dict’>, default={‘minW’: 0, ‘maxW’: inf, ‘minH’: 0, ‘maxH’: inf}, label=’Dimensions’)A dictionary of minimum/maximum width/height in grid units.
prevent_collision
= param.Boolean(default=False, label=’Prevent collision’)Prevent collisions between items.
save_layout
= param.Boolean(default=False, label=’Save layout’)Save layout to local storage.
- close_modal() None #
Closes the modal area
- open_modal() None #
Opens the modal area
- resolve_resources(cdn: bool | Literal['auto'] = 'auto') ResourcesType #
Resolves the resources required for this template component.
- Parameters:
cdn (bool | Literal['auto']) – Whether to load resources from CDN or local server. If set to ‘auto’ value will be automatically determine based on global settings.
- Return type:
Dictionary containing JS and CSS resources.
- save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources=None, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None) None #
Saves Panel objects to file.
- Parameters:
filename (string or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
- select(selector=None)#
Iterates over the Template and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) BaseTemplate #
Serves the template and returns self to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The template
- server_doc(doc: Optional[Document] = None, title: str = None, location: bool | Location = True) Document #
Returns a servable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The Bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The Bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server #
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- theme#
alias of
DefaultTheme
- class panel.template.SlidesTemplate(**params)[source]#
Bases:
VanillaTemplate
SlidesTemplate is built on top of Vanilla web components.
Parameters inherited from:
panel.template.base.BaseTemplate
: config, themepanel.template.base.BasicTemplate
: location, busy_indicator, header, main, main_max_width, sidebar, sidebar_width, modal, notifications, logo, favicon, title, site, site_url, manifest, meta_description, meta_keywords, meta_author, meta_refresh, meta_viewport, base_url, base_target, header_background, header_color, _actionscollapsed_sidebar
= param.Selector(constant=True, default=True, label=’Collapsed sidebar’, names={}, objects=[])Whether the sidebar (if present) is initially collapsed.
reveal_config
= param.Dict(class_=<class ‘dict’>, default={}, label=’Reveal config’)Configuration parameters for reveal.js
reveal_theme
= param.Selector(label=’Reveal theme’, names={}, objects=[‘black’, ‘white’, ‘league’, ‘beige’, ‘night’, ‘solarized’, ‘simple’])The reveal.js theme to load.
show_header
= param.Boolean(default=False, label=’Show header’)Whether to show the header component.
- close_modal() None #
Closes the modal area
- open_modal() None #
Opens the modal area
- resolve_resources(cdn: bool | Literal['auto'] = 'auto') ResourcesType #
Resolves the resources required for this template component.
- Parameters:
cdn (bool | Literal['auto']) – Whether to load resources from CDN or local server. If set to ‘auto’ value will be automatically determine based on global settings.
- Return type:
Dictionary containing JS and CSS resources.
- save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources=None, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None) None #
Saves Panel objects to file.
- Parameters:
filename (string or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
- select(selector=None)#
Iterates over the Template and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) BaseTemplate #
Serves the template and returns self to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The template
- server_doc(doc: Optional[Document] = None, title: str = None, location: bool | Location = True) Document #
Returns a servable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The Bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The Bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server #
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- theme#
alias of
DefaultTheme
- class panel.template.Template(template: str | _Template, nb_template: str | _Template | None = None, items: Optional[Dict[str, Any]] = None, **params)[source]#
Bases:
BaseTemplate
A Template is a high-level component to render multiple Panel objects into a single HTML document defined through a Jinja2 template. The Template object is given a Jinja2 template and then allows populating this template by adding Panel objects, which are given unique names. These unique names may then be referenced in the template to insert the rendered Panel object at a specific location. For instance, given a Jinja2 template that defines roots A and B like this:
<div> {{ embed(roots.A) }} </div> <div> {{ embed(roots.B) }} </div>
We can then populate the template by adding panel ‘A’ and ‘B’ to the Template object:
template.add_panel(‘A’, pn.panel(‘A’)) template.add_panel(‘B’, pn.panel(‘B’))
Once a template has been fully populated it can be rendered using the same API as other Panel objects. Note that all roots that have been declared using the {{ embed(roots.A) }} syntax in the Jinja2 template must be defined when rendered.
Since embedding complex CSS frameworks inside a notebook can have undesirable side-effects and a notebook does not afford the same amount of screen space a Template may given separate template and nb_template objects. This allows for different layouts when served as a standalone server and when used in the notebook.
Parameters inherited from:
panel.template.base.BaseTemplate
: config, design, location, theme- add_panel(name: str, panel: Viewable, tags: List[str] = []) None [source]#
Add panels to the Template, which may then be referenced by the given name using the jinja2 embed macro.
- Parameters:
name (str) – The name to refer to the panel by in the template
panel (panel.Viewable) – A Panel component to embed in the template.
- add_variable(name: str, value: Any) None [source]#
Add parameters to the template, which may then be referenced by the given name in the Jinja2 template.
- Parameters:
name (str) – The name to refer to the panel by in the template
value (object) – Any valid Jinja2 variable type.
- resolve_resources(cdn: bool | Literal['auto'] = 'auto') ResourcesType #
Resolves the resources required for this template component.
- Parameters:
cdn (bool | Literal['auto']) – Whether to load resources from CDN or local server. If set to ‘auto’ value will be automatically determine based on global settings.
- Return type:
Dictionary containing JS and CSS resources.
- save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources=None, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None) None #
Saves Panel objects to file.
- Parameters:
filename (string or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
- select(selector=None)#
Iterates over the Template and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) BaseTemplate #
Serves the template and returns self to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The template
- server_doc(doc: Optional[Document] = None, title: str = None, location: bool | Location = True) Document #
Returns a servable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The Bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The Bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server #
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- theme#
alias of
DefaultTheme
- class panel.template.VanillaTemplate(**params)[source]#
Bases:
BasicTemplate
VanillaTemplate is built on top of Vanilla web components.
Parameters inherited from:
panel.template.base.BaseTemplate
: config, themepanel.template.base.BasicTemplate
: location, busy_indicator, collapsed_sidebar, header, main, main_max_width, sidebar, sidebar_width, modal, notifications, logo, favicon, title, site, site_url, manifest, meta_description, meta_keywords, meta_author, meta_refresh, meta_viewport, base_url, base_target, header_background, header_color, _actionsdesign
= param.ClassSelector(class_=<class ‘panel.theme.base.Design’>, default=<class ‘panel.theme.native.Native’>, label=’Design’)A Design applies a specific design system to a template.
- close_modal() None #
Closes the modal area
- open_modal() None #
Opens the modal area
- resolve_resources(cdn: bool | Literal['auto'] = 'auto') ResourcesType #
Resolves the resources required for this template component.
- Parameters:
cdn (bool | Literal['auto']) – Whether to load resources from CDN or local server. If set to ‘auto’ value will be automatically determine based on global settings.
- Return type:
Dictionary containing JS and CSS resources.
- save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources=None, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None) None #
Saves Panel objects to file.
- Parameters:
filename (string or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
- select(selector=None)#
Iterates over the Template and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) BaseTemplate #
Serves the template and returns self to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The template
- server_doc(doc: Optional[Document] = None, title: str = None, location: bool | Location = True) Document #
Returns a servable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The Bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The Bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server #
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- theme#
alias of
DefaultTheme
base
Module#

Templates allow multiple Panel objects to be embedded into custom HTML documents.
- class panel.template.base.BaseTemplate(template: str | _Template, items=None, nb_template: Optional[str | _Template] = None, **params)[source]#
Bases:
Parameterized
,MimeRenderMixin
,ServableMixin
,ResourceComponent
config
= param.ClassSelector(class_=<class ‘panel.config._base_config’>, constant=True, default=_base_config(css_files=[], js_files={}, js_modules={}, name=’_base_config00095’, raw_css=[]), label=’Config’)Configuration object declaring custom CSS and JS files to load specifically for this template.
design
= param.ClassSelector(class_=<class ‘panel.theme.base.Design’>, default=<class ‘panel.theme.base.Design’>, label=’Design’)A Design applies themes to a template.
location
= param.Boolean(default=False, label=’Location’)Whether to add a Location component to this Template. Note if this is set to true, the Jinja2 template must either insert all available roots or explicitly embed the location root with : {{ embed(roots.location) }}.
theme
= param.ClassSelector(class_=<class ‘panel.theme.base.Theme’>, constant=True, default=<class ‘panel.theme.base.DefaultTheme’>, label=’Theme’)- resolve_resources(cdn: bool | Literal['auto'] = 'auto') ResourcesType [source]#
Resolves the resources required for this template component.
- Parameters:
cdn (bool | Literal['auto']) – Whether to load resources from CDN or local server. If set to ‘auto’ value will be automatically determine based on global settings.
- Return type:
Dictionary containing JS and CSS resources.
- save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources=None, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None) None [source]#
Saves Panel objects to file.
- Parameters:
filename (string or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
- select(selector=None)[source]#
Iterates over the Template and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) BaseTemplate [source]#
Serves the template and returns self to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The template
- server_doc(doc: Optional[Document] = None, title: str = None, location: bool | Location = True) Document [source]#
Returns a servable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The Bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The Bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server #
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- theme#
alias of
DefaultTheme
- class panel.template.base.BasicTemplate(**params)[source]#
Bases:
BaseTemplate
BasicTemplate provides a baseclass for templates with a basic organization including a header, sidebar and main area. Unlike the more generic Template class these default templates make it easy for a user to generate an application with a polished look and feel without having to write any Jinja2 template themselves.
Parameters inherited from:
panel.template.base.BaseTemplate
: config, design, themelocation
= param.Boolean(constant=True, default=True, label=’Location’, readonly=True)Whether to add a Location component to this Template. Note if this is set to true, the Jinja2 template must either insert all available roots or explicitly embed the location root with : {{ embed(roots.location) }}.
busy_indicator
= param.ClassSelector(allow_None=True, class_=<class ‘panel.widgets.indicators.BooleanIndicator’>, constant=True, default=LoadingSpinner(height=20, width=20), label=’Busy indicator’)Visual indicator of application busy state.
collapsed_sidebar
= param.Selector(constant=True, default=False, label=’Collapsed sidebar’, names={}, objects=[])Whether the sidebar (if present) is initially collapsed.
header
= param.ClassSelector(allow_None=True, class_=<class ‘panel.layout.base.ListLike’>, constant=True, label=’Header’)A list-like container which populates the header bar.
main
= param.ClassSelector(allow_None=True, class_=<class ‘panel.layout.base.ListLike’>, constant=True, label=’Main’)A list-like container which populates the main area.
main_max_width
= param.String(default=’’, label=’Main max width’)The maximum width of the main area. For example ‘800px’ or ‘80%’. If the string is ‘’ (default) no max width is set.
sidebar
= param.ClassSelector(allow_None=True, class_=<class ‘panel.layout.base.ListLike’>, constant=True, label=’Sidebar’)A list-like container which populates the sidebar.
sidebar_width
= param.Integer(default=330, inclusive_bounds=(True, True), label=’Sidebar width’)The width of the sidebar in pixels. Default is 330.
modal
= param.ClassSelector(allow_None=True, class_=<class ‘panel.layout.base.ListLike’>, constant=True, label=’Modal’)A list-like container which populates the modal
notifications
= param.ClassSelector(allow_None=True, class_=<class ‘panel.io.notifications.NotificationArea’>, constant=True, label=’Notifications’)The NotificationArea instance attached to this template. Automatically added if config.notifications is set, but may also be provided explicitly.
logo
= param.String(default=’’, label=’Logo’)URI of logo to add to the header (if local file, logo is base64 encoded as URI). Default is ‘’, i.e. not shown.
favicon
= param.String(default=’/static/extensions/panel/images/favicon.ico’, label=’Favicon’)URI of favicon to add to the document head (if local file, favicon is base64 encoded as URI).
title
= param.String(default=’Panel Application’, label=’Title’)A title to show in the header. Also added to the document head meta settings and as the browser tab title.
site
= param.String(default=’’, label=’Site’)Name of the site. Will be shown in the header and link to the ‘site_url’. Default is ‘’, i.e. not shown.
site_url
= param.String(default=’/’, label=’Site url’)Url of the site and logo. Default is ‘/’.
manifest
= param.String(allow_None=True, label=’Manifest’)Manifest to add to site.
meta_description
= param.String(default=’’, label=’Meta description’)A meta description to add to the document head for search engine optimization. For example ‘P.A. Nelson’.
meta_keywords
= param.String(default=’’, label=’Meta keywords’)Meta keywords to add to the document head for search engine optimization.
meta_author
= param.String(default=’’, label=’Meta author’)A meta author to add to the the document head for search engine optimization. For example ‘P.A. Nelson’.
meta_refresh
= param.String(default=’’, label=’Meta refresh’)A meta refresh rate to add to the document head. For example ‘30’ will instruct the browser to refresh every 30 seconds. Default is ‘’, i.e. no automatic refresh.
meta_viewport
= param.String(default=’’, label=’Meta viewport’)A meta viewport to add to the header.
base_url
= param.String(default=’’, label=’Base url’)Specifies the base URL for all relative URLs in a page. Default is ‘’, i.e. not the domain.
base_target
= param.ObjectSelector(default=’_self’, label=’Base target’, names={}, objects=[‘_blank’, ‘_self’, ‘_parent’, ‘_top’])Specifies the base Target for all relative URLs in a page.
header_background
= param.String(default=’’, label=’Header background’)Optional header background color override.
header_color
= param.String(default=’’, label=’Header color’)Optional header text color override.
_actions
= param.ClassSelector(class_=<class ‘panel.template.base.TemplateActions’>, default=TemplateActions(), label=’ actions’)- resolve_resources(cdn: bool | Literal['auto'] = 'auto') ResourcesType #
Resolves the resources required for this template component.
- Parameters:
cdn (bool | Literal['auto']) – Whether to load resources from CDN or local server. If set to ‘auto’ value will be automatically determine based on global settings.
- Return type:
Dictionary containing JS and CSS resources.
- save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources=None, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None) None #
Saves Panel objects to file.
- Parameters:
filename (string or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
- select(selector=None)#
Iterates over the Template and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) BaseTemplate #
Serves the template and returns self to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The template
- server_doc(doc: Optional[Document] = None, title: str = None, location: bool | Location = True) Document #
Returns a servable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The Bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The Bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server #
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- theme#
alias of
DefaultTheme
- class panel.template.base.Template(template: str | _Template, nb_template: str | _Template | None = None, items: Optional[Dict[str, Any]] = None, **params)[source]#
Bases:
BaseTemplate
A Template is a high-level component to render multiple Panel objects into a single HTML document defined through a Jinja2 template. The Template object is given a Jinja2 template and then allows populating this template by adding Panel objects, which are given unique names. These unique names may then be referenced in the template to insert the rendered Panel object at a specific location. For instance, given a Jinja2 template that defines roots A and B like this:
<div> {{ embed(roots.A) }} </div> <div> {{ embed(roots.B) }} </div>
We can then populate the template by adding panel ‘A’ and ‘B’ to the Template object:
template.add_panel(‘A’, pn.panel(‘A’)) template.add_panel(‘B’, pn.panel(‘B’))
Once a template has been fully populated it can be rendered using the same API as other Panel objects. Note that all roots that have been declared using the {{ embed(roots.A) }} syntax in the Jinja2 template must be defined when rendered.
Since embedding complex CSS frameworks inside a notebook can have undesirable side-effects and a notebook does not afford the same amount of screen space a Template may given separate template and nb_template objects. This allows for different layouts when served as a standalone server and when used in the notebook.
Parameters inherited from:
panel.template.base.BaseTemplate
: config, design, location, theme- add_panel(name: str, panel: Viewable, tags: List[str] = []) None [source]#
Add panels to the Template, which may then be referenced by the given name using the jinja2 embed macro.
- Parameters:
name (str) – The name to refer to the panel by in the template
panel (panel.Viewable) – A Panel component to embed in the template.
- add_variable(name: str, value: Any) None [source]#
Add parameters to the template, which may then be referenced by the given name in the Jinja2 template.
- Parameters:
name (str) – The name to refer to the panel by in the template
value (object) – Any valid Jinja2 variable type.
- resolve_resources(cdn: bool | Literal['auto'] = 'auto') ResourcesType #
Resolves the resources required for this template component.
- Parameters:
cdn (bool | Literal['auto']) – Whether to load resources from CDN or local server. If set to ‘auto’ value will be automatically determine based on global settings.
- Return type:
Dictionary containing JS and CSS resources.
- save(filename: str | os.PathLike | IO, title: Optional[str] = None, resources=None, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None) None #
Saves Panel objects to file.
- Parameters:
filename (string or file-like object) – Filename to save the plot to
title (string) – Optional title for the plot
resources (bokeh resources) – One of the valid bokeh.resources (e.g. CDN or INLINE)
embed (bool) – Whether the state space should be embedded in the saved file.
max_states (int) – The maximum number of states to embed
max_opts (int) – The maximum number of states for a single widget
embed_json (boolean (default=True)) – Whether to export the data to json files
json_prefix (str (default='')) – Prefix for the auto-generated json directory
save_path (str (default='./')) – The path to save json files to
load_path (str (default=None)) – The path or URL the json files will be loaded from.
- select(selector=None)#
Iterates over the Template and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) – The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) BaseTemplate #
Serves the template and returns self to allow it to display itself in a notebook context.
- Parameters:
title (str) – A string title to give the Document (if served as an app)
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.
target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.
- Return type:
The template
- server_doc(doc: Optional[Document] = None, title: str = None, location: bool | Location = True) Document #
Returns a servable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) – The Bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) – A string title to give the Document
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
doc – The Bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server #
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) – A string title to give the Document (if served as an app)
port (int (optional, default=0)) – Allows specifying a specific port
address (str) – The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.
threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) – Whether to print the address and port
open (boolean (optional, default=True)) – Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.
- Returns:
server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- theme#
alias of
DefaultTheme
- class panel.template.base.TemplateActions(**params)[source]#
Bases:
ReactiveHTML
A component added to templates that allows triggering events such as opening and closing a modal.
Parameters inherited from:
panel.viewable.Layoutable
: align, aspect_ratio, background, css_classes, design, height, min_width, min_height, max_width, max_height, margin, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingopen_modal
= param.Integer(default=0, inclusive_bounds=(True, True), label=’Open modal’)close_modal
= param.Integer(default=0, inclusive_bounds=(True, True), label=’Close modal’)- 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
- clone(**params) Viewable #
Makes a copy of the object sharing the same parameters.
- Parameters:
params (Keyword arguments override the parameters on the clone.) –
- Return type:
Cloned Viewable object
- controls(parameters: List[str] = [], jslink: bool = True, **kwargs) Panel #
Creates a set of widgets which allow 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
- get_root(doc: Optional[Document] = None, comm: Optional[Comm] = None, preprocess: bool = True) Model #
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.Document) – Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) – Optional pyviz_comms when working in notebook
preprocess (boolean (default=True)) – Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- jscallback(args: Dict[str, Any] = {}, **callbacks: str) Callback #
Allows defining a JS callback to be triggered when 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(node: str, event: str, callback: Callable) None #
Registers a callback to be executed when the specified DOM event is triggered on the named node. Note that the named node must be declared in the HTML. To create a named node you must give it an id of the form id=”name”, where name will be the node identifier.
- Parameters:
node (str) – Named node in the HTML identifiable via id of the form id=”name”.
event (str) – Name of the DOM event to add an event listener to.
callback (callable) – A callable which will be given the DOMEvent object.
- 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) StoppableThread' | '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 panel.io.server.StoppableThread
Subpackages#
- panel.bootstrap Package
bootstrap
PackageBootstrapTemplate
BootstrapTemplateActions
BootstrapTemplateActions.app()
BootstrapTemplateActions.clone()
BootstrapTemplateActions.controls()
BootstrapTemplateActions.embed()
BootstrapTemplateActions.get_root()
BootstrapTemplateActions.jscallback()
BootstrapTemplateActions.jslink()
BootstrapTemplateActions.link()
BootstrapTemplateActions.on_event()
BootstrapTemplateActions.pprint()
BootstrapTemplateActions.save()
BootstrapTemplateActions.select()
BootstrapTemplateActions.servable()
BootstrapTemplateActions.server_doc()
BootstrapTemplateActions.show()
- panel.fast Package
fast
Packagebase
ModuleFastBaseTemplate
FastGridBaseTemplate
FastGridBaseTemplate.close_modal()
FastGridBaseTemplate.design
FastGridBaseTemplate.open_modal()
FastGridBaseTemplate.resolve_resources()
FastGridBaseTemplate.save()
FastGridBaseTemplate.select()
FastGridBaseTemplate.servable()
FastGridBaseTemplate.server_doc()
FastGridBaseTemplate.show()
FastGridBaseTemplate.theme
- Subpackages
- panel.golden Package
- panel.material Package
material
PackageMaterialTemplate
MaterialTemplateActions
MaterialTemplateActions.app()
MaterialTemplateActions.clone()
MaterialTemplateActions.controls()
MaterialTemplateActions.embed()
MaterialTemplateActions.get_root()
MaterialTemplateActions.jscallback()
MaterialTemplateActions.jslink()
MaterialTemplateActions.link()
MaterialTemplateActions.on_event()
MaterialTemplateActions.pprint()
MaterialTemplateActions.save()
MaterialTemplateActions.select()
MaterialTemplateActions.servable()
MaterialTemplateActions.server_doc()
MaterialTemplateActions.show()
- panel.react Package
- panel.slides Package
- panel.vanilla Package