I have 3 chained dropdowns but i want them all to be disabled (not just options, but the dropdown altogether) based on a value in my radioitem. From my code right now:
initialoptions = ["All music", "I choose"]
dcc.RadioItems(
id='initialoptions',
options=[{'label': k, 'value': k} for k in initialoptions],
value="All music",
style={'textAlign':'center', 'font-family' : 'Roboto',"fontSize" : 14}
@app.callback(
Output('artistnames', 'disabled'),
Output('albumnames', 'disabled'),
Output('songnames', 'disabled'),
Input('initialoptions', 'value'))
def disable_options(selected_option):
if selected_option=="All music":
return True
else:
return False
i would expect that once you press "I choose" it would return False and otherwise they would stay disabled. However I cannot seem to get it to disable them altogether, any ideas? I can give the dropdowns the disabled=true to begin with but then they won't enable again by pressing the other option.
I found the solution:
If you want to change 3 outputs at once, the return must give a tuple with 1 return for each output which means the solution is changing
return True
else:
return False
to:
return (True,True,True)
else:
return (False,False,False)