panel.material Package


material Package

Inheritance diagram of panel.template.material

Material template based on the material web components library.

class panel.template.material.MaterialDarkTheme(*, fig, holomap, widgets, fps, max_frames, size, dpi, filename, info, css, widget_location)[source]

Bases: panel.template.theme.DarkTheme

The MaterialDarkTheme is a Dark Theme in the style of Material Design

Parameters inherited from:

css = param.Filename(default=PosixPath(‘/home/runner/work/panel/panel/panel/template/material/dark.css’), label=’Css’, search_paths=[])

bokeh_theme = param.ClassSelector(class_=(<class ‘bokeh.themes.theme.Theme’>, <class ‘str’>), default=<bokeh.themes.theme.Theme object at 0x7fe5cf7df590>, label=’Bokeh theme’)

class panel.template.material.MaterialDefaultTheme(*, fig, holomap, widgets, fps, max_frames, size, dpi, filename, info, css, widget_location)[source]

Bases: panel.template.theme.DefaultTheme

Parameters inherited from:

css = param.Filename(default=PosixPath(‘/home/runner/work/panel/panel/panel/template/material/default.css’), label=’Css’, search_paths=[])

bokeh_theme = param.ClassSelector(class_=(<class ‘bokeh.themes.theme.Theme’>, <class ‘str’>), default=<bokeh.themes.theme.Theme object at 0x7fe5cf7df4d0>, label=’Bokeh theme’)

class panel.template.material.MaterialTemplate(**params)[source]

Bases: panel.template.base.BasicTemplate

MaterialTemplate is built on top of Material web components.

Parameters inherited from:

panel.template.base.BasicTemplate: location, config, busy_indicator, header, main, main_max_width, sidebar, modal, logo, favicon, title, site, site_url, meta_description, meta_keywords, meta_author, meta_refresh, meta_viewport, base_url, base_target, header_background, header_color, theme

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

Closes the modal area

open_modal()

Opens the modal area

save(filename, title=None, resources=None, embed=False, max_states=1000, max_opts=3, embed_json=False, json_prefix='', save_path='./', load_path=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=None, location=True, area='main')

Serves the object if in a panel serve context and returns the Panel object to allow it to display itself in a notebook context. :param title: A string title to give the Document (if served as an app) :type title: str :param location: Whether to create a Location component to observe and

set the URL location.

Parameters

area (str) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.

Returns

Return type

The Panel object itself

server_doc(doc=None, title=None, location=True)

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=None, port=0, address=None, websocket_origin=None, threaded=False, verbose=True, open=True, location=True, **kwargs)

Starts a Bokeh server and displays the Viewable in a new tab.

Parameters
  • title (str) – A string title to give the Document (if served as an app)

  • port (int (optional, default=0)) – Allows specifying a specific port

  • address (str) – The address the server should listen on for HTTP requests.

  • websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.

  • threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.

  • verbose (boolean (optional, default=True)) – Whether to print the address and port

  • open (boolean (optional, default=True)) – Whether to open the server in a new browser tab

  • location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.

Returns

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

Return type

bokeh.server.Server or threading.Thread

theme

alias of panel.template.theme.DefaultTheme

class panel.template.material.MaterialTemplateActions(**params)[source]

Bases: panel.template.base.TemplateActions

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, background, css_classes, width, height, min_width, min_height, max_width, max_height, margin, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.template.base.TemplateActions: open_modal, close_modal

app(notebook_url='localhost:8888', port=0)

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)

Makes a copy of the object sharing the same parameters.

Parameters

params (Keyword arguments override the parameters on the clone.) –

Returns

Return type

Cloned Viewable object

controls(parameters=[], jslink=True, **kwargs)

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.

Returns

Return type

A layout of the controls

embed(max_states=1000, max_opts=3, json=False, json_prefix='', save_path='./', load_path=None, progress=False, states={})

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=None, comm=None, preprocess=True)

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

Returns

Return type

Returns the bokeh model corresponding to this panel object

jscallback(args={}, **callbacks)

Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.

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

  • **callbacks (dict) – A mapping between properties on the source model and the code to execute when that property changes

Returns

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

Return type

Callback

Links properties on the source object to those on the target 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 (HoloViews object or bokeh Model or panel Viewable) – The target to link the value to.

  • code (dict) – Custom code which will be executed when the widget value changes.

  • bidirectional (boolean) – Whether to link source and target bi-directionally

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

Returns

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

Return type

GenericLink

Links the parameters on this object to attributes on another object in Python. 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 (object) – The target object of the link.

  • callbacks (dict) – Maps from a parameter in the source object to a callback.

  • bidirectional (boolean) – 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, event, callback)

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

Prints a compositional repr of the class.

save(filename, title=None, resources=None, template=None, template_variables=None, embed=False, max_states=1000, max_opts=3, embed_json=False, json_prefix='', save_path='./', load_path=None, progress=True, embed_states={}, **kwargs)

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)

  • 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

select(selector=None)

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=None, location=True, area='main')

Serves the object if in a panel serve context and returns the Panel object to allow it to display itself in a notebook context. :param title: A string title to give the Document (if served as an app) :type title: str :param location: Whether to create a Location component to observe and

set the URL location.

Parameters

area (str) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.

Returns

Return type

The Panel object itself

server_doc(doc=None, title=None, location=True)

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=None, port=0, address=None, websocket_origin=None, threaded=False, verbose=True, open=True, location=True, **kwargs)

Starts a Bokeh server and displays the Viewable in a new tab.

Parameters
  • title (str) – A string title to give the Document (if served as an app)

  • port (int (optional, default=0)) – Allows specifying a specific port

  • address (str) – The address the server should listen on for HTTP requests.

  • websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.

  • threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.

  • verbose (boolean (optional, default=True)) – Whether to print the address and port

  • open (boolean (optional, default=True)) – Whether to open the server in a new browser tab

  • location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.

Returns

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

Return type

bokeh.server.Server or threading.Thread