Spaces:
Sleeping
Sleeping
eaglelandsonce
commited on
Update pages/07_Physics_Test_Sets.py
Browse files
pages/07_Physics_Test_Sets.py
CHANGED
@@ -1,10 +1,11 @@
|
|
1 |
import streamlit as st
|
2 |
import os
|
|
|
3 |
|
4 |
# Title of the page
|
5 |
st.title("Physics Test Sets")
|
6 |
|
7 |
-
# Create a column layout for displaying links
|
8 |
col1, col2, col3 = st.columns(3)
|
9 |
|
10 |
# Function to display a clickable download link for the PDF
|
@@ -19,10 +20,24 @@ def create_pdf_link(pdf_name, file_path):
|
|
19 |
else:
|
20 |
st.error(f"File {pdf_name} not found!")
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
# Display the first PDF link as a clickable download button in the first column
|
23 |
with col1:
|
24 |
-
|
|
|
|
|
|
|
|
|
25 |
with col2:
|
26 |
-
|
|
|
|
|
|
|
27 |
|
28 |
# Add more columns and rows as needed for additional PDFs
|
|
|
1 |
import streamlit as st
|
2 |
import os
|
3 |
+
import base64
|
4 |
|
5 |
# Title of the page
|
6 |
st.title("Physics Test Sets")
|
7 |
|
8 |
+
# Create a column layout for displaying links and PDFs
|
9 |
col1, col2, col3 = st.columns(3)
|
10 |
|
11 |
# Function to display a clickable download link for the PDF
|
|
|
20 |
else:
|
21 |
st.error(f"File {pdf_name} not found!")
|
22 |
|
23 |
+
# Function to display the PDF in the Streamlit page
|
24 |
+
def display_pdf(pdf_file):
|
25 |
+
with open(pdf_file, "rb") as f:
|
26 |
+
base64_pdf = base64.b64encode(f.read()).decode('utf-8')
|
27 |
+
pdf_display = f'<iframe src="data:application/pdf;base64,{base64_pdf}" width="700" height="900" type="application/pdf"></iframe>'
|
28 |
+
st.markdown(pdf_display, unsafe_allow_html=True)
|
29 |
+
|
30 |
# Display the first PDF link as a clickable download button in the first column
|
31 |
with col1:
|
32 |
+
pdf_path_1 = os.path.join("psets", "eJackson_set1.pdf")
|
33 |
+
create_pdf_link("Electrodynamics Test Set 1", pdf_path_1)
|
34 |
+
if st.button("View Electrodynamics Test Set 1"):
|
35 |
+
display_pdf(pdf_path_1)
|
36 |
+
|
37 |
with col2:
|
38 |
+
pdf_path_2 = os.path.join("psets", "Griffiths_Example.pdf")
|
39 |
+
create_pdf_link("Griffiths Example", pdf_path_2)
|
40 |
+
if st.button("View Griffiths Example"):
|
41 |
+
display_pdf(pdf_path_2)
|
42 |
|
43 |
# Add more columns and rows as needed for additional PDFs
|