EasySci commited on
Commit
80cc1fe
·
1 Parent(s): a92aaca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -30,22 +30,23 @@ filter_list = pn.widgets.MultiChoice(
30
  button_type='default'
31
  )
32
 
33
- # "+" button to show the search options
34
- add_option_button = pn.widgets.Button(icon='search', name="", icon_size='2em', width=60, height=30)
35
 
36
- # Callback for the "+" button to add the selected option to the filter list
37
- def add_new_option(event):
38
  selected_option = filter_list.value
39
  if selected_option:
40
- entered_options.remove(selected_option[0]) # Remove the selected option from the list
41
- filter_list.options = entered_options # Update the filter_list options
 
42
 
43
- add_option_button.on_click(add_new_option)
44
 
45
  # Layout using Template
46
  template = pn.template.FastListTemplate(
47
  title="EasySciRead",
48
- header=[pn.Row(filter_list, add_option_button)],
49
  sidebar=[buttons],
50
  main=[
51
  pn.Column(text),
 
30
  button_type='default'
31
  )
32
 
33
+ # Create buttons for the header
34
+ header_buttons = []
35
 
36
+ # Callback for adding selected option to the header as a button
37
+ def add_to_header(event):
38
  selected_option = filter_list.value
39
  if selected_option:
40
+ new_button = pn.widgets.Button(name=selected_option[0], width=130, sizing_mode='fixed')
41
+ header_buttons.append(new_button)
42
+ filter_list.value = [] # Clear the selected option after adding it to the header
43
 
44
+ filter_list.param.watch(add_to_header, 'value')
45
 
46
  # Layout using Template
47
  template = pn.template.FastListTemplate(
48
  title="EasySciRead",
49
+ header=[pn.Row(filter_list), pn.Row(header_buttons, sizing_mode='stretch_width')],
50
  sidebar=[buttons],
51
  main=[
52
  pn.Column(text),