为了账号安全,请及时绑定邮箱和手机立即绑定

在Python + Dash中禁用“提交”按钮30秒钟

在Python + Dash中禁用“提交”按钮30秒钟

跃然一笑 2021-05-14 14:18:38
我想阻止用户在下面的脚本中按下“提交”按钮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()
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 168 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号