如何在Dash Python中将进度条与进程链接

如何在Dash Python中将进度条与进程链接,python,plotly-dash,Python,Plotly Dash,我试图将一个流程与进度条联系起来……但在任何地方都找不到解决方案。我唯一能找到的是下面的代码…但我想把后台进程链接到进度条。请帮忙 import dash_bootstrap_components as dbc import dash_core_components as dcc import dash_html_components as html from dash.dependencies import Input, Output progress = html.Div( [

我试图将一个流程与进度条联系起来……但在任何地方都找不到解决方案。我唯一能找到的是下面的代码…但我想把后台进程链接到进度条。请帮忙

import dash_bootstrap_components as dbc
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output

progress = html.Div(
    [
        dcc.Interval(id="progress-interval", n_intervals=0, interval=500),
        dbc.Progress(id="progress"),
    ]
)

@app.callback(
    [Output("progress", "value"), Output("progress", "children")],
    [Input("progress-interval", "n_intervals")],
)
def update_progress(n):
    # check progress of some background process, in this example we'll just
    # use n_intervals constrained to be in 0-100
    progress = min(n % 110, 100)
    # only add text after 5% progress to ensure text isn't squashed too much
    return progress, f"{progress} %" if progress >= 5 else ""