-
Notifications
You must be signed in to change notification settings - Fork 0
/
usage.py
64 lines (55 loc) · 1.47 KB
/
usage.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import dash_tour_component
import dash
from dash.dependencies import Input, Output
import dash_html_components as html
import dash_core_components as dcc
app = dash.Dash(__name__)
app.layout = html.Div([
dash_tour_component.DashTour(
steps=[
{
'selector': '[id="my_first_step"]',
'content': "This is my first step",
# 'position': "center"
},
{
'selector': '[id="my_second_step"]',
'content': '', # content empty updated in callback
}
],
isOpen=False,
id="tour_component",
children=html.Div(),
rounded=7
),
html.Button("Open Tour", id='open_tour_button'),
html.Div("Test 1", id='my_first_step', style={'text-align': 'center'}),
html.Div(style={'height': '200px'}),
html.Div("Test 2", id='my_second_step', style={'text-align': 'center'}),
html.Br(),
html.Div(id='current_step_div', style={'text-align': 'center'})
])
@app.callback(
Output('tour_component', 'isOpen'),
[Input('open_tour_button', 'n_clicks')],
prevent_initial_call=True
)
def open_tour_component(value):
return True
@app.callback(
Output('current_step_div', 'children'),
Output('tour_component', 'children'),
Input('tour_component', 'CurrentStep'),
prevent_initial_call=True
)
def on_current_step_change(step):
# Override the content at step two
if step == 2:
content = html.Div([
dcc.Input(placeholder='some random input')
])
else:
content = ""
return html.H3(f'The current step is {step}'), content
if __name__ == '__main__':
app.run_server(debug=True)