EasySci commited on
Commit
07a60bf
·
1 Parent(s): 9fd55ab

Update app2.py

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