georad commited on
Commit
fb22e4f
·
verified ·
1 Parent(s): 4b3aa5a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -49
app.py CHANGED
@@ -1,12 +1,12 @@
1
  import streamlit as st
2
 
3
  # Inspect the header element, go to the "Computed" tab in styles, and find its height.
4
- #HEADER_HEIGHT = "60px" # EXAMPLE: Adjust this (e.g., "56px", "4rem")
5
- #HEADER_SELECTOR = 'header[data-testid="stHeader"]'
6
 
7
  # ---- SELECTOR FOR THE MAIN CONTENT AREA THAT NEEDS PADDING ----
8
  # Target the first direct div child of the stAppViewContainer which often holds the main scrollable content
9
- #MAIN_CONTENT_SELECTOR = 'section[data-testid="stMain"]'
10
  #MAIN_CONTENT_SELECTOR = 'section[data-testid="stMain"] > div:nth-child(1)'
11
  #MAIN_CONTENT_SELECTOR = 'section[data-testid="stMainBlockContainer"]'
12
  #MAIN_CONTENT_SELECTOR = 'section[data-testid="stAppViewContainer"]'
@@ -17,42 +17,42 @@ import streamlit as st
17
  #MAIN_CONTENT_SELECTOR = 'section[data-testid="stAppViewContainer"] .block-container'
18
  #MAIN_CONTENT_SELECTOR = '.main .block-container' # A more general selector for block-container
19
 
20
- #custom_css = f"""
21
- #<style>
22
- # /* Making the Streamlit header sticky */
23
- # {HEADER_SELECTOR} {{
24
- # position: -webkit-sticky !important; /* For Safari */
25
- # position: sticky !important;
26
- # top: 0 !important;
27
- # z-index: 9999 !important; /* Very high z-index */
28
- # background-color: #90EE90 !important; /* Or your app's header background color */
29
- # /* Add a subtle shadow to make it feel more distinct when content scrolls under */
30
- # /* box-shadow: 0 2px 4px -1px rgba(0,0,0,0.1); */
31
- # /*.reportview-container .main .block-container{{ */
32
- # /* padding-top: 0rem; */
33
- # /* }} */
34
- # }}
35
 
36
- # /* Adding padding to the main content area to prevent overlap with the sticky header */
37
- # {MAIN_CONTENT_SELECTOR} {{
38
- # padding-top: 10px !important; /* {HEADER_HEIGHT} !important; */
39
- # /* background-color: yellow !important; */
40
- # /* border-style: solid !important; */
41
- # /* border-color: red !important; */
42
- # }}
43
 
44
- # /* Optional: If your app is set to wide mode and the header isn't spanning full width */
45
- # /* This might be needed if the sticky positioning affects its width calculation. */
46
- # /*
47
- # #{HEADER_SELECTOR} {{
48
- # # width: 100% !important;
49
- # #}}
50
- # #*/
51
- #</style>
52
- #"""
53
 
54
  # Inject CSS as early as possible in your app
55
- #st.markdown(custom_css, unsafe_allow_html=True)
56
 
57
  # --- PAGE SETUP ---
