forked from kapot65/dash-treeview-antd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusage.py
57 lines (46 loc) · 1.5 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
import dash
import dash_html_components as html
import dash_treeview_antd
from dash.dependencies import Input, Output
app = dash.Dash('')
app.scripts.config.serve_locally = True
app.css.config.serve_locally = True
app.layout = html.Div([
dash_treeview_antd.TreeView(
id='input',
multiple=True,
checkable=True,
checked=['0-0-1'],
selected=[],
expanded=['0'],
data={
'title': 'Parent',
'key': '0',
'children': [{
'title': 'Child',
'key': '0-0',
'children': [
{'title': 'Subchild1', 'key': '0-0-1'},
{'title': 'Subchild2', 'key': '0-0-2'},
{'title': 'Subchild3', 'key': '0-0-3'},
],
}]}
),
html.Div(id='output-checked'),
html.Div(id='output-selected'),
html.Div(id='output-expanded')
])
@app.callback(Output('output-checked', 'children'),
[Input('input', 'checked')])
def _display_checked(checked):
return 'You have checked {}'.format(checked)
@app.callback(Output('output-selected', 'children'),
[Input('input', 'selected')])
def _display_selected(selected):
return 'You have checked {}'.format(selected)
@app.callback(Output('output-expanded', 'children'),
[Input('input', 'expanded')])
def _display_expanded(expanded):
return 'You have selected {}'.format(expanded)
if __name__ == '__main__':
app.run_server(debug=True)