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, sidebar_width, 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, _actions

accent_base_color = param.String(default=’’, label=’Accent base color’)

Optional body accent color override.

background_color = param.String(default=’’, label=’Background color’)

Optional body background color override.

corner_radius = param.Integer(bounds=(0, 25), default=3, inclusive_bounds=(True, True), label=’Corner radius’)

The corner radius applied to controls.

font = param.String(default=’’, label=’Font’)

The font to use.

font_url = param.String(default=’’, label=’Font url’)

A font url to import.

header_neutral_color = param.String(default=’’, label=’Header neutral color’)

Optional header neutral color override.

header_accent_base_color = param.String(default=’’, label=’Header accent base color’)

Optional header accent color override.

neutral_color = param.String(default=’’, label=’Neutral color’)

Optional body neutral color override.

theme_toggle = param.Boolean(bounds=(0, 1), default=True, label=’Theme toggle’)

If True a switch to toggle the Theme is shown.

shadow = param.Boolean(bounds=(0, 1), default=False, label=’Shadow’)

Optional shadow override. Whether or not to apply shadow.

sidebar_footer = param.String(default=’’, label=’Sidebar footer’)

A HTML string appended to the sidebar

main_layout = param.Selector(default=’card’, objects=[‘’, ‘card’])

What to wrap the main components into. Options are ‘’ (i.e. none) and ‘card’ (Default). Could be extended to Accordion, Tab etc. in the future.

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.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, site_url, meta_description, meta_keywords, meta_author, meta_refresh, meta_viewport, base_url, base_target, header_background, header_color, theme, _actions

panel.template.react.ReactTemplate: main, sidebar_width, compact, cols, breakpoints, row_height, dimensions, prevent_collision, save_layout

panel.template.fast.base.FastBaseTemplate: 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()

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


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(default=PosixPath(‘/home/runner/work/panel/panel/panel/template/fast/css/fast_root_dark.css’), label=’Base css’, search_paths=[])

