Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,7 +18,7 @@ of cross-filtering.
|
|
| 18 |
text = pn.pane.Markdown(instructions)
|
| 19 |
|
| 20 |
# List to store the entered options
|
| 21 |
-
entered_options = ["option1", "option2", "option3"
|
| 22 |
|
| 23 |
# MultiChoice widget to display the filter options
|
| 24 |
filter_list = pn.widgets.MultiChoice(
|
|
@@ -33,6 +33,9 @@ filter_list = pn.widgets.MultiChoice(
|
|
| 33 |
# Create buttons for the header
|
| 34 |
header_buttons = pn.Column(sizing_mode='stretch_width', css_classes=['header-buttons'])
|
| 35 |
|
|
|
|
|
|
|
|
|
|
| 36 |
# "+" button to trigger the addition to the header
|
| 37 |
add_to_header_button = pn.widgets.Button(name="Add to Header", button_type='primary')
|
| 38 |
|
|
@@ -40,8 +43,7 @@ add_to_header_button = pn.widgets.Button(name="Add to Header", button_type='prim
|
|
| 40 |
def add_to_header(event):
|
| 41 |
selected_option = filter_list.value
|
| 42 |
if selected_option:
|
| 43 |
-
|
| 44 |
-
header_buttons.append(new_button)
|
| 45 |
filter_list.value = [] # Clear the selected option after adding it to the header
|
| 46 |
|
| 47 |
add_to_header_button.on_click(add_to_header)
|
|
@@ -49,7 +51,7 @@ add_to_header_button.on_click(add_to_header)
|
|
| 49 |
# Layout using Template
|
| 50 |
template = pn.template.FastListTemplate(
|
| 51 |
title="EasySciRead",
|
| 52 |
-
header=[pn.Row(
|
| 53 |
main=[
|
| 54 |
pn.Row(header_buttons),
|
| 55 |
pn.Column(text),
|
|
@@ -62,5 +64,14 @@ template = pn.template.FastListTemplate(
|
|
| 62 |
sidebar_width=150
|
| 63 |
)
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
# Run the app
|
| 66 |
template.servable()
|
|
|
|
| 18 |
text = pn.pane.Markdown(instructions)
|
| 19 |
|
| 20 |
# List to store the entered options
|
| 21 |
+
entered_options = ["option1", "option2", "option3"]
|
| 22 |
|
| 23 |
# MultiChoice widget to display the filter options
|
| 24 |
filter_list = pn.widgets.MultiChoice(
|
|
|
|
| 33 |
# Create buttons for the header
|
| 34 |
header_buttons = pn.Column(sizing_mode='stretch_width', css_classes=['header-buttons'])
|
| 35 |
|
| 36 |
+
# List to store the names of buttons to be added to the header
|
| 37 |
+
buttons_to_add = []
|
| 38 |
+
|
| 39 |
# "+" button to trigger the addition to the header
|
| 40 |
add_to_header_button = pn.widgets.Button(name="Add to Header", button_type='primary')
|
| 41 |
|
|
|
|
| 43 |
def add_to_header(event):
|
| 44 |
selected_option = filter_list.value
|
| 45 |
if selected_option:
|
| 46 |
+
buttons_to_add.append(selected_option[0]) # Store the name of the button to be added
|
|
|
|
| 47 |
filter_list.value = [] # Clear the selected option after adding it to the header
|
| 48 |
|
| 49 |
add_to_header_button.on_click(add_to_header)
|
|
|
|
| 51 |
# Layout using Template
|
| 52 |
template = pn.template.FastListTemplate(
|
| 53 |
title="EasySciRead",
|
| 54 |
+
header=[pn.Row(filter_list, add_to_header_button)],
|
| 55 |
main=[
|
| 56 |
pn.Row(header_buttons),
|
| 57 |
pn.Column(text),
|
|
|
|
| 64 |
sidebar_width=150
|
| 65 |
)
|
| 66 |
|
| 67 |
+
# Periodically update the header layout to add the newly created buttons
|
| 68 |
+
def update_header():
|
| 69 |
+
for button_name in buttons_to_add:
|
| 70 |
+
new_button = pn.widgets.Button(name=button_name, width=130, sizing_mode='fixed')
|
| 71 |
+
header_buttons.append(new_button)
|
| 72 |
+
buttons_to_add.clear() # Clear the list after adding the buttons to the header
|
| 73 |
+
|
| 74 |
+
pn.state.add_periodic_callback(update_header, period=100)
|
| 75 |
+
|
| 76 |
# Run the app
|
| 77 |
template.servable()
|