Hi,
So my project has been using the unofficial Tabs branch for a while and using it, I created a dropdown and upon its selection different tabs would appear. This worked perfectly (code below) but then I decided to upgrade to the official version with the Tab component, and I’ve updated the code below (the init_tabs() method) to return a list of dcc.Tab(...)
instead of a dictionary. However, this now doesn’t work anymore :(.
The callback triggers but the Tabs children don’t change anymore, unless I refresh the page or start off with a different default value for the dropdown. I tried various changes, like declaring the Tabs without children in the layout and only returning the children but that doesn’t work either.
Is this supposed to be like this now, or is there a way around it? Please help.
P.S The code below is an extract of a much larger multi page app so it might not really work…
P.S.2 Dash is one of the best things that I discovered on the internet ever.
layout = html.Div([
html.Div(dcc.Dropdown(id='app-3-dropdown', options=[{'label': 'Below Ground Assets', 'value': 'BG'}, {'label': 'Above Ground Assets', 'value': 'AG'}, {'label': 'Other Assets', 'value': 'OTH'}], value = 'BG', clearable=False), className='three columns'),
html.Div([
html.Div([html.Div(id='tt')], className = 'two columns'),
html.Div([html.Div(id='tab-output')],
id='fixed-width', className = 'ten columns', style= {'height': '550px', 'overflow':'scroll'})
], id='tabs', className = 'row'))
])
def init_tabs(asset_type = 'bg'):
if asset_type == 'bg':
return [{'label': 'H&S Road', 'value': 1},
{'label': 'Environmental', 'value': 2},
{'label': 'Interruption', 'value': 3},
{'label': 'Customer Satifaction', 'value': 4},
{'label': 'Repair', 'value': 5},
{'label': 'Flooding - Compensation', 'value': 6},
{'label': 'Complex Re-Instatement Cost', 'value': 7}
]
else:
return [{'label': 'Reputational Cost', 'value': 8},
{'label': 'Trafic Disruption', 'value': 9},
{'label': 'Other Regulatory', 'value': 10}]
@app.callback(Output('tt', 'children'), [Input('app-3-dropdown', 'value')])
def display_tabs(value):
print('hello')
if value in assets.keys():
print(value)
return dcc.Tabs(
id='tabs',
children=init_tabs(value),
vertical=True)