File size: 1,996 Bytes
b3d5435 9a10dbf 645f459 5c7db51 9a10dbf 645f459 b3d5435 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
import streamlit as st
# --- SHARED ON ALL PAGES ---
#st.logo(image=":material/medical_information:")
st.logo("images/medical_information_24dp_1F1F1F_FILL0_wght400_GRAD0_opsz24.png")
st.sidebar.text("Project by SPG")
# --- PAGE SETUP ---
home_page = st.Page(
page="pages/home.py",
title="Home",
icon=":material/home:",
default=True,)
type_text_page = st.Page(
page="pages/type_text.py",
title="type text",
icon=":material/keyboard:",
default=False,)
upload_file_page = st.Page(
page="pages/upload_file.py",
title="upload file",
icon=":material/file_upload:",
default=False,)
about_page = st.Page(
page="pages/about.py",
title="About the app",
icon=":material/info:",
default=False)
# --- Automatic Scrolling Approach ---
# Add a checkbox to control auto-scrolling
auto_scroll = st.sidebar.checkbox("Auto-scroll to bottom", value=True)
# Create scrollable content
for i in range(100):
st.write(f"This is scrollable content line {i}")
# Add a manual scroll button at both top and bottom for convenience
if st.button("Scroll to Bottom") or auto_scroll:
# Create a link target
st.markdown('''
<a name="bottom"></a>
''', unsafe_allow_html=True)
# Use Streamlit's HTML component to execute the scroll
st.components.v1.html('''
<script>
// Use the iframe parent to scroll the main content area
window.parent.document.querySelector('section.main').scrollTo({
top: window.parent.document.querySelector('section.main').scrollHeight,
behavior: 'smooth'
});
</script>
''', height=0)
# Add some text at the bottom as a visual indicator
st.write("You've reached the bottom!")
# --- NAVIGATION SETUP ---
#pg = st.navigation(pages=[home_page, type_text_page, upload_file_page, about_page]) # WITHOUT SECTIONS
pg = st.navigation({"Home": [home_page], "Demo": [type_text_page, upload_file_page], "About": [about_page]}) # WITH SECTIONS
pg.run() |