Spaces:
Sleeping
Sleeping
Update app2.py
Browse files
app2.py
CHANGED
|
@@ -67,20 +67,30 @@ def toggle_settings(event):
|
|
| 67 |
|
| 68 |
button4.param.watch(toggle_settings, 'value')
|
| 69 |
|
| 70 |
-
#
|
| 71 |
-
|
| 72 |
|
| 73 |
# Function to reset the main panel content to the initial content and store the previous content
|
| 74 |
def reset_main_panel(event):
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
# Reset the main panel to the initial state
|
| 77 |
main_body_instance.main_body.clear() # Clear the existing main panel content
|
| 78 |
-
main_body_instance.main_body.append(
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
main_body_instance.main_body.append(pn.pane.Markdown("You pressed button3!"))
|
| 85 |
main_body_instance.param.trigger('main_body') # Trigger the update manually
|
| 86 |
|
|
@@ -88,6 +98,23 @@ def update_main_panel_button3(event):
|
|
| 88 |
button1.on_click(reset_main_panel)
|
| 89 |
button3.on_click(update_main_panel_button3)
|
| 90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
# List to store the entered options
|
| 92 |
loaded_dict = TLDR.load_categories()
|
| 93 |
|
|
|
|
| 67 |
|
| 68 |
button4.param.watch(toggle_settings, 'value')
|
| 69 |
|
| 70 |
+
# Dictionary to store the previous content of main_panel and main_panel_button3
|
| 71 |
+
previous_content = {}
|
| 72 |
|
| 73 |
# Function to reset the main panel content to the initial content and store the previous content
|
| 74 |
def reset_main_panel(event):
|
| 75 |
+
global previous_content
|
| 76 |
+
# Store the previous content of main_panel if it's not already stored
|
| 77 |
+
if 'main_panel' not in previous_content:
|
| 78 |
+
previous_content['main_panel'] = main_body_instance.main_body.copy()
|
| 79 |
+
|
| 80 |
# Reset the main panel to the initial state
|
| 81 |
main_body_instance.main_body.clear() # Clear the existing main panel content
|
| 82 |
+
main_body_instance.main_body.append(pn.pane.LaTeX("Please select some tags!", styles={'font-size': '20pt'}))
|
| 83 |
main_body_instance.param.trigger('main_body') # Trigger the update manually
|
| 84 |
|
| 85 |
# Function to update the main panel content when button3 is pressed
|
| 86 |
def update_main_panel_button3(event):
|
| 87 |
+
global previous_content
|
| 88 |
+
# Store the previous content of main_panel_button3 if it's not already stored
|
| 89 |
+
if 'main_panel_button3' not in previous_content:
|
| 90 |
+
previous_content['main_panel_button3'] = main_body_instance.main_body.copy()
|
| 91 |
+
|
| 92 |
+
# Reset the main panel to the desired content when button3 is pressed
|
| 93 |
+
main_body_instance.main_body.clear() # Clear the existing main panel content
|
| 94 |
main_body_instance.main_body.append(pn.pane.Markdown("You pressed button3!"))
|
| 95 |
main_body_instance.param.trigger('main_body') # Trigger the update manually
|
| 96 |
|
|
|
|
| 98 |
button1.on_click(reset_main_panel)
|
| 99 |
button3.on_click(update_main_panel_button3)
|
| 100 |
|
| 101 |
+
# Function to check if there's previous content and display it, otherwise show a default message
|
| 102 |
+
def show_previous_content(event):
|
| 103 |
+
global previous_content
|
| 104 |
+
# Check if there's previous content for the button being pressed
|
| 105 |
+
if event.obj.name in previous_content:
|
| 106 |
+
main_body_instance.main_body.clear() # Clear the existing main panel content
|
| 107 |
+
main_body_instance.main_body.extend(previous_content[event.obj.name]) # Add the previous content
|
| 108 |
+
main_body_instance.param.trigger('main_body') # Trigger the update manually
|
| 109 |
+
else:
|
| 110 |
+
main_body_instance.main_body.clear() # Clear the existing main panel content
|
| 111 |
+
main_body_instance.main_body.append(pn.pane.Markdown("No previous content available!"))
|
| 112 |
+
main_body_instance.param.trigger('main_body') # Trigger the update manually
|
| 113 |
+
|
| 114 |
+
# Attach the show_previous_content function to the on_click event of button1 and button3
|
| 115 |
+
button1.on_click(show_previous_content)
|
| 116 |
+
button3.on_click(show_previous_content)
|
| 117 |
+
|
| 118 |
# List to store the entered options
|
| 119 |
loaded_dict = TLDR.load_categories()
|
| 120 |
|