-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_2.py
More file actions
46 lines (39 loc) · 1.15 KB
/
app_2.py
File metadata and controls
46 lines (39 loc) · 1.15 KB
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
import dash
from dash import html
from dash.dependencies import Input, Output, ALL, MATCH
import feffery_antd_components as fac
from feffery_dash_utils.style_utils import style
app = dash.Dash(__name__)
app.layout = html.Div(
fac.AntdSpace(
[
fac.AntdSpace(
[
fac.AntdTooltip(
fac.AntdButton(
f"按钮{i}",
id = {"type":"botton", "index":i},
type="primary"
),
id={"type":"tooltip", "index":i}
)
for i in range(10)
],
wrap=True
)
],
direction="vertical",
style=style(width="100%")
),
style=style(padding=50)
)
# 这里使用的是ALL的解决办法
@app.callback(
Output({"type":"botton", "index":ALL}, "danger"),
Input({"type":"botton", "index":ALL}, "nClicks"),
prevent_initial_call=True
)
def update_bottons(nClicksList):
return [bool(nClicks) for nClicks in nClicksList]
if __name__ == "__main__":
app.run(debug=True)