Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -36,7 +36,6 @@ def add_to_header(event):
|
|
| 36 |
for option in selected_options:
|
| 37 |
if option not in buttons_to_add: # Check if option is already in header
|
| 38 |
buttons_to_add.append(option) # Add to header if not already present
|
| 39 |
-
filter_list.options.remove(option) # Remove from filter list options
|
| 40 |
filter_list.value = [] # Clear the selected options after adding them to the header
|
| 41 |
update_header() # Update the header after adding options
|
| 42 |
|
|
@@ -47,7 +46,6 @@ def update_header():
|
|
| 47 |
header_buttons.clear() # Clear the existing buttons
|
| 48 |
for button_name in buttons_to_add:
|
| 49 |
header_button = pn.widgets.Button(name=button_name, width=50, sizing_mode='fixed')
|
| 50 |
-
header_button.param.custom_name = button_name # Add custom attribute to store button name
|
| 51 |
header_button.on_click(remove_from_header) # Add callback to remove the header button
|
| 52 |
header_buttons.append(header_button)
|
| 53 |
|
|
@@ -62,11 +60,12 @@ filter_list = pn.widgets.MultiChoice(
|
|
| 62 |
placeholder="Search Topics"
|
| 63 |
)
|
| 64 |
|
| 65 |
-
# Callback to remove the clicked header button
|
| 66 |
def remove_from_header(event):
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
|
|
|
| 70 |
update_header() # Update the header and filter list
|
| 71 |
|
| 72 |
# Layout using Template
|
|
|
|
| 36 |
for option in selected_options:
|
| 37 |
if option not in buttons_to_add: # Check if option is already in header
|
| 38 |
buttons_to_add.append(option) # Add to header if not already present
|
|
|
|
| 39 |
filter_list.value = [] # Clear the selected options after adding them to the header
|
| 40 |
update_header() # Update the header after adding options
|
| 41 |
|
|
|
|
| 46 |
header_buttons.clear() # Clear the existing buttons
|
| 47 |
for button_name in buttons_to_add:
|
| 48 |
header_button = pn.widgets.Button(name=button_name, width=50, sizing_mode='fixed')
|
|
|
|
| 49 |
header_button.on_click(remove_from_header) # Add callback to remove the header button
|
| 50 |
header_buttons.append(header_button)
|
| 51 |
|
|
|
|
| 60 |
placeholder="Search Topics"
|
| 61 |
)
|
| 62 |
|
| 63 |
+
# Callback to remove the clicked header button
|
| 64 |
def remove_from_header(event):
|
| 65 |
+
button = event.obj # Get the clicked button
|
| 66 |
+
if button.name in buttons_to_add:
|
| 67 |
+
buttons_to_add.remove(button.name) # Remove from the header buttons list
|
| 68 |
+
filter_list.options.append(button.name) # Add back to the filter list options
|
| 69 |
update_header() # Update the header and filter list
|
| 70 |
|
| 71 |
# Layout using Template
|