Spaces:
Running
Running
Update app2.py
Browse files
app2.py
CHANGED
|
@@ -16,6 +16,9 @@ class MainBody(param.Parameterized):
|
|
| 16 |
@param.depends("main_body")
|
| 17 |
def update(self):
|
| 18 |
return pn.Column(*self.main_body)
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
main_body_instance = MainBody()
|
| 21 |
|
|
@@ -46,7 +49,6 @@ def display_selected_value(event):
|
|
| 46 |
select.param.watch(display_selected_value, 'value')
|
| 47 |
select2.param.watch(display_selected_value, 'value')
|
| 48 |
|
| 49 |
-
|
| 50 |
# Create a column layout for the buttons inside the toggleable sidebar
|
| 51 |
buttons = pn.Column(
|
| 52 |
button1, button2, button3, button4,
|
|
@@ -65,20 +67,42 @@ def toggle_settings(event):
|
|
| 65 |
|
| 66 |
button4.param.watch(toggle_settings, 'value')
|
| 67 |
|
| 68 |
-
#
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
# Function to update the main panel content when button3 is pressed
|
| 75 |
def update_main_panel_button3(event):
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
main_body_instance.param.trigger('main_body') # Trigger the update manually
|
| 79 |
|
| 80 |
-
# Attach the
|
| 81 |
-
button1.on_click(
|
| 82 |
button3.on_click(update_main_panel_button3)
|
| 83 |
|
| 84 |
# List to store the entered options
|
|
|
|
| 16 |
@param.depends("main_body")
|
| 17 |
def update(self):
|
| 18 |
return pn.Column(*self.main_body)
|
| 19 |
+
|
| 20 |
+
def add_panel_to_main_body(self, panel):
|
| 21 |
+
self.main_body.append(panel)
|
| 22 |
|
| 23 |
main_body_instance = MainBody()
|
| 24 |
|
|
|
|
| 49 |
select.param.watch(display_selected_value, 'value')
|
| 50 |
select2.param.watch(display_selected_value, 'value')
|
| 51 |
|
|
|
|
| 52 |
# Create a column layout for the buttons inside the toggleable sidebar
|
| 53 |
buttons = pn.Column(
|
| 54 |
button1, button2, button3, button4,
|
|
|
|
| 67 |
|
| 68 |
button4.param.watch(toggle_settings, 'value')
|
| 69 |
|
| 70 |
+
# List to store the previously displayed main panels
|
| 71 |
+
previous_panels = []
|
| 72 |
+
|
| 73 |
+
# Function to update the main panel content when button4 is toggled
|
| 74 |
+
def toggle_main_panel(event):
|
| 75 |
+
if event.new:
|
| 76 |
+
# Create a FloatPanel and place the main_panel inside it
|
| 77 |
+
float_panel = pn.layout.FloatPanel(main_panel, name="Free Floating FloatPanel", contained=False, position='bottom_left')
|
| 78 |
+
float_panel.show()
|
| 79 |
+
else:
|
| 80 |
+
# Remove any existing FloatPanel if the toggle is set to False
|
| 81 |
+
try:
|
| 82 |
+
float_panel.close()
|
| 83 |
+
except NameError:
|
| 84 |
+
pass
|
| 85 |
+
|
| 86 |
+
# Restore the previously displayed main panels
|
| 87 |
+
main_panel.clear()
|
| 88 |
+
for panel in previous_panels:
|
| 89 |
+
main_panel.append(panel)
|
| 90 |
+
|
| 91 |
+
# Attach the toggle_main_panel function to the on_click event of button4
|
| 92 |
+
button4.param.watch(toggle_main_panel, 'value')
|
| 93 |
+
|
| 94 |
+
# Function to update the main panel content when button1 is pressed
|
| 95 |
+
def update_main_panel_button1(event):
|
| 96 |
+
main_panel.clear() # Clear the existing main panel content if you want to replace it
|
| 97 |
+
main_panel.append(pn.pane.LaTeX("You pressed button1!", styles={'font-size': '20pt'}))
|
| 98 |
|
| 99 |
# Function to update the main panel content when button3 is pressed
|
| 100 |
def update_main_panel_button3(event):
|
| 101 |
+
main_panel.clear() # Clear the existing main panel content if you want to replace it
|
| 102 |
+
main_panel.append(pn.pane.Markdown("You pressed button3!"))
|
|
|
|
| 103 |
|
| 104 |
+
# Attach the functions to the on_click event of button1 and button3
|
| 105 |
+
button1.on_click(update_main_panel_button1)
|
| 106 |
button3.on_click(update_main_panel_button3)
|
| 107 |
|
| 108 |
# List to store the entered options
|