EasySci commited on
Commit
fb9a2fe
·
1 Parent(s): a738c68

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -3
app.py CHANGED
@@ -17,11 +17,14 @@ of cross-filtering.
17
 
18
  text = pn.pane.Markdown(instructions)
19
 
 
 
 
20
  # Add filter list row with spacing
21
  filter_list = pn.widgets.CheckButtonGroup(
22
  name='Filter Options',
23
  margin=(20, 10),
24
- options=[],
25
  sizing_mode='fixed',
26
  button_type='default'
27
  )
@@ -34,13 +37,23 @@ new_option_input = pn.widgets.TextInput(sizing_mode="stretch_width", background=
34
 
35
  # Callback for the "+" button to add the new option to the filter list
36
  def add_new_option(event):
37
- new_option = new_option_input.value
38
  if new_option:
39
- filter_list.options = new_option_input.value.split(',') # Split the comma-separated input into a list
 
40
  new_option_input.value = ""
41
 
42
  add_option_button.on_click(add_new_option)
43
 
 
 
 
 
 
 
 
 
 
44
  # Layout using Template
45
  template = pn.template.FastListTemplate(
46
  title="EasySciRead",
 
17
 
18
  text = pn.pane.Markdown(instructions)
19
 
20
+ # List to store the entered options
21
+ entered_options = []
22
+
23
  # Add filter list row with spacing
24
  filter_list = pn.widgets.CheckButtonGroup(
25
  name='Filter Options',
26
  margin=(20, 10),
27
+ options=entered_options, # Use the list of entered options
28
  sizing_mode='fixed',
29
  button_type='default'
30
  )
 
37
 
38
  # Callback for the "+" button to add the new option to the filter list
39
  def add_new_option(event):
40
+ new_option = new_option_input.value.strip() # Remove leading/trailing spaces
41
  if new_option:
42
+ entered_options.append(new_option) # Add the option to the list of entered options
43
+ filter_list.options = entered_options # Update the filter_list options
44
  new_option_input.value = ""
45
 
46
  add_option_button.on_click(add_new_option)
47
 
48
+ # Callback for removing the selected option from the filter list
49
+ def remove_selected_option(event):
50
+ selected = filter_list.value
51
+ if selected:
52
+ entered_options.remove(selected[0]) # Remove the selected option from the entered options list
53
+ filter_list.options = entered_options # Update the filter_list options
54
+
55
+ filter_list.param.watch(remove_selected_option, 'value')
56
+
57
  # Layout using Template
58
  template = pn.template.FastListTemplate(
59
  title="EasySciRead",