58
  type_text_page = st.Page(
@@ -64,27 +64,21 @@ type_text_page = st.Page(
64
 
65
  # --- Your Streamlit App ---
66
  #st.logo(image="images/menu_book_60dp_75FBFD.png")
67
- #st.title("Map descriptions to SBS codes with Sentence Transformer + Reasoning")
68
- #st.subheader("Select specific Chapter for quicker results")
69
- #st.logo(image="images/menu_book_60dp_75FBFD.png")
70
- #t.sidebar.header("SBS V2.0 mapper")
71
- #st.sidebar.write("(work in progress)")
72
- #t.sidebar.text("Demo by JA-RAD")
73
 
74
 
75
 
76
  # --- NAVIGATION SETUP ---
77
- #pg = st.navigation(pages=[type_text_page]) # WITHOUT SECTIONS
78
  ##pg = st.navigation({"Chapter_Index": [start_page], "Demo": [type_text_page, upload_file_page], "About": [about_page]}) # WITH SECTIONS
79
- #pg.run()
80
 
81
 
82
  if __name__ == "__main__":
83
- #st.title("Map descriptions to SBS codes with Sentence Transformer + Reasoning")
84
- #st.subheader("Select specific Chapter for quicker results")
85
- #st.logo(image="images/menu_book_60dp_75FBFD.png")
86
- #st.sidebar.header("SBS V2.0 mapper")
87
- #st.sidebar.write("(work in progress)")
88
- #st.sidebar.text("Demo by JA-RAD")
89
  pg = st.navigation(pages=[type_text_page]) # WITHOUT SECTIONS
90
  pg.run()
 
1
  import streamlit as st
2
 
3
  # Inspect the header element, go to the "Computed" tab in styles, and find its height.
4
+ HEADER_HEIGHT = "60px" # EXAMPLE: Adjust this (e.g., "56px", "4rem")
5
+ HEADER_SELECTOR = 'header[data-testid="stHeader"]'
6
 
7
  # ---- SELECTOR FOR THE MAIN CONTENT AREA THAT NEEDS PADDING ----
8
  # Target the first direct div child of the stAppViewContainer which often holds the main scrollable content
9
+ MAIN_CONTENT_SELECTOR = 'section[data-testid="stMain"]'
10
  #MAIN_CONTENT_SELECTOR = 'section[data-testid="stMain"] > div:nth-child(1)'
11
  #MAIN_CONTENT_SELECTOR = 'section[data-testid="stMainBlockContainer"]'
12
  #MAIN_CONTENT_SELECTOR = 'section[data-testid="stAppViewContainer"]'
 
17
  #MAIN_CONTENT_SELECTOR = 'section[data-testid="stAppViewContainer"] .block-container'
18
  #MAIN_CONTENT_SELECTOR = '.main .block-container' # A more general selector for block-container
19
 
20
+ custom_css = f"""
21
+ <style>
22
+ /* Making the Streamlit header sticky */
23
+ {HEADER_SELECTOR} {{
24
+ position: -webkit-sticky !important; /* For Safari */
25
+ position: sticky !important;
26
+ top: 0 !important;
27
+ z-index: 9999 !important; /* Very high z-index */
28
+ background-color: #90EE90 !important; /* Or your app's header background color */
29
+ /* Add a subtle shadow to make it feel more distinct when content scrolls under */
30
+ /* box-shadow: 0 2px 4px -1px rgba(0,0,0,0.1); */
31
+ /*.reportview-container .main .block-container{{ */
32
+ /* padding-top: 0rem; */
33
+ /* }} */
34
+ }}
35
 
36
+ /* Adding padding to the main content area to prevent overlap with the sticky header */
37
+ {MAIN_CONTENT_SELECTOR} {{
38
+ padding-top: 10px !important; /* {HEADER_HEIGHT} !important; */
39
+ /* background-color: yellow !important; */
40
+ /* border-style: solid !important; */
41
+ /* border-color: red !important; */
42
+ }}
43
 
44
+ /* Optional: If your app is set to wide mode and the header isn't spanning full width */
45
+ /* This might be needed if the sticky positioning affects its width calculation. */
46
+ /*
47
+ #{HEADER_SELECTOR} {{
48
+ # width: 100% !important;
49
+ #}}
50
+ #*/
51
+ </style>
52
+ """
53
 
54
  # Inject CSS as early as possible in your app
55
+ st.markdown(custom_css, unsafe_allow_html=True)
56
 
57
  # --- PAGE SETUP ---
58
  type_text_page = st.Page(
 
64
 
65
  # --- Your Streamlit App ---
66
  #st.logo(image="images/menu_book_60dp_75FBFD.png")
67
+ st.title("Map descriptions to SBS codes with Sentence Transformer + Reasoning")
68
+ st.subheader("Select specific Chapter for quicker results")
69
+ st.logo(image="images/menu_book_60dp_75FBFD.png")
70
+ t.sidebar.header("SBS V2.0 mapper")
71
+ st.sidebar.write("(work in progress)")
72
+ st.sidebar.text("Demo by JA-RAD")
73
 
74
 
75
 
76
  # --- NAVIGATION SETUP ---
77
+ pg = st.navigation(pages=[type_text_page]) # WITHOUT SECTIONS
78
  ##pg = st.navigation({"Chapter_Index": [start_page], "Demo": [type_text_page, upload_file_page], "About": [about_page]}) # WITH SECTIONS
79
+ pg.run()
80
 
81
 
82
  if __name__ == "__main__":
 
 
 
 
 
 
83
  pg = st.navigation(pages=[type_text_page]) # WITHOUT SECTIONS
84
  pg.run()