panel.material Package#
material
Package#
Material template based on the material web components library.
- class panel.template.material.MaterialTemplate(*, _actions, base_target, base_url, busy_indicator, collapsed_sidebar, favicon, header, header_background, header_color, logo, main, main_max_width, manifest, meta_author, meta_description, meta_keywords, meta_refresh, meta_viewport, modal, notifications, sidebar, sidebar_width, site, site_url, title, config, design, location, theme, name)[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(allow_refs=False, class_=<class βpanel.theme.base.Designβ>, default=<class βpanel.theme.material.Materialβ>, label=βDesignβ, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x308a910d0>)A Design applies a specific design system to a template.
sidebar_width
= param.Integer(allow_refs=False, default=370, inclusive_bounds=(True, True), label=βSidebar widthβ, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309205710>)The width of the sidebar in pixels. Default is 370.
_actions
= param.ClassSelector(allow_refs=False, class_=<class βpanel.template.base.TemplateActionsβ>, default=MaterialTemplateActions(), label=β actionsβ, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x309206e10>)- resolve_resources(cdn: bool | Literal['auto'] = 'auto', extras: dict[str, dict[str, str]] | None = None) ResourcesType [source]#
Resolves the resources required for this template component.
- Parameters:
cdn (bool | Literal['auto']) β Whether to load resources from CDN or local server. If set to βautoβ value will be automatically determine based on global settings.
extras (dict[str, dict[str, str]] | None) β Additional resources to add to the bundle. Valid resource types include js, js_modules and css.
- Return type:
Dictionary containing JS and CSS resources.
- save(filename: str | PathLike | IO, title: str | None = 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: str | None = 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: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = 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: Document | None = 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: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server [source]#
Starts a Bokeh server and displays the Viewable in a new tab.
- Parameters:
title (str | None) β A string title to give the Document (if served as an app)
port (int (optional, default=0)) β Allows specifying a specific port
address (str) β The address the server should listen on for HTTP requests.
websocket_origin (str or list(str) (optional)) β A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, βlocalhostβ is used.
threaded (boolean (optional, default=False)) β Whether to launch the Server on a separate thread, allowing interactive use.
verbose (boolean (optional, default=True)) β Whether to print the address and port
open (boolean (optional, default=True)) β Whether to open the server in a new browser tab
location (boolean or panel.io.location.Location) β Whether to create a Location component to observe and set the URL location.
- Returns:
server β Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)
- Return type:
bokeh.server.Server or panel.io.server.StoppableThread
- theme[source]#
alias of
DefaultTheme
- class panel.template.material.MaterialTemplateActions(*, close_modal, open_modal, loading, align, aspect_ratio, css_classes, design, height, height_policy, margin, max_height, max_width, min_height, min_width, sizing_mode, styles, stylesheets, tags, visible, width, width_policy, name)[source]#
Bases:
TemplateActions
Parameters inherited from:
panel.viewable.Layoutable
: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, margin, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.template.base.TemplateActions
: open_modal, close_modal- clone(**params) Viewable [source]#
Makes a copy of the object sharing the same parameters.
- Parameters:
params (Keyword arguments override the parameters on the clone.)
- Return type:
Cloned Viewable object
- controls(parameters: list[str] = [], jslink: bool = True, **kwargs) Panel [source]#
Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.
- Parameters:
parameters (list(str)) β An explicit list of parameters to return controls for.
jslink (bool) β Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.
kwargs (dict) β Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.
- Return type:
A layout of the controls
- embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = None, progress: bool = False, states={}) None [source]#
Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.
- 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: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model [source]#
Returns the root model and applies pre-processing hooks
- Parameters:
doc (bokeh.Document) β Bokeh document the bokeh model will be attached to.
comm (pyviz_comms.Comm) β Optional pyviz_comms when working in notebook
preprocess (boolean (default=True)) β Whether to run preprocessing hooks
- Return type:
Returns the bokeh model corresponding to this panel object
- jscallback(args: dict[str, Any] = {}, **callbacks: str) Callback [source]#
Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.
- Parameters:
args (dict) β A mapping of objects to make available to the JS callback
**callbacks (dict) β A mapping between properties on the source model and the code to execute when that property changes
- Returns:
callback β The Callback which can be used to disable the callback.
- Return type:
- jslink(target: JSLinkTarget, code: dict[str, str] = None, args: dict | None = None, bidirectional: bool = False, **links: str) Link [source]#
Links properties on the this Reactive object to those on the target Reactive object in JS code.
Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.
- Parameters:
target (panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned) β The target to link the value to.
code (dict) β Custom code which will be executed when the widget value changes.
args (dict) β A mapping of objects to make available to the JS callback
bidirectional (boolean) β Whether to link source and target bi-directionally
**links (dict) β A mapping between properties on the source model and the target model property to link it to.
- Returns:
link β The GenericLink which can be used unlink the widget and the target model.
- Return type:
GenericLink
- link(target: Parameterized, callbacks: dict[str, str | Callable] | None = None, bidirectional: bool = False, **links: str) Watcher [source]#
Links the parameters on this Reactive object to attributes on the target Parameterized object.
Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.
- Parameters:
target (param.Parameterized) β The target object of the link.
callbacks (dict | None) β Maps from a parameter in the source object to a callback.
bidirectional (bool) β Whether to link source and target bi-directionally
**links (dict) β Maps between parameters on this object to the parameters on the supplied object.
- on_event(node: str, event: str, callback: Callable) None [source]#
Registers a callback to be executed when the specified DOM event is triggered on the named node. Note that the named node must be declared in the HTML. To create a named node you must give it an id of the form id=βnameβ, where name will be the node identifier.
- Parameters:
node (str) β Named node in the HTML identifiable via id of the form id=βnameβ.
event (str) β Name of the DOM event to add an event listener to.
callback (callable) β A callable which will be given the DOMEvent object.
- save(filename: str | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | Template | None = None, template_variables: dict[str, Any] = {}, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None [source]#
Saves Panel objects to file.
- Parameters:
filename (str or file-like object) β Filename to save the plot to
title (string) β Optional title for the plot
resources (bokeh resources) β One of the valid bokeh.resources (e.g. CDN or INLINE)
template β passed to underlying io.save
template_variables β passed to underlying io.save
embed (bool) β Whether the state space should be embedded in the saved file.
max_states (int) β The maximum number of states to embed
max_opts (int) β The maximum number of states for a single widget
embed_json (boolean (default=True)) β Whether to export the data to json files
json_prefix (str (default='')) β Prefix for the auto-generated json directory
save_path (str (default='./')) β The path to save json files to
load_path (str (default=None)) β The path or URL the json files will be loaded from.
progress (boolean (default=True)) β Whether to report progress
embed_states (dict (default={})) β A dictionary specifying the widget values to embed for each widget
as_png (boolean (default=None)) β To save as a .png. If None save_png will be true if filename is string and ends with png.
- select(selector: type | Callable[[Viewable], bool] | None = None) list[Viewable] [source]#
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
selector (type or callable or None) β The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
viewables
- Return type:
list(Viewable)
- servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = None) ServableMixin [source]#
Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.
- 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: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document [source]#
Returns a serveable bokeh Document with the panel attached
- Parameters:
doc (bokeh.Document (optional)) β The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()
title (str) β A string title to give the Document
location (boolean or panel.io.location.Location) β Whether to create a Location component to observe and set the URL location.
- Returns:
doc β The bokeh document the panel was attached to
- Return type:
bokeh.Document
- show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server [source]#
Starts a Bokeh server and displays the Viewable in a new tab.
- 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