Py.Cafe

BSd3v./

dash-async-demo

Dash Async Demo

DocsPricing
  • app.py
  • dash-2.18.2-py3-none-any.whl
  • requirements.txt
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# check out https://dash.plotly.com/ for documentation
# And check out https://py.cafe/maartenbreddels for more examples
from dash import Dash, Input, Output, callback, dcc, html, set_props, ctx
import time

app = Dash(__name__)
md = """
# Dash demo

See [The dash examples index](https://dash-example-index.herokuapp.com/) for more examples.
"""

test = 10

test_components = [html.Div([html.Div(id='testout'+str(x)),
    dcc.Interval(id='testing'+str(x), interval=30+(10*x))]) for x in range(test)]

# Define the layout of the Dash app
app.layout = html.Div(children=[
    html.H1(children='Hello Dash'),
    html.Div(children='Dash: A web application framework for Python.'),
    html.Button('Testing', id='test'),
    *test_components
])

for x in range(test):
    @app.callback(
        Output('testout'+str(x),'children'),
        Input('test','n_clicks'),
        Input(f'testing'+str(x), 'n_intervals')
    )
    def rawr(n_clicks: int, n_interval: int):
        time.sleep(4/x)
        return ctx.triggered[0]['value']