ssb_dash_framework.setup package

ssb_dash_framework.setup.app_setup module

app_setup(port, service_prefix, domain, stylesheet)

Set up and configure a Dash application with the specified parameters.

Parameters:
  • port (int) – The port number for the Dash application.

  • service_prefix (str) – The service prefix used for constructing the app’s pathname.

  • domain (str) – The domain name where the app is hosted.

  • stylesheet (str) – The name of the Bootstrap theme to apply to the app. Must be a key in theme_map.

Returns:

Configured Dash application instance.

Return type:

Dash

Notes

  • The function maps the stylesheet parameter to a Bootstrap theme using theme_map.

  • A callback is registered within the app to toggle the visibility of an element with the ID main-varvelger based on the number of clicks on sidebar-varvelger-button.

Examples

>>> app = app_setup(port=8050, service_prefix="/", domain="localhost", stylesheet="slate")
>>> app.run_server() 

ssb_dash_framework.setup.main_layout module

main_layout(window_list, tab_list, variable_list=None, default_values=None)

Generates the main layout for the Dash application.

Parameters:
  • window_list (list[html.Div]) – A list of modal components to be included in the sidebar.

  • tab_list (list[html.Div | dbc.Tab]) – A list of tab objects, each containing a layout method and a label attribute.

  • variable_list (list[str] | None) – A list of variable selection components to be included in the main layout. Defaults to all existing VariableSelectorOptions.

  • default_values (dict[str, Any] | None, optional) – Default values for the variable selector. Defaults to None.

Returns:

A Dash Container component representing the app’s main layout.

Return type:

dbc.Container

Notes

  • The function includes an alert handler modal and a toggle button for the variable selector.

  • Each tab in tab_list must implement a layout() method and have a label attribute.

ssb_dash_framework.setup.variableselector module

class VariableSelector(selected_inputs, selected_states, default_values=None)

Bases: object

Class containing options for shared states between modules in the framework.

Notes

  • Each module should have its own instance of the VariableSelector in its __init__ function.

Parameters:
  • selected_inputs (list[str])

  • selected_states (list[str])

  • default_values (dict[str, str | int | float] | None)

get_inputs()

Retrieves a list of Dash Input objects for selected inputs.

Return type:

list[Input]

get_option(variable_name)

Retrieves a VariableSelectorOption by variable name.

Return type:

VariableSelectorOption

Parameters:

variable_name (str)

get_output_object(variable)

Creates a Dash Output object for a given variable.

Use this if you need to have a module output back to the shared VariableSelector in the main layout.

Parameters:

variable (str) – The variable name.

Returns:

The corresponding Dash Output object.

Return type:

Output

Raises:

ValueError – If the name (title) does not exist in any of the options available to the VariableSelector

get_states()

Retrieves a list of Dash State objects for selected states.

Return type:

list[State]

layout()

Generate a list of Dash Bootstrap cards based on selected variable keys.

Return type:

list[Row]

class VariableSelectorOption(variable_title)

Bases: object

Represents an individual variable selection option.

Parameters:

variable_title (str)

set_variables(variable_list)

Sets the list of variables for the VariableSelector.

Parameters:

variable_list (str | List[str]) – List of variable names to be added to the VariableSelector.

Raises:

TypeError – If variable_list is not a string or a list of strings.

Return type:

None

Examples

>>> set_variables("orgnr")
>>> set_variables("kvartal")
>>> set_variables(["foretak", "aar"])