EasySci commited on
Commit
019ac52
·
1 Parent(s): 007ed9b

Update app2.py

Browse files
Files changed (1) hide show
  1. app2.py +15 -21
app2.py CHANGED
@@ -13,8 +13,6 @@ from src.search import Search_Papers
13
  # Create the MainBody class
14
  class MainBody(param.Parameterized):
15
  main_body = param.List(default=[pn.pane.LaTeX("Please select some tags!", styles={'font-size': '20pt'})])
16
- initial_main_body = param.List(default=[pn.pane.LaTeX("Please select some tags!", styles={'font-size': '20pt'})])
17
- main_panel_content = None
18
 
19
  @param.depends("main_body")
20
  def update(self):
@@ -24,10 +22,16 @@ class MainBody(param.Parameterized):
24
  main_body_instance = MainBody()
25
 
26
  # Store the initial content of the main panel in the MainBody instance
27
- main_body_instance.initial_main_body = [pn.pane.LaTeX("Please select some tags!", styles={'font-size': '20pt'})]
 
28
 
29
- # Store the initial content of the main panel in the MainBody instance
30
- main_body_instance.initial_main_body = [pn.pane.LaTeX("Please select some tags!", styles={'font-size': '20pt'})]
 
 
 
 
 
31
 
32
  paper_list = [] # Add this line to initialize paper_list as an empty list
33
 
@@ -74,14 +78,6 @@ def toggle_settings(event):
74
 
75
  button3.param.watch(toggle_settings, 'value')
76
 
77
- # Function to reset the main panel content to the initial content
78
- def reset_main_panel(event):
79
- # Clear the existing main panel content if it's not the initial content
80
- if main_body_instance.main_body != main_body_instance.initial_main_body:
81
- main_body_instance.main_body.clear()
82
- main_body_instance.main_body.extend(main_body_instance.initial_main_body)
83
- main_body_instance.param.trigger('main_body') # Trigger the update manually
84
-
85
  # Attach the reset_main_panel function to the on_click event of button1
86
  button1.on_click(reset_main_panel)
87
 
@@ -141,11 +137,9 @@ def add_to_header(event):
141
  paper_list.append(paper_list_itr)
142
  filter_list.value = [] # Clear the selected options after adding them to the header
143
 
144
- # Store the updated main panel content
145
- main_body_instance.main_panel_content = main_body_instance.update()
146
- main_body_instance.param.trigger('main_panel_content') # Trigger the update manually
147
-
148
-
149
 
150
  add_to_header_button.on_click(add_to_header)
151
 
@@ -172,9 +166,9 @@ def remove_from_header(event):
172
  buttons_to_add.remove(button.name) # Remove from the header buttons list
173
  filter_list.options.append(button.name) # Add back to the filter list options
174
  update_header() # Update the header and filter list
175
- # Store the updated main panel content
176
- main_body_instance.main_panel_content = main_body_instance.update()
177
- main_body_instance.param.trigger('main_panel_content') # Trigger the update manually
178
 
179
  # MultiChoice widget to display the filter options with delete buttons
180
  filter_list = pn.widgets.MultiChoice(
 
13
  # Create the MainBody class
14
  class MainBody(param.Parameterized):
15
  main_body = param.List(default=[pn.pane.LaTeX("Please select some tags!", styles={'font-size': '20pt'})])
 
 
16
 
17
  @param.depends("main_body")
18
  def update(self):
 
22
  main_body_instance = MainBody()
23
 
24
  # Store the initial content of the main panel in the MainBody instance
25
+ main_body_instance.main_body = [pn.pane.LaTeX("Please select some tags!", styles={'font-size': '20pt'})]
26
+ initial_main_body = main_body_instance.main_body.copy()
27
 
28
+ # Function to reset the main panel content to the initial content
29
+ def reset_main_panel(event):
30
+ # Clear the existing main panel content if it's not the initial content
31
+ if main_body_instance.main_body != initial_main_body:
32
+ main_body_instance.main_body.clear()
33
+ main_body_instance.main_body.extend(initial_main_body)
34
+ main_body_instance.param.trigger('main_body') # Trigger the update manually
35
 
36
  paper_list = [] # Add this line to initialize paper_list as an empty list
37
 
 
78
 
79
  button3.param.watch(toggle_settings, 'value')
80
 
 
 
 
 
 
 
 
 
81
  # Attach the reset_main_panel function to the on_click event of button1
82
  button1.on_click(reset_main_panel)
83
 
 
137
  paper_list.append(paper_list_itr)
138
  filter_list.value = [] # Clear the selected options after adding them to the header
139
 
140
+ # Update the main panel content
141
+ main_body_instance.main_body = TLDR.update_mainTLDR(buttons_to_add, paper_list)
142
+ main_body_instance.param.trigger('main_body') # Trigger the update manually
 
 
143
 
144
  add_to_header_button.on_click(add_to_header)
145
 
 
166
  buttons_to_add.remove(button.name) # Remove from the header buttons list
167
  filter_list.options.append(button.name) # Add back to the filter list options
168
  update_header() # Update the header and filter list
169
+ # Update the main panel content
170
+ main_body_instance.main_body = TLDR.update_mainTLDR(buttons_to_add, paper_list)
171
+ main_body_instance.param.trigger('main_body') # Trigger the update manually
172
 
173
  # MultiChoice widget to display the filter options with delete buttons
174
  filter_list = pn.widgets.MultiChoice(