Spaces:
Running
Running
Update app2.py
Browse files
app2.py
CHANGED
|
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import panel as pn
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
# Create buttons for the toggleable sidebar
|
| 6 |
+
button1 = pn.widgets.Button(icon='home', name="Home", icon_size='1.5em', button_type = 'primary', button_style = 'outline', width = 140)
|
| 7 |
+
button2 = pn.widgets.Button(icon='file-analytics', name='My papers', icon_size='1.5em', button_type = 'primary', button_style = 'outline', width = 140)
|
| 8 |
+
button3 = pn.widgets.Button(icon='settings', icon_size='1.5em', name='Settings', button_type = 'primary', button_style = 'outline', width = 140)
|
| 9 |
+
|
| 10 |
+
# Create a column layout for the buttons inside the toggleable sidebar
|
| 11 |
+
buttons = pn.Column(button1, button2, button3 , css_classes=['hidden'])
|
| 12 |
+
|
| 13 |
+
instructions = """
|
| 14 |
+
## Modified-gravity wormholes without exotic matter
|
| 15 |
+
### Tiberiu Harko, Francisco S. N. Lobo, M. K. Mak, and Sergey V. Sushkov
|
| 16 |
+
A fundamental ingredient in wormhole physics is the flaring-out condition at the throat which,
|
| 17 |
+
in classical general relativity, entails the violation of the null energy condition. In this work, we
|
| 18 |
+
present the most general conditions.....
|
| 19 |
+
"""
|
| 20 |
+
|
| 21 |
+
instructions2 = """
|
| 22 |
+
## Viability of Bouncing Cosmology in Energy-Momentum-Squared
|
| 23 |
+
### Ahmed H. Barbar, Adel M. Awad, and Mohammad T. AlFiky
|
| 24 |
+
We analyze the early-time isotropic cosmology in the so-called energy-momentum-squared gravity
|
| 25 |
+
(EMSG). In this theory, a FORMATAÇAO term is added to the Einstein-Hilbert action, which has been
|
| 26 |
+
shown to replace the initial singularity by a regular bounce. We show that this is not the case,
|
| 27 |
+
and the bouncing solution obtained does.....
|
| 28 |
+
"""
|
| 29 |
+
|
| 30 |
+
text = pn.pane.Markdown(instructions)
|
| 31 |
+
text2 = pn.pane.Markdown(instructions2)
|
| 32 |
+
|
| 33 |
+
# List to store the entered options
|
| 34 |
+
entered_options = [
|
| 35 |
+
"Astrophysics",
|
| 36 |
+
"Condensed Matter",
|
| 37 |
+
"Mathematical Physics",
|
| 38 |
+
"Nuclear Experiment"
|
| 39 |
+
]
|
| 40 |
+
|
| 41 |
+
# Create buttons for the header
|
| 42 |
+
header_buttons = pn.Row(sizing_mode='stretch_width', css_classes=['header-buttons'])
|
| 43 |
+
|
| 44 |
+
# "+" button to trigger the addition to the header
|
| 45 |
+
add_to_header_button = pn.widgets.Button(name="", icon='search', icon_size='1.5em', button_style = 'outline',button_type = 'light')
|
| 46 |
+
|
| 47 |
+
# List to store the names of buttons to be added to the header
|
| 48 |
+
buttons_to_add = []
|
| 49 |
+
|
| 50 |
+
# Callback for adding selected options to the list
|
| 51 |
+
def add_to_header(event):
|
| 52 |
+
selected_options = filter_list.value
|
| 53 |
+
if selected_options:
|
| 54 |
+
for option in selected_options:
|
| 55 |
+
if option not in buttons_to_add: # Check if option is already in header
|
| 56 |
+
buttons_to_add.append(option) # Add to header if not already present
|
| 57 |
+
filter_list.value = [] # Clear the selected options after adding them to the header
|
| 58 |
+
update_header() # Update the header after adding options
|
| 59 |
+
|
| 60 |
+
add_to_header_button.on_click(add_to_header)
|
| 61 |
+
|
| 62 |
+
# Function to update the header layout with the newly created buttons
|
| 63 |
+
def update_header():
|
| 64 |
+
header_buttons.clear() # Clear the existing buttons
|
| 65 |
+
for button_name in buttons_to_add:
|
| 66 |
+
header_button = pn.widgets.Button(name=button_name, button_type = 'primary', button_style = 'outline')
|
| 67 |
+
header_button.on_click(remove_from_header) # Add callback to remove the header button
|
| 68 |
+
header_buttons.append(header_button)
|
| 69 |
+
|
| 70 |
+
# Update the filter list options to exclude buttons that are already in the header
|
| 71 |
+
filter_list.options = [option for option in entered_options if option not in buttons_to_add]
|
| 72 |
+
|
| 73 |
+
# MultiChoice widget to display the filter options with delete buttons
|
| 74 |
+
filter_list = pn.widgets.MultiChoice(
|
| 75 |
+
name='',
|
| 76 |
+
value=[],
|
| 77 |
+
options=entered_options,
|
| 78 |
+
margin=(20, 10),
|
| 79 |
+
sizing_mode='fixed',
|
| 80 |
+
solid=False,
|
| 81 |
+
styles={'background': '#f0f0f0'},
|
| 82 |
+
placeholder="Search Topics"
|
| 83 |
+
)
|
| 84 |
+
|
| 85 |
+
# Callback to remove the clicked header button
|
| 86 |
+
def remove_from_header(event):
|
| 87 |
+
button = event.obj # Get the clicked button
|
| 88 |
+
if button.name in buttons_to_add:
|
| 89 |
+
buttons_to_add.remove(button.name) # Remove from the header buttons list
|
| 90 |
+
filter_list.options.append(button.name) # Add back to the filter list options
|
| 91 |
+
update_header() # Update the header and filter list
|
| 92 |
+
|
| 93 |
+
# Layout using Template
|
| 94 |
+
template = pn.template.FastListTemplate(
|
| 95 |
+
title="EasySciRead",
|
| 96 |
+
header=[pn.Row(header_buttons, width=800, sizing_mode='fixed'), pn.Row(filter_list, width=250), pn.Row(add_to_header_button, width=55)],
|
| 97 |
+
main=[
|
| 98 |
+
# First row of the grid
|
| 99 |
+
pn.Row(pn.pane.Markdown("# Cosmology"),
|
| 100 |
+
pn.Column(text, text2, sizing_mode='stretch_width'),
|
| 101 |
+
pn.Column(text2, text, sizing_mode='stretch_width'),
|
| 102 |
+
sizing_mode='stretch_width',
|
| 103 |
+
),
|
| 104 |
+
# Second row of the grid
|
| 105 |
+
pn.Row(pn.pane.Markdown("# Astrophysics"),
|
| 106 |
+
pn.Column(text, text2, sizing_mode='stretch_width'),
|
| 107 |
+
sizing_mode='stretch_width',
|
| 108 |
+
),
|
| 109 |
+
],
|
| 110 |
+
sidebar=[buttons],
|
| 111 |
+
accent_base_color="#88d8b0",
|
| 112 |
+
header_background="#FFFFFF",
|
| 113 |
+
header_color="#000000",
|
| 114 |
+
text_align='center',
|
| 115 |
+
sidebar_width=150
|
| 116 |
+
)
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
def run_code(event):
|
| 120 |
+
# Add your desired Python code here
|
| 121 |
+
# For example, let's print "Hello, Panel!" when the button is clicked
|
| 122 |
+
print("Hello, Panel!", flush = True)
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
# Attach the function to the button's on_click event
|
| 126 |
+
button3.on_click(run_code)
|
| 127 |
+
|
| 128 |
+
# Run the app
|
| 129 |
+
template.servable()
|