Switch page function reloading page

I have, in my Main.py file, the switch_page function which works perfectly for me to go to any page within my pages folder. However, when I try to utilise this same command in one of the pages within the folder, it just reloads the page. Is there an easy fix?

1 Like

From the docs:

The specified page must be recognized by Streamlit’s multipage architecture (your main Python file or a Python file in a pages/ folder). Arbitrary Python scripts cannot be passed to st.switch_page.

1 Like

So I can switch to one of my pages while in main but not while in another page? I’m a bit confused by that.
Screenshot from 2024-03-16 22-58-35
This works to switch to my stock input page inside my pages folder

Screenshot from 2024-03-16 22-58-19
This doesn’t work while I’m inside the pages folder.
My file directory goes as follows:
1-Main.py
1-pages (into 2)
2-Stock_Input.py
2-Create_Prediction.py
2-Previous_Predictions.py
2-Historical_Data.py
I’ve looked through the documentation which seems to have this work without the problem I’m having. If you could help me to understand that would be appreciated thanks!

1 Like

I don’t understand your file directory and having the code as pictures instead of text doesn’t help, but it doesn’t look like the examples, at all.

1 Like

I can see you are using buttons. Be careful in using buttons.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.