EasySci commited on
Commit
8e189fc
·
1 Parent(s): c5db087

Update app2.py

Browse files
Files changed (1) hide show
  1. app2.py +17 -16
app2.py CHANGED
@@ -20,24 +20,27 @@ class MainBody(param.Parameterized):
20
 
21
  main_body_instance = MainBody()
22
 
23
- class CustomRadioButtonGroup(pn.widgets.RadioButtonGroup):
24
- value = param.String(default=None)
25
- value_change = param.Event()
26
-
27
- @param.depends('value', watch=True)
28
- def _value_change_handler(self):
29
- self.param.trigger('value_change')
30
-
31
  paper_list = [] # Add this line to initialize paper_list as an empty list
32
 
33
  main_body = [pn.pane.LaTeX("Please select some tags!", styles={'font-size': '20pt'})]
34
 
35
  # Create buttons for the toggleable sidebar
36
- button1 = pn.widgets.Button(icon='home', name="Home", icon_size='1.5em', button_type = 'primary', button_style = 'outline', width = 140)
37
- button2 = pn.widgets.Button(icon='file-analytics', name='My papers', icon_size='1.5em', button_type = 'primary', button_style = 'outline', width = 140)
38
- button3 = pn.widgets.Button(icon='settings', icon_size='1.5em', name='Settings', button_type = 'primary', button_style = 'outline', width = 140)
 
 
 
 
 
39
 
40
- select = CustomRadioButtonGroup(value="⭐", options=["⭐", "🐘"], name='String', align='center',button_type = 'success')
 
 
 
 
 
 
41
 
42
  # Create a column layout for the buttons inside the toggleable sidebar
43
  buttons = pn.Column(
@@ -49,11 +52,9 @@ buttons = pn.Column(
49
  # Function to display the selected value
50
  def display_selected_value(event):
51
  print(f"Selected value: {select.value}")
52
-
53
- select.param.watch(display_selected_value, 'value_change')
54
 
55
- # Attach the function to the RadioButtonGroup's on_change event
56
- select.on_change(display_selected_value)
57
 
58
  # List to store the entered options
59
  loaded_list = TLDR.load_categories()
 
20
 
21
  main_body_instance = MainBody()
22
 
 
 
 
 
 
 
 
 
23
  paper_list = [] # Add this line to initialize paper_list as an empty list
24
 
25
  main_body = [pn.pane.LaTeX("Please select some tags!", styles={'font-size': '20pt'})]
26
 
27
  # Create buttons for the toggleable sidebar
28
+ button1 = pn.widgets.Button(icon='home', name="Home", icon_size='1.5em', button_type='primary', button_style='outline', width=140)
29
+ button2 = pn.widgets.Button(icon='file-analytics', name='My papers', icon_size='1.5em', button_type='primary', button_style='outline', width=140)
30
+ button3 = pn.widgets.Button(icon='settings', icon_size='1.5em', name='Settings', button_type='primary', button_style='outline', width=140)
31
+
32
+ # Custom RadioButtonGroup widget with additional value_change event
33
+ class CustomRadioButtonGroup(pn.widgets.RadioButtonGroup):
34
+ value = pn.Param(None, doc="The selected value").tag(sync=True)
35
+ value_change = pn.Param(None, doc="Event that is triggered when the value changes").tag(sync=True, events=True)
36
 
37
+ def _process_events(self, events):
38
+ changed = super()._process_events(events)
39
+ if "value" in changed:
40
+ self.value_change = True
41
+ return changed
42
+
43
+ select = CustomRadioButtonGroup(value="⭐", options=["⭐", "🐘"], name='String', align='center')
44
 
45
  # Create a column layout for the buttons inside the toggleable sidebar
46
  buttons = pn.Column(
 
52
  # Function to display the selected value
53
  def display_selected_value(event):
54
  print(f"Selected value: {select.value}")
 
 
55
 
56
+ # Attach the function to the CustomRadioButtonGroup's value_change event
57
+ select.param.watch(display_selected_value, 'value_change')
58
 
59
  # List to store the entered options
60
  loaded_list = TLDR.load_categories()