-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapp.py
83 lines (67 loc) · 2.34 KB
/
app.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import dash
from dash import Dash, html, dcc, Input, Output, State, clientside_callback
import dash_bootstrap_components as dbc
from utils.nav import navbar
from utils.utils import example_apps
# need these two imports for the custom components
import dash_mantine_components
import dash_iconify
# syntax highlighting light or dark
light_hljs = "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.4.0/styles/stackoverflow-light.min.css"
dark_hljs = "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.4.0/styles/stackoverflow-dark.min.css"
# stylesheet with the .dbc class
dbc_css = "https://cdn.jsdelivr.net/gh/AnnMarieW/dash-bootstrap-templates/dbc.min.css"
# for the custom datepicker example
jquery_external_scripts = [
"https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.1/jquery.min.js",
"https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js",
]
jquery_external_stylesheets = [
"https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css"
]
# .js for custom html components - barcodes
js_custom_html_barcodes = [
"https://cdn.jsdelivr.net/npm/[email protected]/dist/JsBarcode.all.min.js"
]
dbc_css = "https://cdn.jsdelivr.net/gh/AnnMarieW/dash-bootstrap-templates/dbc.min.css"
app = Dash(
__name__,
use_pages=True,
external_stylesheets=[
dbc.themes.SPACELAB,
dbc.icons.BOOTSTRAP,
dbc.icons.FONT_AWESOME,
dbc_css,
dark_hljs,
]
+ jquery_external_stylesheets,
suppress_callback_exceptions=True,
external_scripts=jquery_external_scripts + js_custom_html_barcodes,
)
for k in example_apps:
new_callback_map = example_apps[k].callback_map
new_callback_list = example_apps[k]._callback_list
app.callback_map.update(new_callback_map)
app._callback_list.extend(new_callback_list)
print("step 4")
app.layout = html.Div(
[
navbar,
dbc.Container(dash.page_container, className="p-2"),
],
className="mb-4 dbc dbc-ag-grid",
)
clientside_callback(
"""
(switchOn) => {
switchOn
? document.documentElement.setAttribute('data-bs-theme', 'light')
: document.documentElement.setAttribute('data-bs-theme', 'dark')
return window.dash_clientside.no_update
}
""",
Output("switch", "id"),
Input("switch", "value"),
)
if __name__ == "__main__":
app.run_server(debug=True)