EasySci commited on
Commit
9d3d386
·
1 Parent(s): a617b4a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -43,9 +43,10 @@ add_to_header_button.on_click(add_to_header)
43
  def update_header():
44
  header_buttons.clear() # Clear the existing buttons
45
  for button_name in buttons_to_add:
46
- new_button = pn.widgets.Button(name=button_name, width = 50, sizing_mode='fixed')
47
- header_buttons.append(new_button)
48
-
 
49
  # Update the filter list options to exclude buttons that are already in the header
50
  filter_list.options = [option for option in entered_options if option not in buttons_to_add]
51
 
@@ -60,6 +61,12 @@ filter_list = pn.widgets.MultiChoice(
60
  placeholder="Search Topics"
61
  )
62
 
 
 
 
 
 
 
63
  # Layout using Template
64
  template = pn.template.FastListTemplate(
65
  title="EasySciRead",
 
43
  def update_header():
44
  header_buttons.clear() # Clear the existing buttons
45
  for button_name in buttons_to_add:
46
+ header_button = pn.widgets.Button(name=button_name, width=50, sizing_mode='fixed')
47
+ header_button.on_click(remove_from_header) # Add callback to remove the header button
48
+ header_buttons.append(header_button)
49
+
50
  # Update the filter list options to exclude buttons that are already in the header
51
  filter_list.options = [option for option in entered_options if option not in buttons_to_add]
52
 
 
61
  placeholder="Search Topics"
62
  )
63
 
64
+ # Callback to remove the clicked header button and add it back to the filter list
65
+ def remove_from_header(event):
66
+ button_name = event.name
67
+ buttons_to_add.remove(button_name) # Remove from the header buttons list
68
+ update_header() # Update the header and filter list
69
+
70
  # Layout using Template
71
  template = pn.template.FastListTemplate(
72
  title="EasySciRead",