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:
- 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"])