Api¶
-
class
dasher.
Api
(title=None, layout='bootstrap', layout_kw=None)[source]¶ Dasher api. The api allows generation of widgets and dash dependencies (for instances of
DasherCallback
). It is used byDasher
to generate interactive apps.Parameters: - title (str, optional) – Title of the app.
- layout (str or DasherLayout subclass, optional) – Name of a built-in layout or custom layout (DasherLayout subclass)
- layout_kw (dict, optional) – Dictionary of keyword arguments passed to the layout class.
-
static
generate_dependencies
(widgets, output_id, output_dependency='children')[source]¶ Generate input and output dependencies for a list of widgets. It generates an
dash.dependencies.Input
for each widgets’ underlying dash component using thevalue
property. Andash.dependencies.Output
is generated for output_id using thechildren
property.Parameters: - widgets (list of BaseWidget) – List of dasher widgets to generate dependencies for.
- output_id (str) – Id of the output.
- output_dependency (str, optional) – Property for the output dependency.
Returns: - output (dash.dependencies.Output) – Generated output dependency.
- input_list (list of dash.dependencies.Input) – List of generated input dependencies.
-
generate_widget
(name, x, label=None)[source]¶ Generate a dasher widget, which is a styled and labeled interactive component.
The type of the interactive component is determined based on the type of x using the selected widget specification of the layout.
Parameters: - name (str) – Name of the widget.
- x (object of supported type) – Object used to determine which interactive component is returned.
- label (str or None, optional) – Label of the component.
Returns: dasher.base.BaseWidget – Generated dasher widget.
See also
get_widget()
- Generates widget and returns the
layout
of the widget. get_component()
- Generates widget and returns the widgets’
component
.
-
generate_widgets
(kw, labels=None, group=None)[source]¶ Generate dasher widgets based on a dictionary.
Parameters: - kw (dict) – The keys of the dictionary define the names of the widgets and the type of the values is used to determine the type of the interactive widgets based on the selected component specification.
- labels (list or dict, optional) – Labels for the widgets. May be either a list of labels for kw in the order
of appearance or a dictionary mapping the keys of kw to the desired
labels. If
None
, the keys of kw are used for the labels directly. - group (str, optional) – If not
None
, group will be used as a suffix for each component / widget name in order to group widgets.
Returns: list of dasher.base.BaseWidget – List of generated dasher widgets.
See also
get_widgets()
- Generates widgets and returns the
layout
of the widgets. get_components()
- Generates widgets and returns the
component
of the widgets.
-
get_component
(name, x)[source]¶ Generate an interactive dash component. This is a convenience method, which first calls the
generate_widget
method and then directly returns the un-styled and un-labeledcomponent
of the widget.Parameters: - name (str) – Name of the component.
- x (object of supported type) – Object used to determine which interactive component is returned.
Returns: dash.development.base_component.Component – Generated dash component.
-
get_components
(kw, labels=None, group=None)[source]¶ Generate interactive components based on a dictionary. This is a convenience method, which first calls the
generate_widgets
method and then directly returns a list containing the un-styled and un-labeledcomponent
of the widgets.Parameters: - kw (dict) – The keys of the dictionary define the names of the widgets and the type of the values is used to determine the type of the interactive widgets based on the selected component specification.
- labels (list or dict, optional) – Labels for the widgets. May be either a list of labels for kw in the order
of appearance or a dictionary mapping the keys of kw to the desired
labels. If
None
, the keys of kw are used for the labels directly. - group (str, optional) – If not
None
, group will be used as a suffix for each component / widget name in order to group widgets.
Returns: list of dash.development.base_component.Component – List of generated interactive components.
-
get_widget
(name, x, label=None)[source]¶ Generate a styled and labeled interactive dash component. This is a convenience method, which first calls the
generate_widget
method and then directly returns thelayout
of the widget.Parameters: - name (str) – Name of the component.
- x (object of supported type) – Object used to determine which interactive component is returned.
- label (str or None, optional) – Label of the component.
Returns: dash.development.base_component.Component – Generated dash component.
-
get_widgets
(kw, labels=None, group=None)[source]¶ Generate interactive widgets based on a dictionary. This is a convenience method, which first calls the
generate_widgets
method and then directly returns a list containing thelayout
of the widgets.Parameters: - kw (dict) – The keys of the dictionary define the names of the widgets and the type of the values is used to determine the type of the interactive widgets based on the selected component specification.
- labels (list or dict, optional) – Labels for the widgets. May be either a list of labels for kw in the order
of appearance or a dictionary mapping the keys of kw to the desired
labels. If
None
, the keys of kw are used for the labels directly. - group (str, optional) – If not
None
, group will be used as a suffix for each component / widget name in order to group widgets.
Returns: list of dash.development.base_component.Component – List of generated interactive components.