Hello,
I’ve few problems with my code. When I use list in Input - arg children is “NoneType”. If I use single Input I have “list” as a type of children? Why? Does callback change type of arg? My code below:
Input as a list:
management_page= html.Div([
dcc.Input(id='name',placeholder='Type a name',type='text',value='name'),
dcc.Input(id='name1', placeholder='Type a name', type='text', value='name'),
html.Br(),
"Choose elements",
dcc.Dropdown(id='dropd',options=[
{'label': 'Graph', 'value': 'graph'},
{'label': 'Textarea', 'value': 'textarea'},
{'label': 'Datatable', 'value': 'dt'},
],
multi=True),
html.Button(id='button',children='Nazwa')
])
@app.callback(Output('tabs','children'),[Input('button','n_clicks_timestamp'),Input('name','value')], [State('tabs','children')]
)
def addNew(click, val,children):
pprint(type(children))
if click is not None:
tab = dcc.Tab(label='label_t'+str(val), value='val_t' + str(val))
tab_array.append(tab)
tab_array_names['value' + str(val)]=Tab('value' + (str(val))).page
pprint(type(children))
children+=[tab]
return children
else:
pass
Those pprints give: <type ‘list’> <type ‘NoneType’>,then give NoneType everytime.
If I write code like this:
management_page= html.Div([
dcc.Input(id='name',placeholder='Type a name',type='text',value='name'),
dcc.Input(id='name1', placeholder='Type a name', type='text', value='name'),
html.Br(),
"Choose elements",
dcc.Dropdown(id='dropd',options=[
{'label': 'Graph', 'value': 'graph'},
{'label': 'Textarea', 'value': 'textarea'},
{'label': 'Datatable', 'value': 'dt'},
],
multi=True),
html.Button(id='button',children='Nazwa')
])
@app.callback(Output('tabs','children'),Input('button','n_clicks_timestamp'),[State('tabs','children')]
)
def addNew(click,children):
pprint(type(children))
if click is not None:
tab = dcc.Tab(label='label_t'+str("x"), value='val_t' + str("x"))
tab_array.append(tab)
tab_array_names['value' + str("x")]=Tab('value' + (str("x"l))).page
pprint(type(children))
children+=[tab]
#children.append(tab)
pprint(type(children))
return children
else:
pass
Give me <type ‘list’> everytime.
Anyone knows why?