Python plotly破折号按钮链接到网页

2024-06-09 10:14:00 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用的是PythonDash,我希望在我的表格下面有一个按钮,当点击时,它会将用户带到一个特定的网页。我对使用dash非常陌生,所以我甚至不确定这个功能是否存在。我确实专门搜索了pythondash这个主题,结果空手而归。非常感谢您的帮助,谢谢


Tags: 用户功能网页主题按钮表格dash陌生
1条回答
网友
1楼 · 发布于 2024-06-09 10:14:00

use this for button example and to learn more please use this

link:https://dash.plotly.com/dash-core-components.

import dash
import dash_html_components as html
import dash_core_components as dcc

external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div([
    html.Div(dcc.Input(id='input-box', type='text')),
    html.Button('Submit', id='button'),
    html.Div(id='output-container-button',
             children='Enter a value and press submit')
])


@app.callback(
    dash.dependencies.Output('output-container-button', 'children'),
    [dash.dependencies.Input('button', 'n_clicks')],
    [dash.dependencies.State('input-box', 'value')])
def update_output(n_clicks, value):
    return 'The input value was "{}" and the button has been clicked {} times'.format(
        value,
        n_clicks
    )


if __name__ == '__main__':
    app.run_server(debug=True)

相关问题 更多 >