EasySci commited on
Commit
184c116
·
1 Parent(s): 5d52afd

Update app2.py

Browse files
Files changed (1) hide show
  1. app2.py +46 -36
app2.py CHANGED
@@ -1,6 +1,4 @@
1
  import panel as pn
2
- from panel import Tabs
3
-
4
  pn.extension('katex')
5
 
6
  import pytz
@@ -25,26 +23,19 @@ paper_list = [] # Add this line to initialize paper_list as an empty list
25
 
26
  main_body = [pn.pane.LaTeX("Please select some tags!", styles={'font-size': '20pt'})]
27
 
28
- # Create the content for each tab
29
- tab1_content = MainBody(main_body=[pn.pane.LaTeX("Home Tab Content", styles={'font-size': '20pt'})])
30
- tab2_content = MainBody(main_body=[pn.pane.LaTeX("My Papers Tab Content", styles={'font-size': '20pt'})])
31
-
32
- # Create the Tabs widget and add the tab content
33
- tabs = Tabs(
34
- ("", tab1_content.update),
35
- ("", tab2_content.update),
36
- tabs_location='above' # Hide labels by placing tabs above the content
37
- )
38
-
39
 
40
  # Create buttons for the toggleable sidebar
41
- button1 = pn.widgets.Button(icon='home', name="Daily papers", icon_size='1.5em', button_type='primary', button_style='outline', width=140)
42
- button2 = pn.widgets.Button(icon='calendar-filled', name="Search papers", icon_size='1.5em', button_type='primary', button_style='outline', width=140)
43
- button3 = pn.widgets.Button(icon='file-analytics', name='My papers', icon_size='1.5em', button_type='primary', button_style='outline', width=140)
44
- button4 = pn.widgets.Toggle(name='Accessibility', icon='settings', icon_size='1.5em', button_type='default', button_style='outline', width=140, value=False)
45
 
46
  # Custom RadioButtonGroup widget
47
- select = pn.widgets.RadioButtonGroup(value="Scientic", options=["General", "Scientic"], name='String', align='center', button_type='default')
48
  select2 = pn.widgets.RadioButtonGroup(value="Normal", options=["Bionic", "Normal"], name='String', align='center', button_type='default')
49
 
50
  # Define a callback to display the selected value
@@ -55,6 +46,7 @@ def display_selected_value(event):
55
  select.param.watch(display_selected_value, 'value')
56
  select2.param.watch(display_selected_value, 'value')
57
 
 
58
  # Create a column layout for the buttons inside the toggleable sidebar
