Say I have a model with 20 parameters and I made one input component for each param.
[dcc.Input(type = 'number', id = 'input %i'%i) for i in range(20)]
I want to have one button html.Button('populate parameters', id = 'button populate')
that is supposed to populate best pre-fitted value for all the inputs.
Code should look like below, except it doesn't work.
for i in range(20):
@app.callback(
dash.dependencies.Output('input %i'%i, 'value'),
[dash.dependencies.Input('button populate', 'n_clicks')]
)
def update(ignore):
return np.random.uniform()
Do I have to write 20 callbacks for each output with identical functionality? I can't find a way to make them in one go (loop?)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…