kartikmandar commited on
Commit
21475e0
·
1 Parent(s): b270ce6

add dashboardClasses for dynamic ui

Browse files
Files changed (2) hide show
  1. explorer.py +167 -8
  2. utils/dashboardClasses.py +476 -0
explorer.py CHANGED
@@ -1,15 +1,23 @@
1
  import panel as pn
2
  from utils.strings import HOME_HEADING_STRING, WELCOME_MESSAGE_STRING, FOOTER_STRING
 
 
3
 
4
 
5
  # Initialize panel extension
6
- pn.extension()
7
 
8
  # Create a boolean status indicator
9
  busy_indicator = pn.indicators.BooleanStatus(
10
  value=True, color="warning", width=30, height=30
11
  )
12
 
 
 
 
 
 
 
13
  # Create header
14
  home_heading = pn.pane.HTML(
15
  HOME_HEADING_STRING,
@@ -17,20 +25,163 @@ home_heading = pn.pane.HTML(
17
  css_classes=["home-heading"],
18
  )
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  # Create a welcome message
21
  welcome_message = pn.pane.HTML(
22
  WELCOME_MESSAGE_STRING,
23
  stylesheets=["../assets/stylesheets/explorer.css"],
24
  )
25
 
26
- # Create main content layout
27
- main = pn.Column(home_heading, welcome_message, height=800)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
- # Create a sidebar
30
- sidebar = pn.pane.Markdown("Sidebar")
31
 
32
- # Create a footer
33
- footer = pn.pane.Markdown(FOOTER_STRING)
34
 
35
  # Create a FastGridTemplate layout
36
  layout = pn.template.FastGridTemplate(
@@ -48,7 +199,7 @@ layout = pn.template.FastGridTemplate(
48
  # config= (TemplateConfig): Contains configuration options similar to pn.config but applied to the current Template only. (Currently only css_files is supported) But css_files are now deprecated.
49
  busy_indicator=busy_indicator,
50
  # For configuring the grid
51
- cols={"lg": 20, "md": 20, "sm": 20, "xs": 10, "xxs": 10},
52
  breakpoints={"lg": 1200, "md": 996, "sm": 768, "xs": 480, "xxs": 0},
53
  row_height=10,
54
  dimensions={"minW": 0, "maxW": float("inf"), "minH": 0, "maxH": float("inf")},
@@ -83,6 +234,14 @@ layout = pn.template.FastGridTemplate(
83
  base_target="_self",
84
  )
85
 
 
 
 
 
 
 
 
 
86
  # layout.main[0:5, 0:20] = heading
87
 
88
  # layout.main[:25, 0:12] = main
 
1
  import panel as pn
2
  from utils.strings import HOME_HEADING_STRING, WELCOME_MESSAGE_STRING, FOOTER_STRING
3
+ from utils.dashboardClasses import MainHeader, MainArea, OutputBox, WarningBox, BokehPlotsContainer, HelpBox, Footer, Sidebar
4
+ from bokeh.plotting import figure # Importing figure from Bokeh
5
 
6
 
7
  # Initialize panel extension
8
+ pn.extension('gridstack')
9
 
10
  # Create a boolean status indicator
11
  busy_indicator = pn.indicators.BooleanStatus(
12
  value=True, color="warning", width=30, height=30
13
  )
14
 
15
+ # Create a text input widget for the header
16
+ heading_input = pn.widgets.TextInput(
17
+ name="Heading", value="Light Curve Analysis Dashboard"
18
+ )
19
+
20
+
21
  # Create header
22
  home_heading = pn.pane.HTML(
23
  HOME_HEADING_STRING,
 
25
  css_classes=["home-heading"],
26
  )
27
 
28
+ # Create different types of content for the tabs
29
+ tab1_content = pn.pane.Markdown("# Welcome to Tab 1\nThis is the content for Tab 1.")
30
+ tab2_content = pn.pane.HTML("<h1>Welcome to Tab 2</h1><p>This is some HTML content.</p>")
31
+
32
+ # Example plot using Bokeh
33
+ p = figure(width=400, height=400)
34
+ p.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=15, color="navy", alpha=0.5)
35
+ tab3_content = pn.pane.Bokeh(p)
36
+
37
+ # Example with widgets
38
+ tab4_content = pn.Column(
39
+ pn.widgets.FloatSlider(name='Slider', start=0, end=10, value=5),
40
+ pn.widgets.Checkbox(name='Checkbox', value=True),
41
+ )
42
+
43
+ tabs_content = {
44
+ "hi": tab1_content,
45
+ "Tab 2": tab2_content,
46
+ "Tab 3": tab3_content,
47
+ "Tab 4": tab4_content,
48
+ "alflakj": tab3_content,
49
+ }
50
+
51
+ main_area = MainArea(tabs_content=tabs_content)
52
+
53
+ # Create the output box and warning box
54
+ output_box = OutputBox(output_content="This is the output content")
55
+ warning_box = WarningBox(warning_content="This is the warning content")
56
+
57
+ # Define custom actions for buttons
58
+ def start_action(event):
59
+ print("Start button clicked")
60
+
61
+
62
+ def stop_action(event):
63
+ print("Stop button clicked")
64
+
65
+
66
+ def reset_action(event):
67
+ print("Reset button clicked")
68
+
69
+
70
+ def pause_action(event):
71
+ print("Pause button clicked")
72
+
73
+
74
+ def resume_action(event):
75
+ print("Resume button clicked")
76
+
77
+
78
+ # Create instances of the parameterized classes
79
+ header = MainHeader(
80
+ heading=heading_input,
81
+ button_1_name="Start",
82
+ button_1_action=start_action,
83
+ button_2_name="Stop",
84
+ button_2_action=stop_action,
85
+ button_3_name="Reset",
86
+ button_3_action=reset_action,
87
+ button_4_name="Pause",
88
+ button_4_action=pause_action,
89
+ button_5_name="Resume",
90
+ button_5_action=resume_action,
91
+ button_6_name="yoyo",
92
+ button_6_action=resume_action,
93
+ button_7_name="yoyo",
94
+ button_7_action=resume_action,
95
+ button_8_name="yoyo",
96
+ button_8_action=resume_action,
97
+ # button_9_name="yoyo",
98
+ # button_9_action=resume_action,
99
+ # button_10_name="yoyo",
100
+ # button_10_action=resume_action,
101
+ # button_11_name="yoyo",
102
+ # button_11_action=resume_action,
103
+ # button_12_name="yoyo",
104
+ # button_12_action=resume_action,
105
+ )
106
+
107
  # Create a welcome message
108
  welcome_message = pn.pane.HTML(
109
  WELCOME_MESSAGE_STRING,
110
  stylesheets=["../assets/stylesheets/explorer.css"],
111
  )
112
 
113
+ # Create Bokeh plots
114
+ p1 = figure(title="Scatter Plot")
115
+ p1.scatter([1, 2, 3], [4, 5, 6])
116
+
117
+ p2 = figure(title="Line Plot")
118
+ p2.line([1, 2, 3], [4, 5, 6])
119
+
120
+ p3 = figure(title="Bar Plot")
121
+ p3.vbar(x=[1, 2, 3], top=[4, 5, 6], width=0.5)
122
+
123
+ # Create Bokeh plots container
124
+ bokeh_plots_container = BokehPlotsContainer(
125
+ flexbox_contents=[p1, p2, p3],
126
+ titles=["Scatter Plot", "Line Plot", "Bar Plot"],
127
+ sizes=[(200, 200), (200, 200), (300, 300)]
128
+ )
129
+
130
+ # Create HelpBox
131
+ help_content = """
132
+ ## Help Section
133
+ This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.
134
+ This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.
135
+ This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.
136
+
137
+ vThis section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.
138
+
139
+ vThis section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.vThis section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.
140
+ arkdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.vThis section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.
141
+ arkdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.vThis section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.
142
+ arkdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.vThis section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.
143
+ arkdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.This section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.vThis section provides help and documentation for using the dashboard. You can include any markdown content here to assist users.
144
+ """
145
+ help_box = HelpBox(help_content=help_content, title="Help Section")
146
+
147
+
148
+ # Define icon buttons
149
+ icon_buttons = [
150
+ pn.widgets.Button(name="Icon 1", button_type="default"),
151
+ pn.widgets.Button(name="Icon 2", button_type="default"),
152
+ pn.widgets.Button(name="Icon 3", button_type="default"),
153
+ pn.widgets.Button(name="Icon 4", button_type="default"),
154
+ pn.widgets.Button(name="Icon 5", button_type="default")
155
+ ]
156
+
157
+ footer_content = "© 2024 Stingray. All rights reserved."
158
+ additional_links = [
159
+ "[Privacy Policy](https://example.com)",
160
+ "[Terms of Service](https://example.com)",
161
+ "[Contact Us](https://example.com)",
162
+ "[Support](https://example.com)",
163
+ "[About Us](https://example.com)"
164
+ ]
165
+
166
+ footer = Footer(
167
+ main_content=footer_content,
168
+ additional_links=additional_links,
169
+ icons=icon_buttons
170
+ )
171
+
172
+ # Create the sidebar
173
+ sidebar = Sidebar(
174
+ main=main_area,
175
+ header=header,
176
+ footer=footer,
177
+ outputs=output_box,
178
+ warning=warning_box,
179
+ help=help_box
180
+ )
181
 
 
 
182
 
183
+ # # Create a footer
184
+ # footer = pn.pane.Markdown(FOOTER_STRING)
185
 
186
  # Create a FastGridTemplate layout
187
  layout = pn.template.FastGridTemplate(
 
199
  # config= (TemplateConfig): Contains configuration options similar to pn.config but applied to the current Template only. (Currently only css_files is supported) But css_files are now deprecated.
200
  busy_indicator=busy_indicator,
201
  # For configuring the grid
202
+ cols={"lg": 12, "md": 12, "sm": 12, "xs": 4, "xxs": 2},
203
  breakpoints={"lg": 1200, "md": 996, "sm": 768, "xs": 480, "xxs": 0},
204
  row_height=10,
205
  dimensions={"minW": 0, "maxW": float("inf"), "minH": 0, "maxH": float("inf")},
 
234
  base_target="_self",
235
  )
236
 
237
+ layout.main[0:8, 0:12] = header
238
+ layout.main[8:45, 0:8] = main_area
239
+ layout.main[8:25, 8:12] = output_box
240
+ layout.main[25:45, 8:12] = warning_box
241
+ layout.main[45:85, 0:12] = bokeh_plots_container
242
+ layout.main[85:120, 0:12] = help_box
243
+ layout.main[120:150, 0:12] = footer
244
+
245
  # layout.main[0:5, 0:20] = heading
246
 
247
  # layout.main[:25, 0:12] = main
utils/dashboardClasses.py CHANGED
@@ -0,0 +1,476 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import panel as pn
2
+ import param
3
+
4
+
5
+ class MainHeader(pn.viewable.Viewer):
6
+ heading = param.String(
7
+ default="Default Heading", doc="The heading text", allow_refs=True
8
+ )
9
+
10
+ button_1_name = param.String(default="Button 1", doc="Name for Button 1")
11
+ button_2_name = param.String(default="Button 2", doc="Name for Button 2")
12
+ button_3_name = param.String(default="Button 3", doc="Name for Button 3")
13
+ button_4_name = param.String(default="Button 4", doc="Name for Button 4")
14
+ button_5_name = param.String(default="Button 5", doc="Name for Button 5")
15
+ button_6_name = param.String(default="Button 6", doc="Name for Button 6")
16
+ button_7_name = param.String(default="Button 7", doc="Name for Button 7")
17
+ button_8_name = param.String(default="Button 8", doc="Name for Button 8")
18
+ button_9_name = param.String(default="Button 9", doc="Name for Button 9")
19
+ button_10_name = param.String(default="Button 10", doc="Name for Button 10")
20
+ button_11_name = param.String(default="Button 11", doc="Name for Button 11")
21
+ button_12_name = param.String(default="Button 12", doc="Name for Button 12")
22
+
23
+ button_1_action = param.Parameter(doc="Action for Button 1")
24
+ button_2_action = param.Parameter(doc="Action for Button 2")
25
+ button_3_action = param.Parameter(doc="Action for Button 3")
26
+ button_4_action = param.Parameter(doc="Action for Button 4")
27
+ button_5_action = param.Parameter(doc="Action for Button 5")
28
+ button_6_action = param.Parameter(doc="Action for Button 6")
29
+ button_7_action = param.Parameter(doc="Action for Button 7")
30
+ button_8_action = param.Parameter(doc="Action for Button 8")
31
+ button_9_action = param.Parameter(doc="Action for Button 9")
32
+ button_10_action = param.Parameter(doc="Action for Button 10")
33
+ button_11_action = param.Parameter(doc="Action for Button 11")
34
+ button_12_action = param.Parameter(doc="Action for Button 12")
35
+
36
+ def __init__(self, **params):
37
+ super().__init__(**params)
38
+
39
+ def __panel__(self):
40
+ heading_pane = pn.pane.HTML(
41
+ pn.bind(lambda heading: f"<h1>{heading}</h1>", self.param.heading)
42
+ )
43
+
44
+ buttons = []
45
+ if self.button_1_name and self.button_1_action:
46
+ buttons.append(
47
+ pn.widgets.Button(
48
+ name=self.button_1_name,
49
+ button_type="primary",
50
+ width=100,
51
+ height=30,
52
+ margin=(5, 5),
53
+ on_click=self.button_1_action,
54
+ )
55
+ )
56
+ if self.button_2_name and self.button_2_action:
57
+ buttons.append(
58
+ pn.widgets.Button(
59
+ name=self.button_2_name,
60
+ button_type="primary",
61
+ width=100,
62
+ height=30,
63
+ margin=(5, 5),
64
+ on_click=self.button_2_action,
65
+ )
66
+ )
67
+ if self.button_3_name and self.button_3_action:
68
+ buttons.append(
69
+ pn.widgets.Button(
70
+ name=self.button_3_name,
71
+ button_type="primary",
72
+ width=100,
73
+ height=30,
74
+ margin=(5, 5),
75
+ on_click=self.button_3_action,
76
+ )
77
+ )
78
+ if self.button_4_name and self.button_4_action:
79
+ buttons.append(
80
+ pn.widgets.Button(
81
+ name=self.button_4_name,
82
+ button_type="primary",
83
+ width=100,
84
+ height=30,
85
+ margin=(5, 5),
86
+ on_click=self.button_4_action,
87
+ )
88
+ )
89
+ if self.button_5_name and self.button_5_action:
90
+ buttons.append(
91
+ pn.widgets.Button(
92
+ name=self.button_5_name,
93
+ button_type="primary",
94
+ width=100,
95
+ height=30,
96
+ margin=(5, 5),
97
+ on_click=self.button_5_action,
98
+ )
99
+ )
100
+ if self.button_6_name and self.button_6_action:
101
+ buttons.append(
102
+ pn.widgets.Button(
103
+ name=self.button_6_name,
104
+ button_type="primary",
105
+ width=100,
106
+ height=30,
107
+ margin=(5, 5),
108
+ on_click=self.button_6_action,
109
+ )
110
+ )
111
+ if self.button_7_name and self.button_7_action:
112
+ buttons.append(
113
+ pn.widgets.Button(
114
+ name=self.button_7_name,
115
+ button_type="primary",
116
+ width=100,
117
+ height=30,
118
+ margin=(5, 5),
119
+ on_click=self.button_7_action,
120
+ )
121
+ )
122
+ if self.button_8_name and self.button_8_action:
123
+ buttons.append(
124
+ pn.widgets.Button(
125
+ name=self.button_8_name,
126
+ button_type="primary",
127
+ width=100,
128
+ height=30,
129
+ margin=(5, 5),
130
+ on_click=self.button_8_action,
131
+ )
132
+ )
133
+ if self.button_9_name and self.button_9_action:
134
+ buttons.append(
135
+ pn.widgets.Button(
136
+ name=self.button_9_name,
137
+ button_type="primary",
138
+ width=100,
139
+ height=30,
140
+ margin=(5, 5),
141
+ on_click=self.button_9_action,
142
+ )
143
+ )
144
+ if self.button_10_name and self.button_10_action:
145
+ buttons.append(
146
+ pn.widgets.Button(
147
+ name=self.button_10_name,
148
+ button_type="primary",
149
+ width=100,
150
+ height=30,
151
+ margin=(5, 5),
152
+ on_click=self.button_10_action,
153
+ )
154
+ )
155
+ if self.button_11_name and self.button_11_action:
156
+ buttons.append(
157
+ pn.widgets.Button(
158
+ name=self.button_11_name,
159
+ button_type="primary",
160
+ width=100,
161
+ height=30,
162
+ margin=(5, 5),
163
+ on_click=self.button_11_action,
164
+ )
165
+ )
166
+ if self.button_12_name and self.button_12_action:
167
+ buttons.append(
168
+ pn.widgets.Button(
169
+ name=self.button_12_name,
170
+ button_type="primary",
171
+ width=100,
172
+ height=30,
173
+ margin=(5, 5),
174
+ on_click=self.button_12_action,
175
+ )
176
+ )
177
+
178
+ layout = pn.Row(
179
+ heading_pane,
180
+ pn.FlexBox(
181
+ *buttons,
182
+ align_items="center",
183
+ justify_content="end",
184
+ flex_wrap="wrap",
185
+ ),
186
+ )
187
+
188
+ return layout
189
+
190
+
191
+ class MainArea(pn.viewable.Viewer):
192
+ tabs_content = param.Dict(
193
+ default={}, doc="Dictionary with tab names as keys and content as values"
194
+ )
195
+
196
+ def __init__(self, **params):
197
+ super().__init__(**params)
198
+
199
+ def __panel__(self):
200
+ tabs = pn.Tabs()
201
+ for tab_name, content in self.tabs_content.items():
202
+ tabs.append((tab_name, content))
203
+
204
+ flexbox_layout = pn.FlexBox(
205
+ tabs,
206
+ sizing_mode="stretch_both",
207
+ align_items="stretch",
208
+ justify_content="space-between",
209
+ )
210
+ return flexbox_layout
211
+
212
+
213
+ class OutputBox(pn.viewable.Viewer):
214
+ output_content = param.String(
215
+ default="", doc="Content to display in the output box"
216
+ )
217
+
218
+ def __init__(self, **params):
219
+ super().__init__(**params)
220
+
221
+ def __panel__(self):
222
+ heading = pn.pane.Markdown("## Output")
223
+ output_box = pn.widgets.TextAreaInput(
224
+ name="",
225
+ value=self.output_content,
226
+ disabled=True,
227
+ min_height=220,
228
+ sizing_mode="stretch_both",
229
+ )
230
+ return pn.Column(heading, output_box, sizing_mode="stretch_both")
231
+
232
+
233
+ class WarningBox(pn.viewable.Viewer):
234
+ warning_content = param.String(
235
+ default="", doc="Content to display in the warning box"
236
+ )
237
+
238
+ def __init__(self, **params):
239
+ super().__init__(**params)
240
+
241
+ def __panel__(self):
242
+ heading = pn.pane.Markdown("## Warning")
243
+ warning_box = pn.widgets.TextAreaInput(
244
+ name="",
245
+ value=self.warning_content,
246
+ disabled=True,
247
+ min_height=220,
248
+ sizing_mode="stretch_both",
249
+ )
250
+ return pn.Column(heading, warning_box, sizing_mode="stretch_both")
251
+
252
+
253
+ class BokehPlotsContainer(pn.viewable.Viewer):
254
+ flexbox_contents = param.List(default=[], doc="Contents for FlexBox containers")
255
+ titles = param.List(default=[], doc="Titles for FlexBox containers")
256
+ sizes = param.List(
257
+ default=[], doc="Sizes for FlexBox containers as (height, width)"
258
+ )
259
+
260
+ def __init__(self, **params):
261
+ super().__init__(**params)
262
+
263
+ def __panel__(self):
264
+ flexbox_container = pn.FlexBox(
265
+ align_items="center", justify_content="flex-start", flex_wrap="wrap"
266
+ )
267
+
268
+ for idx, content in enumerate(self.flexbox_contents):
269
+ if idx < len(self.titles):
270
+ title = self.titles[idx]
271
+ else:
272
+ title = f"FlexBox {idx+1}"
273
+
274
+ heading = pn.pane.Markdown(f"## {title}", align="center")
275
+ flexbox = pn.Column(
276
+ heading,
277
+ content,
278
+ )
279
+
280
+ if idx < len(self.sizes):
281
+ height, width = self.sizes[idx]
282
+ flexbox.height = height
283
+ flexbox.width = width
284
+ else:
285
+ flexbox.height = 300
286
+ flexbox.width = 300
287
+
288
+ flexbox_container.append(flexbox)
289
+
290
+ return flexbox_container
291
+
292
+
293
+ class HelpBox(pn.viewable.Viewer):
294
+ title = param.String(default="Help", doc="Title for the help box")
295
+ help_content = param.String(default="", doc="Markdown content for the help box")
296
+
297
+ def __init__(self, **params):
298
+ super().__init__(**params)
299
+
300
+ def __panel__(self):
301
+ heading = pn.pane.Markdown(f"## {self.title}")
302
+ help_markdown = pn.pane.Markdown(self.help_content, sizing_mode="stretch_both")
303
+ return pn.Column(heading, help_markdown, sizing_mode="stretch_both")
304
+
305
+
306
+ class Footer(pn.viewable.Viewer):
307
+ main_content = param.String(default="", doc="Main content to display in the footer")
308
+ additional_links = param.List(default=[], doc="List of additional links as markdown strings")
309
+ icons = param.List(default=[], doc="List of icon buttons")
310
+
311
+ def __init__(self, **params):
312
+ super().__init__(**params)
313
+
314
+ def __panel__(self):
315
+ logo = pn.pane.PNG(
316
+ "../assets/images/stingray_explorer.png",
317
+ width=100,
318
+ height=100,
319
+ align="center"
320
+ )
321
+ name = pn.pane.Markdown("Stingray Explorer", align="center")
322
+
323
+ logo_name_pane = pn.FlexBox(
324
+ logo,
325
+ name,
326
+ flex_direction="column",
327
+ justify_content="center",
328
+ align_items="center"
329
+ )
330
+
331
+ links = [pn.pane.Markdown(link) for link in self.additional_links]
332
+
333
+ links_pane = pn.FlexBox(
334
+ *links,
335
+ flex_direction="column",
336
+ justify_content="center",
337
+ align_items="center"
338
+ )
339
+
340
+ icons_pane = pn.FlexBox(
341
+ *self.icons,
342
+ flex_direction="column",
343
+ justify_content="center",
344
+ align_items="center"
345
+ )
346
+
347
+ contact_us_pane = pn.FlexBox(
348
+ pn.pane.Markdown("Email: contact@example.com"),
349
+ pn.pane.Markdown("Phone: (123) 456-7890"),
350
+ flex_direction="row",
351
+ justify_content="center",
352
+ align_items="center"
353
+ )
354
+
355
+ copyright_pane = pn.pane.Markdown(
356
+ """
357
+ &copy; 2024, Stingray. All rights reserved.
358
+ """,
359
+ )
360
+
361
+ pane1 = pn.FlexBox(
362
+ logo_name_pane,
363
+ links_pane,
364
+ icons_pane,
365
+ flex_direction="row",
366
+ justify_content="space-between",
367
+ align_items="center",
368
+
369
+ )
370
+
371
+ pane2 = pn.FlexBox(
372
+ contact_us_pane,
373
+ flex_direction="column",
374
+ justify_content="center",
375
+ align_items="center",
376
+
377
+ )
378
+
379
+ pane3 = pn.FlexBox(
380
+ copyright_pane,
381
+ flex_direction="row",
382
+ justify_content="center",
383
+ align_items="center",
384
+
385
+ )
386
+
387
+ footer = pn.FlexBox(
388
+ pane1,
389
+ pane2,
390
+ pane3,
391
+ flex_direction="row",
392
+ justify_content="center",
393
+ align_items="center",
394
+
395
+ )
396
+
397
+ return footer
398
+
399
+
400
+ class Sidebar(pn.viewable.Viewer):
401
+ main = param.Parameter(doc="Main content area to update")
402
+ header = param.Parameter(doc="Header content area to update")
403
+ footer = param.Parameter(doc="Footer content area to update")
404
+ outputs = param.Parameter(doc="Output content area to update")
405
+ warning = param.Parameter(doc="Warning content area to update")
406
+ help = param.Parameter(doc="Help content area to update")
407
+
408
+ def __init__(self, **params):
409
+ super().__init__(**params)
410
+
411
+ self.load_data_button = pn.widgets.Button(
412
+ name="Load Data", button_type="warning",
413
+ )
414
+
415
+ self.menu_items_quicklook_stingray = [
416
+ ("Light Curve", "QuickLookLightCurve"),
417
+ ("Powerspectra", "QuickLookPowerspectra"),
418
+ ("CrossCorrelation", "QuickLookCrossCorrelation"),
419
+ ]
420
+
421
+ self.quicklook_stingray_button = pn.widgets.MenuButton(
422
+ name="Quicklook",
423
+ items=self.menu_items_quicklook_stingray,
424
+ button_type="primary",
425
+ )
426
+
427
+ self.load_data_button.on_click(self.load_data)
428
+ self.quicklook_stingray_button.on_click(self.handle_quicklook_button_selection)
429
+
430
+ def load_data(self, event):
431
+ self.main[:] = [pn.pane.Markdown("### Data Ingestion Tabs\n\nDummy content for data ingestion.")]
432
+ self.header[:] = [pn.pane.Markdown("# Data Ingestion Loaded")]
433
+ self.footer[:] = [pn.pane.Markdown("### Footer Updated with Data Ingestion")]
434
+ self.outputs[:] = [pn.pane.Markdown("### Output Updated with Data Ingestion")]
435
+ self.warning[:] = [pn.pane.Markdown("### Warning Updated with Data Ingestion")]
436
+ self.help[:] = [pn.pane.Markdown("### Help Updated with Data Ingestion")]
437
+
438
+ def handle_quicklook_button_selection(self, event):
439
+ clicked = event.item
440
+ if clicked == "QuickLookLightCurve":
441
+ self.main[:] = [pn.pane.Markdown("### QuickLook Light Curve\n\nDummy content for light curve.")]
442
+ self.header[:] = [pn.pane.Markdown("# QuickLook Light Curve")]
443
+ self.footer[:] = [pn.pane.Markdown("### Footer Updated with Light Curve")]
444
+ self.outputs[:] = [pn.pane.Markdown("### Output Updated with Light Curve")]
445
+ self.warning[:] = [pn.pane.Markdown("### Warning Updated with Light Curve")]
446
+ self.help[:] = [pn.pane.Markdown("### Help Updated with Light Curve")]
447
+ elif clicked == "QuickLookPowerspectra":
448
+ self.main[:] = [pn.pane.Markdown("### Powerspectra\n\nDummy content for Powerspectra.")]
449
+ self.header[:] = [pn.pane.Markdown("# QuickLook Powerspectra")]
450
+ self.footer[:] = [pn.pane.Markdown("### Footer Updated with Powerspectra")]
451
+ self.outputs[:] = [pn.pane.Markdown("### Output Updated with Powerspectra")]
452
+ self.warning[:] = [pn.pane.Markdown("### Warning Updated with Powerspectra")]
453
+ self.help[:] = [pn.pane.Markdown("### Help Updated with Powerspectra")]
454
+ elif clicked == "QuickLookCrossCorrelation":
455
+ self.main[:] = [pn.pane.Markdown("### CrossCorrelation\n\nDummy content for CrossCorrelation.")]
456
+ self.header[:] = [pn.pane.Markdown("# QuickLook CrossCorrelation")]
457
+ self.footer[:] = [pn.pane.Markdown("### Footer Updated with CrossCorrelation")]
458
+ self.outputs[:] = [pn.pane.Markdown("### Output Updated with CrossCorrelation")]
459
+ self.warning[:] = [pn.pane.Markdown("### Warning Updated with CrossCorrelation")]
460
+ self.help[:] = [pn.pane.Markdown("### Help Updated with CrossCorrelation")]
461
+ else:
462
+ self.main[:] = [pn.pane.Markdown(f"### {clicked}\n\nContent not found.")]
463
+ self.header[:] = [pn.pane.Markdown(f"# {clicked}")]
464
+ self.footer[:] = [pn.pane.Markdown(f"### Footer Updated with {clicked}")]
465
+ self.outputs[:] = [pn.pane.Markdown(f"### Output Updated with {clicked}")]
466
+ self.warning[:] = [pn.pane.Markdown(f"### Warning Updated with {clicked}")]
467
+ self.help[:] = [pn.pane.Markdown(f"### Help Updated with {clicked}")]
468
+
469
+ def __panel__(self):
470
+ sidebar = pn.Column(
471
+ pn.pane.Markdown("# Navigation"),
472
+ self.load_data_button,
473
+ self.quicklook_stingray_button,
474
+ sizing_mode="stretch_both"
475
+ )
476
+ return sidebar