-
-
Notifications
You must be signed in to change notification settings - Fork 324
/
Copy pathset_update.py
38 lines (31 loc) · 1022 Bytes
/
set_update.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
from idom import component, html, run, use_state
@component
def Grid():
line_size = 5
selected_indices, set_selected_indices = use_state(set())
def make_handle_click(index):
def handle_click(event):
set_selected_indices(selected_indices | {index})
return handle_click
return html.div(
{"style": {"display": "flex", "flex-direction": "row"}},
[
html.div(
{
"on_click": make_handle_click(index),
"style": {
"height": "30px",
"width": "30px",
"background_color": "black"
if index in selected_indices
else "white",
"outline": "1px solid grey",
"cursor": "pointer",
},
"key": index,
}
)
for index in range(line_size)
],
)
run(Grid)