Spaces:
Sleeping
Sleeping
Commit
·
06b9c8f
1
Parent(s):
e277b73
Try to have direct links for pages
Browse files
app.py
CHANGED
@@ -1,13 +1,17 @@
|
|
1 |
import streamlit as st
|
2 |
import page_home
|
3 |
import page_likert
|
|
|
4 |
|
5 |
# Default to wide mode
|
6 |
st.set_page_config(layout="wide")
|
7 |
|
8 |
# Initialize a session state variable for page navigation
|
9 |
if 'page' not in st.session_state:
|
10 |
-
|
|
|
|
|
|
|
11 |
|
12 |
# Sidebar navigation using buttons
|
13 |
st.sidebar.title("Navigation")
|
@@ -16,6 +20,9 @@ if st.sidebar.button("Home"):
|
|
16 |
if st.sidebar.button("Likert"):
|
17 |
st.session_state['page'] = 'Likert'
|
18 |
|
|
|
|
|
|
|
19 |
# Page contents based on session state
|
20 |
if st.session_state['page'] == 'Home':
|
21 |
page_home.show()
|
@@ -24,4 +31,4 @@ elif st.session_state['page'] == 'Likert':
|
|
24 |
|
25 |
# Rerun Calculations
|
26 |
if st.sidebar.button("Rerun Calculations"):
|
27 |
-
st.rerun()
|
|
|
1 |
import streamlit as st
|
2 |
import page_home
|
3 |
import page_likert
|
4 |
+
from urllib.parse import quote, unquote
|
5 |
|
6 |
# Default to wide mode
|
7 |
st.set_page_config(layout="wide")
|
8 |
|
9 |
# Initialize a session state variable for page navigation
|
10 |
if 'page' not in st.session_state:
|
11 |
+
# Check if a page is specified in the query parameters
|
12 |
+
query_params = st.experimental_get_query_params()
|
13 |
+
initial_page = unquote(query_params.get("page", ["Home"])[0])
|
14 |
+
st.session_state['page'] = initial_page
|
15 |
|
16 |
# Sidebar navigation using buttons
|
17 |
st.sidebar.title("Navigation")
|
|
|
20 |
if st.sidebar.button("Likert"):
|
21 |
st.session_state['page'] = 'Likert'
|
22 |
|
23 |
+
# Update the query parameters based on the session state
|
24 |
+
st.experimental_set_query_params(page=quote(st.session_state['page']))
|
25 |
+
|
26 |
# Page contents based on session state
|
27 |
if st.session_state['page'] == 'Home':
|
28 |
page_home.show()
|
|
|
31 |
|
32 |
# Rerun Calculations
|
33 |
if st.sidebar.button("Rerun Calculations"):
|
34 |
+
st.rerun()
|