-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmy_panel_5.py
More file actions
79 lines (67 loc) · 2.2 KB
/
Copy pathmy_panel_5.py
File metadata and controls
79 lines (67 loc) · 2.2 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from chartlets import Component, Input, Output
from chartlets.components import Box, Button, Dialog, Typography
from server.context import Context
from server.panel import Panel
panel = Panel(__name__, title="Panel E")
# noinspection PyUnusedLocal
@panel.layout()
def render_panel(
ctx: Context,
) -> Component:
open_button = Button(id="open_button", text="Open Dialog")
okay_button = Button(id="okay_button", text="Okay")
not_okay_button = Button(id="not_okay_button", text="Not okay")
dialog = Dialog(
id="dialog",
title="This is a modal dialog",
titleProps={
"id": "dialog-title",
"variant": "h6",
"style": {"fontWeight": "bold", "color": "darkblue"},
},
content="You can add your content here in the dialog.",
contentProps={
"id": "dialog-description",
"variant": "body1",
"style": {"padding": "16px", "color": "gray"},
},
children=[okay_button, not_okay_button],
disableEscapeKeyDown=True,
fullScreen=False,
fullWidth=True,
maxWidth="sm",
scroll="paper",
ariaLabel="dialog-title",
ariaDescribedBy="dialog-description",
)
info_text = Typography(id="info_text", color="grey")
return Box(
style={
"display": "flex",
"flexDirection": "column",
"width": "100%",
"height": "100%",
"gap": "6px",
},
children=[open_button, dialog, info_text],
)
# noinspection PyUnusedLocal
@panel.callback(Input("open_button", "clicked"), Output("dialog", "open"))
def dialog_on_open(ctx: Context, button) -> bool:
return True
# noinspection PyUnusedLocal
@panel.callback(
Input("okay_button", "clicked"),
Output("dialog", "open"),
Output("info_text", "text"),
)
def dialog_on_close(ctx: Context, button) -> tuple[bool, str]:
return False, "Okay button was clicked!"
# noinspection PyUnusedLocal
@panel.callback(
Input("not_okay_button", "clicked"),
Output("dialog", "open"),
Output("info_text", "text"),
)
def dialog_on_close(ctx: Context, button) -> tuple[bool, str]:
return False, "Not okay button was clicked!"