Multiple callback error

ok… so your requirement is whenever a new value from the ticker is selected , a new tab needs to be appended to the existing set of tabs and it shouldn’t be selected .???

Correct. Whichever tab was already selected should still be selected.

I’m starting to realize that this is probably more effort than it’s worth. There’s probably a better way of doing things (ie - with dcc.Store), rather than this.

Hi I have a similar problem I have a datatable that i wish to fill with diffrent types of data depending on what i pick from a dropdown. Additinaly i only want to update when i click a button.

However i get the same error:
Traceback (most recent call last):
File “testTab.py”, line 230, in
[State(‘StatToolList’,component_property=‘value’)]
File “C:\Program Files\Anaconda\4.4.0\lib\site-packages\dash\dash.py”, line 1156, in callback
self._validate_callback(output, inputs, state)
File “C:\Program Files\Anaconda\4.4.0\lib\site-packages\dash\dash.py”, line 865, in _validate_callback
list(layout.keys()) + (
AttributeError: ‘Div’ object has no attribute ‘keys’

html.Div([
            html.H3('Tab content 4'),
            
            dcc.Dropdown(
                            id = 'StatToolList',
                            options = [{"label":TOOL,"value":TOOL} for TOOL in tools.TOOL_NUMBER.tolist()],
                            multi = True,
                            placeholder = 'Select Tool Number',
                            style={'width':'50%','marginTop':'2px','display': 'inline-block'}),
            html.Button('Submit', id='ExStatButton'),
            dash_table.DataTable(id='DataStat',
                                 data=[],
                                 columns=[])

        ])

@app.callback(
        [Output('DataStat','data'),
        Output('DataStat','columns')],
        [Input('ExStatButton','n_clicks')],
        [State('StatToolList',component_property='value')]
        )
def Update_Stat_Table(n_clicks,Tool_List):
    #if n_clicks is None:
    df_stat=Create_Process_analysis(Tool_List)
    columns=[{"name":col,"id":col} for col in list(df_stat.columns)]
    data=df_stat.to_dict("records")

    return data,columns

@Lindvall do you have the latest version of dash (v1.0.2)? AttributeError: 'Div' object has no attribute 'keys' is masking some other error in your code, but this was fixed in the most recent release.

No I have v1.0.0, is there anything else I could, besides updating my version?

That error happened when a callback was being connected to a nonexistent ID. I don’t see any problems in your code though, and a simplified version of your code seems to run for me (if I prepend app.layout = to the snippet above)

1 Like

Yeah i dont know what happened but I re-structured the callback and this is working for me.

@app.callback(
        [Output('DataStat','data'),
        Output('DataStat','columns')],
        [Input('ExStatButton','n_clicks')],
        [State('StatToolList','value'),
         State('DataStat','data'),
         State('DataStat','columns')],
        )
def Update_Stat_Table(n_clicks,Tool_List,DataInit,ColumnsInit):
    if n_clicks is not None:
        df_stat=Create_Process_analysis(Tool_List)
        columns=[{"name":col,"id":col} for col in list(df_stat.columns)]
        data=df_stat.to_dict("records")
        return data,columns
        
    else:
      
        return DataInit,ColumnsInit
1 Like