EasySci commited on
Commit
7175e43
·
1 Parent(s): f2d164f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -12
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", "option5","option6","option7","option8","option9"]
22
 
23
  # MultiChoice widget to display the filter options
24
  filter_list = pn.widgets.MultiChoice(
@@ -36,15 +36,17 @@ header_buttons = pn.Column(sizing_mode='stretch_width', css_classes=['header-but
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
 
39
- # Callback for adding selected option to the header as a button
 
 
 
40
  def add_to_header(event):
41
- selected_option = filter_list.value
42
- if selected_option:
43
- new_button = pn.widgets.Button(name=selected_option[0], width=130, sizing_mode='fixed')
44
- header_buttons.append(new_button)
45
- filter_list.value = [] # Clear the selected option after adding it to the header
46
 
47
- # Update the header immediately after adding the button
48
  update_header()
49
 
50
  add_to_header_button.on_click(add_to_header)
@@ -56,13 +58,10 @@ def update_header():
56
  new_button = pn.widgets.Button(name=button_name, width=130, sizing_mode='fixed')
57
  header_buttons.append(new_button)
58
 
59
- # List to store the names of buttons to be added to the header
60
- buttons_to_add = []
61
-
62
  # Layout using Template
63
  template = pn.template.FastListTemplate(
64
  title="EasySciRead",
65
- header=[pn.Row(header_buttons, filter_list, add_to_header_button)],
66
  main=[
67
  # pn.Row(header_buttons),
68
  pn.Column(text),
 
18
  text = pn.pane.Markdown(instructions)
19
 
20
  # List to store the entered options
21
+ entered_options = ["option1", "option2", "option3", "option5", "option6", "option7", "option8", "option9"]
22
 
23
  # MultiChoice widget to display the filter options
24
  filter_list = pn.widgets.MultiChoice(
 
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
 
39
+ # List to store the names of buttons to be added to the header
40
+ buttons_to_add = []
41
+
42
+ # Callback for adding selected options to the list
43
  def add_to_header(event):
44
+ selected_options = filter_list.value
45
+ if selected_options:
46
+ buttons_to_add.extend(selected_options) # Extend the list with selected options
47
+ filter_list.value = [] # Clear the selected options after adding them to the list
 
48
 
49
+ # Update the header immediately after adding the options
50
  update_header()
51
 
52
  add_to_header_button.on_click(add_to_header)
 
58
  new_button = pn.widgets.Button(name=button_name, width=130, sizing_mode='fixed')
59
  header_buttons.append(new_button)
60
 
 
 
 
61
  # Layout using Template
62
  template = pn.template.FastListTemplate(
63
  title="EasySciRead",
64
+ header=[pn.Row(header_buttons, sizing_mode='stretch_width'), pn.Row(filter_list, add_to_header_button)],
65
  main=[
66
  # pn.Row(header_buttons),
67
  pn.Column(text),