@blackary Since this will allow opening another page using buttons, is there an option to remove the sidebar pages option as it won’t make any sense
Hey, I am using your approach for my app. Everything works perfectly in my local. However, when I deploy the app onto AWS, the switch_page() gives an error, which says that.
ValueError: Could not find page <name_ofmy_page>. Must be one of ['init ']
It sounds like your other pages aren’t actually being loaded – do you see them in the sidebar?
Can confirm that this method doesn’t work on st 1.26.0. I keep getting errors like this:
ImportError: cannot import name '_RerunData' from 'streamlit' (/Users/behnam/opt/anaconda3/envs/streamlit-app/lib/python3.11/site-packages/streamlit/__init__.py)
or
ModuleNotFoundError: No module named 'streamlit_extras.<my-app-name>'
the first error occurs if I don’t use the st_extras package and simply use the switch_page
function defined above. The second one occurs when I use the st_extras
package, import extra
and modify the switch_page
function with my own app name.
@behnamoh Did you try using it like this?
from streamlit_extras.switch_page_button import switch_page
want_to_contribute = st.button("I want to contribute!")
if want_to_contribute:
switch_page("Contribute")
Also make sure switch_page argument is single quotes
switch_page('Trial')
Exactly how @mathcatsand and @behnamoh did in their illustrated above. This is in contrast to show_pages which uses double quotes. This one hung me up for a good hour.
That is not correct, actually. Python treats single quotes and double quotes the same, so either one will work fine.
Thank you for setting the record straight. I must have changed something else in the same commit. I don’t have time to figure out right now. Fortunately it all works.
can i build 2 pages?. the one is excel input page(that contains welcoming to the user) and then after user input the excel. page will be redirect to main page that will show analytic from user input