EasySci commited on
Commit
1edc318
·
1 Parent(s): 2862361

Update app2.py

Browse files
Files changed (1) hide show
  1. app2.py +21 -31
app2.py CHANGED
@@ -67,42 +67,32 @@ def toggle_settings(event):
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
 
67
 
68
  button4.param.watch(toggle_settings, 'value')
69
 
70
+ # Function to reset the main panel content to the initial content
71
+ def reset_main_panel(event):
72
+ global main_panel_content
73
+ main_panel_content = None # Clear the stored content
74
+ main_body_instance.main_body.clear() # Clear the existing main panel content
75
+ main_body_instance.main_body.append(pn.pane.LaTeX("Please select some tags!", styles={'font-size': '20pt'}))
76
+ main_body_instance.param.trigger('main_body') # Trigger the update manually
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
 
78
  # Function to update the main panel content when button3 is pressed
79
  def update_main_panel_button3(event):
80
+ global main_panel_content
81
+ if main_panel_content is not None:
82
+ # Restore the content of main_panel if it's not empty
83
+ main_body_instance.main_body = main_panel_content
84
+ main_body_instance.param.trigger('main_body') # Trigger the update manually
85
+ else:
86
+ # If main_panel_content is empty, add new content
87
+ main_body_instance.main_body.clear() # Clear the existing main panel content if you want to replace it
88
+ main_body_instance.main_body.append(pn.pane.Markdown("You pressed button3!"))
89
+ main_body_instance.param.trigger('main_body') # Trigger the update manually
90
+
91
+ # Store the content of main_panel
92
+ main_panel_content = main_body_instance.main_body
93
 
94
  # Attach the functions to the on_click event of button1 and button3
95
+ button1.on_click(reset_main_panel)
96
  button3.on_click(update_main_panel_button3)
97
 
98
  # List to store the entered options