panel.fast Package


fast Package

The Fast Templates provide easy to use, great looking templates for Panel based on the https://fast.design framework.


base Module

Inheritance diagram of panel.template.fast.base
class panel.template.fast.base.FastBaseTemplate(**params)[source]

Bases: panel.template.base.BasicTemplate

Parameters inherited from:

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

theme_toggle = param.Boolean(readonly=False)

If True a switch to toggle the Theme is shown.

sidebar_footer = param.String(readonly=False)

A HTML string appended to the sidebar

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)

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.

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.fast.base.FastGridBaseTemplate(**params)[source]

Bases: panel.template.fast.base.FastBaseTemplate, panel.template.react.ReactTemplate

Combines the FastTemplate and the React template.

Parameters inherited from:

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

panel.template.react.ReactTemplate: main, compact, cols, breakpoints, row_height

panel.template.fast.base.FastBaseTemplate: theme_toggle, sidebar_footer

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)

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.

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


theme Module

Inheritance diagram of panel.template.fast.theme

Functionality for styling according to Fast.design

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

Bases: panel.template.theme.DarkTheme

Parameters inherited from:

base_css = param.Filename(readonly=False)

style = param.ClassSelector(readonly=False)

property bokeh_theme

Provide new default values for Bokeh models.

Bokeh Model properties all have some built-in default value. If a property has not been explicitly set (e.g. m.foo = 10) then accessing the property with return the default value. It may be useful for users to be able to specify a different set of default values than the built-in default. The Theme class allows collections of custom default values to be easily applied to Bokeh documents.

The Theme class can be constructed either from a YAML file or from a JSON dict (but not both). Examples of both formats are shown below.

The plotting API’s defaults override some theme properties. Namely: fill_alpha, fill_color, line_alpha, line_color, text_alpha and text_color. Those properties should therefore be set explicitly when using the plotting API.

Parameters
  • filename (str, optional) – path to a YAML theme file

  • json (str, optional) – a JSON dictionary specifying theme values

Raises

ValueError – If neither filename or json is supplied.

Examples

Themes are specified by providing a top-level key attrs which has blocks for Model types to be themed. Each block has keys and values that specify the new property defaults for that type.

Take note of the fact that YAML interprets the value None as a string, which is not usually what you want. To give None as a value in YAML, use !!null. To give ‘None’ as a value in json, use null.

Here is an example theme in YAML format that sets various visual properties for all figures, grids, and titles:

attrs:
    Figure:
        background_fill_color: '#2F2F2F'
        border_fill_color: '#2F2F2F'
        outline_line_color: '#444444'
    Axis:
        axis_line_color: !!null
    Grid:
        grid_line_dash: [6, 4]
        grid_line_alpha: .3
    Title:
        text_color: "white"

Here is the same theme, in JSON format:

{
'attrs' : {
    'Figure' : {
        'background_fill_color': '#2F2F2F',
        'border_fill_color': '#2F2F2F',
        'outline_line_color': '#444444',
    },
    'Axis': {
        'axis_line_color': null,
    },
    'Grid': {
        'grid_line_dash': [6, 4]',
        'grid_line_alpha': .3,
    },
    'Title': {
        'text_color': 'white'
    }
}
class panel.template.fast.theme.FastDefaultTheme(*, fig, holomap, widgets, fps, max_frames, size, dpi, filename, info, css, widget_location)[source]

Bases: panel.template.theme.DefaultTheme

Parameters inherited from:

panel.template.theme.Theme: css, bokeh_theme

base_css = param.Filename(readonly=False)

style = param.ClassSelector(readonly=False)

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

Bases: param.parameterized.Parameterized

The FastStyle class provides the different colors and icons used to style the Fast Templates.

accent_fill_active = param.Color(readonly=False)

accent_fill_hover = param.Color(readonly=False)

accent_fill_rest = param.Color(readonly=False)

accent_foreground_active = param.Color(readonly=False)

accent_foreground_cut = param.Color(readonly=False)

accent_foreground_hover = param.Color(readonly=False)

accent_foreground_rest = param.Color(readonly=False)

neutral_outline_active = param.Color(readonly=False)

neutral_outline_hover = param.Color(readonly=False)

neutral_outline_rest = param.Color(readonly=False)

accent_base_color = param.Color(readonly=False)

background_color = param.Color(readonly=False)

collapsed_icon = param.String(readonly=False)

expanded_icon = param.String(readonly=False)

color = param.Color(readonly=False)

neutral_fill_card_rest = param.Color(readonly=False)

neutral_focus = param.Color(readonly=False)

neutral_foreground_rest = param.Color(readonly=False)

header_background = param.Color(readonly=False)

header_color = param.Color(readonly=False)

font = param.String(readonly=False)

font_url = param.String(readonly=False)

create_bokeh_theme()[source]

Returns a custom bokeh theme based on the style parameters

Returns

A Bokeh Theme

Return type

Dict