style = param.ClassSelector(class_=<class ‘panel.template.fast.theme.FastStyle’>, default=FastStyle(accent_base_color=’#E1477E’, background_color=’#181818’, collapsed_icon=’n<svg style=”stroke: var(–accent-fill-rest);” width=”18” height=”18” viewBox=”0 0 18 18” fill=”none” xmlns=”http://www.w3.org/2000/svg” slot=”collapsed-icon”>n <path d=”M15.2222 1H2.77778C1.79594 1 1 1.79594 1 2.77778V15.2222C1 16.2041 1.79594 17 2.77778 17H15.2222C16.2041 17 17 16.2041 17 15.2222V2.77778C17 1.79594 16.2041 1 15.2222 1Z” stroke-linecap=”round” stroke-linejoin=”round”></path>n <path d=”M9 5.44446V12.5556” stroke-linecap=”round” stroke-linejoin=”round”></path>n <path d=”M5.44446 9H12.5556” stroke-linecap=”round” stroke-linejoin=”round”></path>n</svg>n’, color=’#ffffff’, corner_radius=3, expanded_icon=’n<svg style=”stroke: var(–accent-fill-rest);” width=”18” height=”18” viewBox=”0 0 18 18” fill=”none” xmlns=”http://www.w3.org/2000/svg” slot=”expanded-icon”>n <path d=”M15.2222 1H2.77778C1.79594 1 1 1.79594 1 2.77778V15.2222C1 16.2041 1.79594 17 2.77778 17H15.2222C16.2041 17 17 16.2041 17 15.2222V2.77778C17 1.79594 16.2041 1 15.2222 1Z” stroke-linecap=”round” stroke-linejoin=”round”></path>n <path d=”M5.44446 9H12.5556” stroke-linecap=”round” stroke-linejoin=”round”></path>n</svg>n’, font=’Open Sans, sans-serif’, font_url=’//fonts.googleapis.com/css?family=Open+Sans’, header_accent_base_color=’#ffffff’, header_background=’#313131’, header_color=’#ffffff’, header_neutral_color=’#ffffff’, name=’FastStyle00097’, neutral_color=’#000000’, neutral_fill_card_rest=’#212121’, neutral_focus=’#717171’, neutral_foreground_rest=’#e5e5e5’, shadow=False), label=’Style’)

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), accessing the property will 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(default=PosixPath(‘/home/runner/work/panel/panel/panel/template/fast/css/fast_root_default.css’), label=’Base css’, search_paths=[])

style = param.ClassSelector(class_=<class ‘panel.template.fast.theme.FastStyle’>, default=FastStyle(accent_base_color=’#A01346’, background_color=’#ffffff’, collapsed_icon=’n<svg style=”stroke: var(–accent-fill-rest);” width=”18” height=”18” viewBox=”0 0 18 18” fill=”none” xmlns=”http://www.w3.org/2000/svg” slot=”collapsed-icon”>n <path d=”M15.2222 1H2.77778C1.79594 1 1 1.79594 1 2.77778V15.2222C1 16.2041 1.79594 17 2.77778 17H15.2222C16.2041 17 17 16.2041 17 15.2222V2.77778C17 1.79594 16.2041 1 15.2222 1Z” stroke-linecap=”round” stroke-linejoin=”round”></path>n <path d=”M9 5.44446V12.5556” stroke-linecap=”round” stroke-linejoin=”round”></path>n <path d=”M5.44446 9H12.5556” stroke-linecap=”round” stroke-linejoin=”round”></path>n</svg>n’, color=’#00aa41’, corner_radius=3, expanded_icon=’n<svg style=”stroke: var(–accent-fill-rest);” width=”18” height=”18” viewBox=”0 0 18 18” fill=”none” xmlns=”http://www.w3.org/2000/svg” slot=”expanded-icon”>n <path d=”M15.2222 1H2.77778C1.79594 1 1 1.79594 1 2.77778V15.2222C1 16.2041 1.79594 17 2.77778 17H15.2222C16.2041 17 17 16.2041 17 15.2222V2.77778C17 1.79594 16.2041 1 15.2222 1Z” stroke-linecap=”round” stroke-linejoin=”round”></path>n <path d=”M5.44446 9H12.5556” stroke-linecap=”round” stroke-linejoin=”round”></path>n</svg>n’, font=’Open Sans, sans-serif’, font_url=’//fonts.googleapis.com/css?family=Open+Sans’, header_accent_base_color=’#ffffff’, header_background=’#00aa41’, header_color=’#ffffff’, header_neutral_color=’#ffffff’, name=’FastStyle00096’, neutral_color=’#000000’, neutral_fill_card_rest=’#F7F7F7’, neutral_focus=’#888888’, neutral_foreground_rest=’#2B2B2B’, shadow=True), label=’Style’)

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.

background_color = param.String(default=’#ffffff’, label=’Background color’)

neutral_color = param.String(default=’#000000’, label=’Neutral color’)

accent_base_color = param.String(default=’#A01346’, label=’Accent base color’)

collapsed_icon = param.String(default=’n<svg style=”stroke: var(–accent-fill-rest);” width=”18” height=”18” viewBox=”0 0 18 18” fill=”none” xmlns=”http://www.w3.org/2000/svg” slot=”collapsed-icon”>n <path d=”M15.2222 1H2.77778C1.79594 1 1 1.79594 1 2.77778V15.2222C1 16.2041 1.79594 17 2.77778 17H15.2222C16.2041 17 17 16.2041 17 15.2222V2.77778C17 1.79594 16.2041 1 15.2222 1Z” stroke-linecap=”round” stroke-linejoin=”round”></path>n <path d=”M9 5.44446V12.5556” stroke-linecap=”round” stroke-linejoin=”round”></path>n <path d=”M5.44446 9H12.5556” stroke-linecap=”round” stroke-linejoin=”round”></path>n</svg>n’, label=’Collapsed icon’)

expanded_icon = param.String(default=’n<svg style=”stroke: var(–accent-fill-rest);” width=”18” height=”18” viewBox=”0 0 18 18” fill=”none” xmlns=”http://www.w3.org/2000/svg” slot=”expanded-icon”>n <path d=”M15.2222 1H2.77778C1.79594 1 1 1.79594 1 2.77778V15.2222C1 16.2041 1.79594 17 2.77778 17H15.2222C16.2041 17 17 16.2041 17 15.2222V2.77778C17 1.79594 16.2041 1 15.2222 1Z” stroke-linecap=”round” stroke-linejoin=”round”></path>n <path d=”M5.44446 9H12.5556” stroke-linecap=”round” stroke-linejoin=”round”></path>n</svg>n’, label=’Expanded icon’)

color = param.String(default=’#00aa41’, label=’Color’)

neutral_fill_card_rest = param.String(default=’#F7F7F7’, label=’Neutral fill card rest’)

neutral_focus = param.String(default=’#888888’, label=’Neutral focus’)

neutral_foreground_rest = param.String(default=’#2B2B2B’, label=’Neutral foreground rest’)

header_background = param.String(default=’#00aa41’, label=’Header background’)

header_neutral_color = param.String(default=’#ffffff’, label=’Header neutral color’)

header_accent_base_color = param.String(default=’#ffffff’, label=’Header accent base color’)

header_color = param.String(default=’#ffffff’, label=’Header color’)

font = param.String(default=’Open Sans, sans-serif’, label=’Font’)

font_url = param.String(default=’//fonts.googleapis.com/css?family=Open+Sans’, label=’Font url’)

corner_radius = param.Integer(default=3, inclusive_bounds=(True, True), label=’Corner radius’)

shadow = param.Boolean(bounds=(0, 1), default=True, label=’Shadow’)

create_bokeh_theme()[source]

Returns a custom bokeh theme based on the style parameters

Returns

A Bokeh Theme

Return type

Dict