georad commited on
Commit
ce47786
·
verified ·
1 Parent(s): c3ae9df

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -45
app.py CHANGED
@@ -1,58 +1,46 @@
1
  import streamlit as st
2
 
3
  # Set page config
4
- st.set_page_config(page_title="JavaScript Status Widget Fix", layout="wide")
5
-
6
- # JavaScript approach to fix the status widget position
7
- js_code = """
8
- <script>
9
- // Function to fix the position of the status widget
10
- function fixStatusWidget() {
11
- // Try to find the status widget using different possible selectors
12
- const statusWidget =
13
- document.querySelector('[data-testid="stStatusWidget"]') ||
14
- document.querySelector('.stStatusWidget') ||
15
- document.querySelector('button[kind="formSubmit"]').closest('div').closest('div');
 
 
 
 
 
 
16
 
17
- if (statusWidget) {
18
- // Set fixed positioning
19
- statusWidget.style.position = 'fixed';
20
- statusWidget.style.top = '10px';
21
- statusWidget.style.right = '10px';
22
- statusWidget.style.zIndex = '1000000';
23
- statusWidget.style.backgroundColor = 'white';
24
- statusWidget.style.borderRadius = '4px';
25
- statusWidget.style.boxShadow = '0 0 10px rgba(0,0,0,0.2)';
26
- statusWidget.style.padding = '4px';
27
- console.log('Status widget positioned successfully');
28
- } else {
29
- console.log('Status widget not found, will retry');
30
  }
31
- }
32
-
33
- // Try to fix the widget immediately
34
- fixStatusWidget();
35
-
36
- // Also run after a delay to make sure the DOM is fully loaded
37
- setTimeout(fixStatusWidget, 1000);
38
-
39
- // Continue checking periodically in case the widget gets recreated
40
- setInterval(fixStatusWidget, 2000);
41
- </script>
42
- """
43
-
44
- # Inject the JavaScript
45
- st.components.v1.html(js_code, height=0)
46
 
47
  # Your regular Streamlit app content
48
- st.title("App with JavaScript-Fixed Status Widget")
49
- st.write("Scroll down to see if the status widget stays fixed")
50
 
51
- # Generate content for scrolling test
52
  for i in range(30):
53
  st.write(f"Testing content line {i}")
54
- if i % 10 == 0:
55
- st.markdown("### Section Break")
56
 
57
  # --- SHARED ON ALL PAGES ---
58
  st.logo(image="images/menu_book_60dp_75FBFD.png")
 
1
  import streamlit as st
2
 
3
  # Set page config
4
+ st.set_page_config(page_title="Fixed Top Toolbar", layout="wide")
5
+
6
+ # CSS to fix the entire top toolbar
7
+ st.markdown("""
8
+ <style>
9
+ /* Target the entire header/toolbar section */
10
+ header[data-testid="stHeader"],
11
+ header.css-18ni7ap.e8zbici2,
12
+ .stApp > header {
13
+ position: fixed !important;
14
+ top: 0 !important;
15
+ left: 0 !important;
16
+ right: 0 !important;
17
+ height: auto !important;
18
+ z-index: 999999 !important;
19
+ background-color: white !important;
20
+ box-shadow: 0 1px 5px rgba(0,0,0,0.1) !important;
21
+ }
22
 
23
+ /* Add padding to main content to prevent it being hidden under fixed header */
24
+ .main .block-container {
25
+ padding-top: 3rem !important;
 
 
 
 
 
 
 
 
 
 
26
  }
27
+
28
+ /* Make sure status widget appears above other elements */
29
+ [data-testid="stStatusWidget"] {
30
+ z-index: 1000000 !important;
31
+ }
32
+ </style>
33
+ """, unsafe_allow_html=True)
 
 
 
 
 
 
 
 
34
 
35
  # Your regular Streamlit app content
36
+ st.title("App with Fixed Top Toolbar")
37
+ st.write("Scroll down to test if the toolbar and status widget stay fixed")
38
 
39
+ # Generate content for scrolling
40
  for i in range(30):
41
  st.write(f"Testing content line {i}")
42
+ if i % 5 == 0:
43
+ st.markdown("---")
44
 
45
  # --- SHARED ON ALL PAGES ---
46
  st.logo(image="images/menu_book_60dp_75FBFD.png")