我想阻止用戶在下面的腳本中按下“提交”按鈕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
提交
取消