EasySci commited on
Commit
9947be3
·
1 Parent(s): d6a4825

Update app2.py

Browse files
Files changed (1) hide show
  1. app2.py +15 -10
app2.py CHANGED
@@ -74,11 +74,15 @@ current_state = 'main_panel' # Variable to keep track of the current state
74
  # Function to reset the main panel content to the initial content and store the previous content
75
  def reset_main_panel(event):
76
  global previous_content, current_state
 
77
  # Store the previous content of the current state if it's not already stored
78
- if current_state in previous_content:
 
 
 
79
  previous_content[current_state] = main_body_instance.main_body.copy()
80
 
81
- current_state = 'main_panel' # Update the current state
82
  # Reset the main panel to the initial state
83
  main_body_instance.main_body.clear() # Clear the existing main panel content
84
  main_body_instance.main_body.append(pn.pane.LaTeX("Please select some tags!", styles={'font-size': '20pt'}))
@@ -88,11 +92,16 @@ def reset_main_panel(event):
88
  def update_main_panel_button3(event):
89
  global previous_content, current_state
90
  # Store the previous content of the current state if it's not already stored
91
- if current_state in previous_content:
 
92
  previous_content[current_state] = main_body_instance.main_body.copy()
 
 
 
 
 
93
 
94
- current_state = 'main_panel_button3' # Update the current state
95
- # Update the main panel to the desired content when button3 is pressed
96
  main_body_instance.main_body.clear() # Clear the existing main panel content
97
  main_body_instance.main_body.append(pn.pane.Markdown("You pressed button3!"))
98
  main_body_instance.param.trigger('main_body') # Trigger the update manually
@@ -105,17 +114,13 @@ button3.on_click(update_main_panel_button3)
105
  def show_previous_content(event):
106
  global previous_content, current_state
107
  # Check if there's previous content for the current state
108
- print(current_state, flush=True)
109
  if current_state in previous_content:
110
  main_body_instance.main_body.clear() # Clear the existing main panel content
111
  main_body_instance.main_body.extend(previous_content[current_state]) # Add the previous content
112
  else:
113
  main_body_instance.main_body.clear() # Clear the existing main panel content
114
  main_body_instance.main_body.append(pn.pane.Markdown("No previous content available!"))
115
-
116
- # Update the current state before displaying the previous content
117
- current_state = 'main_panel' if current_state == 'main_panel_button3' else current_state
118
-
119
  main_body_instance.param.trigger('main_body') # Trigger the update manually
120
 
121
  # Attach the show_previous_content function to the on_click event of button1 and button3
 
74
  # Function to reset the main panel content to the initial content and store the previous content
75
  def reset_main_panel(event):
76
  global previous_content, current_state
77
+
78
  # Store the previous content of the current state if it's not already stored
79
+ if current_state not in previous_content:
80
+ current_state = 'main_panel'
81
+ previous_content[current_state] = main_body_instance.main_body.copy()
82
+ else:
83
  previous_content[current_state] = main_body_instance.main_body.copy()
84
 
85
+ current_state = 'main_panel'
86
  # Reset the main panel to the initial state
87
  main_body_instance.main_body.clear() # Clear the existing main panel content
88
  main_body_instance.main_body.append(pn.pane.LaTeX("Please select some tags!", styles={'font-size': '20pt'}))
 
92
  def update_main_panel_button3(event):
93
  global previous_content, current_state
94
  # Store the previous content of the current state if it's not already stored
95
+ if current_state not in previous_content:
96
+ current_state = 'main_panel_button3'
97
  previous_content[current_state] = main_body_instance.main_body.copy()
98
+ else:
99
+ previous_content[current_state] = main_body_instance.main_body.copy()
100
+
101
+ # Update the current state to main_panel_button3
102
+ current_state = 'main_panel_button3'
103
 
104
+ # Reset the main panel to the desired content when button3 is pressed
 
105
  main_body_instance.main_body.clear() # Clear the existing main panel content
106
  main_body_instance.main_body.append(pn.pane.Markdown("You pressed button3!"))
107
  main_body_instance.param.trigger('main_body') # Trigger the update manually
 
114
  def show_previous_content(event):
115
  global previous_content, current_state
116
  # Check if there's previous content for the current state
117
+ print(current_state, flush = True)
118
  if current_state in previous_content:
119
  main_body_instance.main_body.clear() # Clear the existing main panel content
120
  main_body_instance.main_body.extend(previous_content[current_state]) # Add the previous content
121
  else:
122
  main_body_instance.main_body.clear() # Clear the existing main panel content
123
  main_body_instance.main_body.append(pn.pane.Markdown("No previous content available!"))
 
 
 
 
124
  main_body_instance.param.trigger('main_body') # Trigger the update manually
125
 
126
  # Attach the show_previous_content function to the on_click event of button1 and button3