59
  buttons = pn.Column(
60
  button1, button2, button3,
@@ -73,6 +65,36 @@ def toggle_settings(event):
73
 
74
  button3.param.watch(toggle_settings, 'value')
75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  # List to store the entered options
77
  loaded_dict = TLDR.load_categories()
78
 
@@ -83,7 +105,7 @@ entered_options = list(loaded_dict.values())
83
  header_buttons = pn.Row(sizing_mode='stretch_width', css_classes=['header-buttons'])
84
 
85
  # "+" button to trigger the addition to the header
86
- add_to_header_button = pn.widgets.Button(name="", icon='search', icon_size='1.5em', button_style='outline', button_type='light')
87
 
88
  # List to store the names of buttons to be added to the header
89
  buttons_to_add = []
@@ -114,7 +136,7 @@ def update_header():
114
  header_buttons.clear() # Clear the existing buttons
115
 
116
  for button_name in buttons_to_add:
117
- header_button = pn.widgets.Button(name=button_name, button_type='primary', button_style='outline')
118
  header_button.on_click(remove_from_header) # Add callback to remove the header button
119
  header_buttons.append(header_button)
120
  buttons_to_add
@@ -148,27 +170,15 @@ filter_list = pn.widgets.MultiChoice(
148
  template = pn.template.FastListTemplate(
149
  title="EasySciRead",
150
  header=[pn.Row(header_buttons, width=750, sizing_mode='stretch_width'), pn.Row(filter_list, width=250), pn.Row(add_to_header_button, width=55)],
151
- main=tabs, # Use the Tabs widget here
152
  sidebar=[buttons],
153
  accent_base_color="#88d8b0",
154
  header_background="#FFFFFF",
155
  header_color="#000000",
156
  text_align='center',
157
- sidebar_width=200,
158
- sizing_mode='stretch_both' # Adjust sizing mode if needed
159
  )
160
 
161
- # CSS customization to hide tab labels
162
- css_style = """
163
- <style>
164
- .pn-TabBar-tabs {
165
- color: transparent;
166
- }
167
- </style>
168
- """
169
-
170
- # Add the CSS style to the template
171
- template.add_html(css_style)
172
-
173
  # Run the app
174
- template.servable()
 
1
  import panel as pn
 
 
2
  pn.extension('katex')
3
 
4
  import pytz
 
23
 
24
  main_body = [pn.pane.LaTeX("Please select some tags!", styles={'font-size': '20pt'})]
25
 
26
+ # Create buttons for the toggleable sidebar
27
+ # button1 = pn.widgets.Button(name="🏠 Home", button_type='default', button_style='outline', width=140)
28
+ # button2 = pn.widgets.Button(name='📁 My papers', button_type='default', button_style='outline', width=140)
29
+ # button3 = pn.widgets.Toggle(name='⚙️ Settings', button_type='default', button_style='outline', width=140, value=False)
 
 
 
 
 
 
 
30
 
31
  # Create buttons for the toggleable sidebar
32
+ button1 = pn.widgets.Button(icon='home', name="Daily papers", icon_size='1.5em', button_type = 'primary', button_style = 'outline', width = 140)
33
+ button2 = pn.widgets.Button(icon='calendar-filled', name="Search papers", icon_size='1.5em', button_type = 'primary', button_style = 'outline', width = 140)
34
+ button3 = pn.widgets.Button(icon='file-analytics', name='My papers', icon_size='1.5em', button_type = 'primary', button_style = 'outline', width = 140)
35
+ button4 = pn.widgets.Toggle(name='Accessibility',icon='settings', icon_size='1.5em', button_type='default', button_style='outline', width=140, value=False)
36
 
37
  # Custom RadioButtonGroup widget
38
+ select = pn.widgets.RadioButtonGroup(value="Scientic", options=["General", "Scientic"], name='String', align='center', button_type='default') # , align='center'
39
  select2 = pn.widgets.RadioButtonGroup(value="Normal", options=["Bionic", "Normal"], name='String', align='center', button_type='default')
40
 
41
  # Define a callback to display the selected value
 
46
  select.param.watch(display_selected_value, 'value')
47
  select2.param.watch(display_selected_value, 'value')
48
 
49
+
50
  # Create a column layout for the buttons inside the toggleable sidebar
51
  buttons = pn.Column(
52
  button1, button2, button3,
 
65
 
66
  button3.param.watch(toggle_settings, 'value')
67
 
68
+ # Function to update the main panel content when button1 is pressed
69
+ def update_main_panel_button1(event):
70
+ main_panel.clear() # Clear the existing main panel content
71
+ main_panel.append(pn.pane.Markdown("You pressed button1!"))
72
+
73
+ # Function to update the main panel content when button3 is pressed
74
+ def update_main_panel_button3(event):
75
+ main_panel.clear() # Clear the existing main panel content
76
+ main_panel.append(pn.pane.Markdown("You pressed button3!"))
77
+
78
+ # Attach the functions to the on_click event of button1 and button3
79
+ button1.on_click(update_main_panel_button1)
80
+ button3.on_click(update_main_panel_button3)
81
+
82
+ # Create the main panel with some initial content
83
+ main_panel = pn.Column(pn.pane.Markdown("# Main Panel"))
84
+
85
+ # Define a callback to show/hide the select buttons when "Settings" button is toggled
86
+ def toggle_date_picker(event):
87
+ if event.new:
88
+ # Create a FloatPanel and place the DatePicker inside it
89
+ float_panel = pn.layout.FloatPanel(date_picker, name="Free Floating FloatPanel", contained=False, position='bottom_left')
90
+ float_panel.show()
91
+ else:
92
+ # Remove any existing FloatPanel if the toggle is set to False
93
+ try:
94
+ float_panel.close()
95
+ except NameError:
96
+ pass
97
+
98
  # List to store the entered options
99
  loaded_dict = TLDR.load_categories()
100
 
 
105
  header_buttons = pn.Row(sizing_mode='stretch_width', css_classes=['header-buttons'])
106
 
107
  # "+" button to trigger the addition to the header
108
+ add_to_header_button = pn.widgets.Button(name="", icon='search', icon_size='1.5em', button_style = 'outline',button_type = 'light')
109
 
110
  # List to store the names of buttons to be added to the header
111
  buttons_to_add = []
 
136
  header_buttons.clear() # Clear the existing buttons
137
 
138
  for button_name in buttons_to_add:
139
+ header_button = pn.widgets.Button(name=button_name, button_type = 'primary', button_style = 'outline')
140
  header_button.on_click(remove_from_header) # Add callback to remove the header button
141
  header_buttons.append(header_button)
142
  buttons_to_add
 
170
  template = pn.template.FastListTemplate(
171
  title="EasySciRead",
172
  header=[pn.Row(header_buttons, width=750, sizing_mode='stretch_width'), pn.Row(filter_list, width=250), pn.Row(add_to_header_button, width=55)],
173
+ main= main_body_instance.update,
174
  sidebar=[buttons],
175
  accent_base_color="#88d8b0",
176
  header_background="#FFFFFF",
177
  header_color="#000000",
178
  text_align='center',
179
+ sidebar_width=160,
180
+ sizing_mode = 'stretch_both'
181
  )
182
 
 
 
 
 
 
 
 
 
 
 
 
 
183
  # Run the app
184
+ template.servable()