-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.py
91 lines (82 loc) · 3.51 KB
/
index.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
84
85
86
87
88
89
90
91
import dash_bootstrap_components as dbc
from dash import dcc, html, Output, Input
from apps import resonance, transmission, converter, tof_plotter, bragg, golden_angles, home_page
from config import app_dict
from app import app
image_logo = 'team_logo.png'
header = html.Div([
dbc.Navbar([
dbc.Row([
dbc.Col([
html.A(
html.Img(src=app.get_asset_url(image_logo),
height="60px",
),
href="/",
)],
),
dbc.Col(html.Pre(""),
class_name="header_pre_padding"),
dbc.Col(html.H5("i"),
width="auto",
class_name="header_i"),
dbc.Col(html.H1("NEU"),
width="auto",
class_name="header_col_right_padding"),
dbc.Col(html.H5("tron"),
width="auto",
class_name="header_tron"),
dbc.Col(html.Pre(""),
class_name="header_pre_padding"),
dbc.Col(html.H1("I"),
class_name="header_col_right_padding"),
dbc.Col(html.H5("maging"),
class_name="header_col_left_padding_special_case_for_i"),
dbc.Col(html.Pre(""),
class_name="header_pre_padding"),
dbc.Col(html.H1("T"),
class_name="header_col_right_padding"),
dbc.Col(html.H5("oolbox"),
class_name="header_col_left_padding"),
dbc.Col(html.Pre(""),
class_name="header_dropdown_separator"),
],
align="center"),
dbc.DropdownMenu(
label="Select a Tool",
id="list_of_tools_dropdown",
children=[
dbc.DropdownMenuItem("Neutron Transmission", href="/transmission"),
dbc.DropdownMenuItem("Neutron Resonance", href="/resonance"),
dbc.DropdownMenuItem("Composition Converter", href="/converter"),
dbc.DropdownMenuItem("Time-of-flight Plotter", href='/tof_plotter'),
dbc.DropdownMenuItem("Bragg-edge Simulator", href='/bragg'),
dbc.DropdownMenuItem("Golden Angles", href='/golden_angles'),
],
color="primary",
size="lg",
),
],
class_name="header_format",
color="white",
),
dcc.Location(id='location'),
html.Hr(style={'borderTop': '3px solid blue'}),
html.Div(id='tool_selected_page'),
html.Div(id='main_content')
])
app.layout = header
@app.callback(Output('main_content', 'children'),
Input('location', 'pathname'))
def fill_main_content(pathname):
if pathname is None:
return "Loading ..."
for _key in app_dict.keys():
if app_dict[_key]['url'] == pathname:
return eval(f"{_key}.layout")
if pathname == '/':
return home_page.layout
else:
return '404: URL not founds!'
if __name__ == '__main__':
app.run_server(debug=True)