Base classes

class dasher.base.BaseLayout(title, widget_spec, credits=True)[source]

Abtract base class of a dasher layout, which is responsible for creating the layout of the dasher app.

The widget specification (widget_spec) is used to determine the types and the layout of the automatically generated interactive widgets.

A layout class also handles the addition of callbacks via the add_callback method and creates a suitable form of separation between the callbacks in the app layout. The standard way to do this is to generate a separate tab for each callback.

A child class must implement the abtract add_callback method and create the final app layout as its’ layout attribute. If the layout needs external stylesheets, the child class must announce this by creating an external_stylesheets attribute containing the list of required external stylesheets.

Parameters:
  • title (str) – Title of the dash app.
  • widget_spec (OrderedDict) – Widget specification used to determine the types of the interactive widgets.
  • credits (bool) – If true, dasher / layout credits are shown in the app.
Variables:
  • title (str) – Title of the dash app.
  • credits (bool) – If true, dasher / layout credits are shown in the app.
  • layout (list of dash.development.base_component.Component) – The final app layout (is assigned to the layout property of the dash app).
add_callback(callback, app, **kwargs)[source]

The implementation must handle the addition of callbacks to the layout and provide a suitable form of separation between the callbacks in the app layout. The standard way to do this is to generate a separate tab for each callback.

Parameters:
  • callback (Callback) – The callback to add to the layout.
  • app (dash.Dash) – The dash app.
  • **kwargs – Keyword arguments to override default layout settings for a callback.
class dasher.base.BaseWidget(name, x, label=None, dependecy='value')[source]

Abstract base class of a dasher widget. A dasher widget is an interactive control, which consists of an interactive dash component, a label and a final layout.

Parameters:
  • name (str) – Name of the widget.
  • x (object) – The object, whose type determines the type of the widget.
  • label (str) – The label for the dash component.
  • layout (dash.development.base_component.Component) – The layout is a styled and labeled version of component.
  • dependency (str, optional) – The attribute used for the dash.dependencies.Input dependency. Default: “value”.
Variables:
  • name (str) – Name of the widget.
  • x (object) – The object, whose type determines the type of the widget.
  • component (DasherComponent) – The interactive dash component.
  • label (str) – The label for the dash component.
  • layout (dash.development.base_component.Component) – The layout is a styled and labeled version of component.
  • dependency (str, optional) – The attribute used for the dash.dependencies.Input dependency. Default: “value”.
component

Abstract property. The implementation of the getter method in the child class must return the concrete component.

Returns:dash.development.base_component.Component – Generated dash component.
layout

Abstract property. The implementation of the getter method in the child class must return the final layout of the widget.

Returns:dash.development.base_component.Component – Generated dash component.
class dasher.base.Callback(name, description, f, kw, labels, widgets, outputs, inputs, layout_kw)[source]

This class contains the specification of a callback.

Parameters:
  • name (str) – Name of the callback.
  • description (str or None) – Additional description of the callback.
  • f (callable) – The callback function itself.
  • kw (dict) – The keyword arguments passed to the callback decorator.
  • labels (list or dict or None) – Labels for the widgets.
  • widgets (list of BaseWidget) – Generated dasher widgets for the callback.
  • outputs (dash.dependencies.Output or list of dash.dependencies.Output) – Output dependencies for the callback
  • inputs (list of dash.dependencies.Input) – Input dependencies for the callback
  • layout_kw (dict or None) – Keyword arguments to override default layout settings for the callback.
Variables:
  • name (str) – Name of the callback.
  • description (str or None) – Additional description of the callback.
  • f (callable) – The callback function itself.
  • kw (dict) – The keyword arguments passed to the callback decorator.
  • labels (list or dict or None) – Labels for the widgets.
  • widgets (list of BaseWidget) – Generated dasher widgets for the callback.
  • outputs (dash.dependencies.Output or list of dash.dependencies.Output) – Output dependencies for the callback.
  • inputs (list of dash.dependencies.Input) – Input dependencies for the callback.
  • layout_kw (dict or None) – Keyword arguments to override default layout settings for the callback.
class dasher.base.CustomWidget(component, dependency='value')[source]

Wrapper class for custom widgets. Used to fully customize a widget including the dependency attribute.

Parameters:
  • component (dash.development.base_component.Component) – Custom interactive dash component.
  • dependency (str, optional) – The attribute used for the dash.dependencies.Input dependency. Default: “value”.
class dasher.base.WidgetPassthroughMixin(name, x, label=None)[source]

Passthrough mixin to support custom dash components and custom widgets.

component

Abstract property. The implementation of the getter method in the child class must return the concrete component.

Returns:dash.development.base_component.Component – Generated dash component.
dasher.base.generate_callback_id(name)[source]

Get callback id from name. It is a lowercase version of name, where all non-alphanumeric characters are replaced by underscores.

Parameters:name (str) – The callback name to generate an id from.
Returns:str – Lowercase version of name, where all non-alphanumeric characters are replaced by underscores.