I am working on a multi-tab dashboard with DASH and I have some callback problems.
1. Problem: Button enabled / disbaled in connection with a checkbox: On my first tab there is a button that leads to the next tab and that should only be enabled if a checkbox is clicked. This is working. But if I unclick the checkbox, the button is still enabled even tho it should be disabled then again. Here my code:
@callback(
Output(component_id='start-button',component_property='disabled'),
Input(component_id='checklist-
conditions',component_property='value'),prevent_initial_call=True
)
def enable_start_button(conditions_read):
if conditions_read == "I herby comfirm that I read...":
disabled = False
if conditions_read != "I herby comfirm that I read...":
disabled = False
2. Problem: Button enabled if more pre-conditions are set: A button should be enabled only if 4 conditions are fulfilled. However, the button is already enabled if only one of the 4 conditions is fulfilled. Here the code:
@callback(
Output(component_id='continue1-button',component_property='disabled'),
Input(component_id='contact-first-name',component_property='value'),
Input(component_id='contact-last-name',component_property='value'),
Input(component_id='contact-mail',component_property='value'),
Input(component_id='contact-company',component_property='value'),
prevent_initial_call=True
)
def
enable_start_button(first_name_checked,last_name_checked,mail_checked,company_checked):
if first_name_checked != None and last_name_checked != None and mail_checked !=
None and company_checked!= None:
disabled = False
3. Problem: 2 inputs should be enabled (here dropdowns) if certain conditions are fulfilled. However, only one of the 2 inputs gets enabled, the other stays grey. For example, it should be possible to choose a new wind turbine type and rating if before the user selects in another dropdown as a turbine type = new. Here the code:
@callback(
Output(component_id='new-turbine',component_property='disabled'),
Output(component_id='new-turbine-rating',component_property='disabled'),
Input(component_id='turbine-type',component_property='value'),
prevent_inital_callback = True
)
def enable_new_turbine(new_turbine):
if new_turbine == "New":
disabled1 = False
disabled2 = False
I am already searching for a longer time for a solution since it seems not to be such a difficult problem. But I still have not found anything and I would be glad for any help! Thanks a lot and best regards, Lexy.