我看到了这个Progress
&;Interval
组件的示例,用于在破折号中显示进度:
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 ""
但是,我找不到任何一个例子来说明如何正确地将进度条链接到某个后台进程。在
例如,如果我有一个带有常规for
循环的回调,如何显示这个for
循环的进度(例如,如果我从100开始在第10个元素上,我希望它在进度条中显示为10%?在
目前没有回答
相关问题 更多 >
编程相关推荐