georad commited on
Commit
0682b30
·
verified ·
1 Parent(s): 11b9e87

Update pages/home.py

Browse files
Files changed (1) hide show
  1. pages/home.py +53 -0
pages/home.py CHANGED
@@ -3,6 +3,58 @@ import streamlit.components.v1 as components
3
  from streamlit_shortcuts import button, add_keyboard_shortcuts
4
  import base64
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  st.title("📘Named Entity Recognition")
7
 
8
  st.header("Tags the below 41 medical entities")
@@ -65,3 +117,4 @@ st.markdown("""
65
  }, 500);
66
  </script>
67
  """, unsafe_allow_html=True)
 
 
3
  from streamlit_shortcuts import button, add_keyboard_shortcuts
4
  import base64
5
 
6
+ # This is the key secret to making auto-scrolling work
7
+ # By registering query parameters, we can control which part of the page to show
8
+ import time
9
+ from urllib.parse import quote
10
+
11
+ st.header("Tags the below 5 medical entities")
12
+ st.write("ACTIVITY")
13
+ st.write("ADMINISTRATION")
14
+ st.write("AGE")
15
+ st.write("AREA")
16
+ st.write("BIOLOGICAL_ATTRIBUTE")
17
+
18
+ # Initialize session state to track if we need to scroll
19
+ if 'init_scroll' not in st.session_state:
20
+ st.session_state.init_scroll = True
21
+
22
+ # Show all the content
23
+ st.subheader("Scrollable Content")
24
+ for i in range(99): # Show all but the last item
25
+ st.write(f"This is scrollable content line {i}")
26
+
27
+ # Bottom indicator and the last line (this is what we'll scroll to)
28
+ bottom_content = st.container()
29
+ with bottom_content:
30
+ st.write("This is scrollable content line 99")
31
+ st.success("🔽 Bottom of the page 🔽")
32
+
33
+ # Create a button that will refresh the page, causing the auto-scroll code to execute
34
+ if st.button("Click to Scroll to Bottom") or st.session_state.init_scroll:
35
+ # Update session state so it only auto-scrolls once unless button is clicked
36
+ st.session_state.init_scroll = False
37
+
38
+ # This is the trick: inject a small snippet that forces the container
39
+ # to be navigated to via HTML anchor
40
+ bottom_anchor_id = f"bottom-{int(time.time())}"
41
+ st.markdown(f"<div id='{bottom_anchor_id}'></div>", unsafe_allow_html=True)
42
+
43
+ # Force a page rerun with a focus on the bottom section
44
+ # This query parameter approach sometimes works where JavaScript fails
45
+ js = f"""
46
+ <script>
47
+ // Try to scroll to the bottom using multiple methods
48
+ document.getElementById('{bottom_anchor_id}').scrollIntoView();
49
+ window.location.href = "#bottom-{bottom_anchor_id}";
50
+
51
+ // As a fallback, try a direct scroll command
52
+ window.scrollTo(0, document.body.scrollHeight);
53
+ </script>
54
+ """
55
+ st.components.v1.html(js, height=0)
56
+
57
+ '''
58
  st.title("📘Named Entity Recognition")
59
 
60
  st.header("Tags the below 41 medical entities")
 
117
  }, 500);
118
  </script>
119
  """, unsafe_allow_html=True)
120
+ '''