georad commited on
Commit
4db2c59
·
verified ·
1 Parent(s): 8393070

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -40
app.py CHANGED
@@ -1,61 +1,59 @@
1
  import streamlit as st
2
 
3
  # Set page config
4
- st.set_page_config(page_title="Virtual Sticky Header", layout="wide")
5
 
6
- # Create a session state to track which section we're viewing
7
- if 'current_section' not in st.session_state:
8
- st.session_state.current_section = "section1"
9
-
10
- # Create columns for our layout
11
- col1, col2, col3 = st.columns([1, 2, 1])
12
-
13
- # Function to create our "sticky" header
14
- def create_header():
15
- with st.container():
16
- st.markdown("### My Application")
17
- tab1, tab2, tab3 = st.tabs(["Section 1", "Section 2", "Section 3"])
18
-
19
- with tab1:
20
- if st.button("Go to Section 1"):
21
- st.session_state.current_section = "section1"
22
- st.experimental_rerun()
23
-
24
- with tab2:
25
- if st.button("Go to Section 2"):
26
- st.session_state.current_section = "section2"
27
- st.experimental_rerun()
28
-
29
- with tab3:
30
- if st.button("Go to Section 3"):
31
- st.session_state.current_section = "section3"
32
- st.experimental_rerun()
33
 
34
- # Create our header
35
- create_header()
36
 
37
- # Display content based on the current section
38
- if st.session_state.current_section == "section1":
39
  st.header("Section 1")
40
  st.write("This is section 1 content")
41
- for i in range(10):
42
  st.write(f"Content line {i}")
43
 
44
- elif st.session_state.current_section == "section2":
45
  st.header("Section 2")
46
  st.write("This is section 2 content")
47
- for i in range(10):
48
  st.write(f"Content line {i}")
49
 
50
- elif st.session_state.current_section == "section3":
51
  st.header("Section 3")
52
  st.write("This is section 3 content")
53
- for i in range(10):
54
  st.write(f"Content line {i}")
55
 
56
- # Add a "back to top" button at the bottom
57
- if st.button("Back to Top"):
58
- st.experimental_rerun()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
 
60
 
61
 
 
1
  import streamlit as st
2
 
3
  # Set page config
4
+ st.set_page_config(page_title="Multipage Navigation", layout="wide")
5
 
6
+ # Use sidebar as a persistent navigation element (this is always visible)
7
+ with st.sidebar:
8
+ st.title("My Application")
9
+ st.markdown("### Navigation")
10
+
11
+ nav_option = st.radio(
12
+ "Go to:",
13
+ ["Section 1", "Section 2", "Section 3"],
14
+ key="nav_radio"
15
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
+ # Main content area
18
+ st.title("My Application")
19
 
20
+ # Display content based on navigation selection
21
+ if nav_option == "Section 1":
22
  st.header("Section 1")
23
  st.write("This is section 1 content")
24
+ for i in range(15):
25
  st.write(f"Content line {i}")
26
 
27
+ elif nav_option == "Section 2":
28
  st.header("Section 2")
29
  st.write("This is section 2 content")
30
+ for i in range(15):
31
  st.write(f"Content line {i}")
32
 
33
+ elif nav_option == "Section 3":
34
  st.header("Section 3")
35
  st.write("This is section 3 content")
36
+ for i in range(15):
37
  st.write(f"Content line {i}")
38
 
39
+ # Add "quick jump" buttons at the bottom
40
+ st.markdown("### Quick Navigation")
41
+ col1, col2, col3 = st.columns(3)
42
+
43
+ with col1:
44
+ if st.button("Jump to Section 1"):
45
+ st.session_state.nav_radio = "Section 1"
46
+ st.experimental_rerun()
47
+
48
+ with col2:
49
+ if st.button("Jump to Section 2"):
50
+ st.session_state.nav_radio = "Section 2"
51
+ st.experimental_rerun()
52
+
53
+ with col3:
54
+ if st.button("Jump to Section 3"):
55
+ st.session_state.nav_radio = "Section 3"
56
+ st.experimental_rerun()
57
 
58
 
59