我想阻止用户在下面的脚本中按下“提交”按钮30秒钟。我将如何去做呢?这是我的代码当前的外观:import dashfrom dash.dependencies import Input, Output, Stateimport dash_core_components as dccimport dash_html_components as htmlapp = dash.Dash()app.layout = html.Div([ dcc.Input(id='my-id', value='initial value', type="text"), html.Button('Submit', id='button'), html.Div(id='my-div')])@app.callback( Output(component_id='my-div', component_property='children'), [Input('button', 'n_clicks')], state=[State(component_id='my-id', component_property='value')])def update_output_div(n_clicks, input_value): return 'You\'ve entered "{}" and clicked {} times'.format(input_value, n_clicks)if __name__ == '__main__': app.run_server()有谁知道我该如何阻止用户按下按钮30秒钟?预先感谢。编辑15/08/2018 9:30 GMT对stevepastelan的回应:import dashfrom dash.dependencies import Input, Output, Stateimport dash_core_components as dccimport dash_html_components as htmlapp = dash.Dash()app.layout = html.Div([ dcc.Input(id='my-id', value='initial value', type="text"), html.Button('Submit', id='button'), html.Div([dcc.Interval( id='interval-component', interval=1 * 3000, # in milliseconds n_intervals=0)]), html.Div(id='my-div')])@app.callback( Output(component_id='my-div', component_property='children'), [Input('button', 'n_clicks')], [Input('interval-component', 'n_intervals')], state=[State(component_id='my-id', component_property='value')])def update_output_div(n_clicks,n_intervals, input_value): return 'You\'ve entered "{}" and clicked {} times'.format(input_value, n_clicks)if __name__ == '__main__': app.run_server()
添加回答
举报
0/150
提交
取消