streamlit / docs

Source code for the Streamlit Python library documentation
https://docs.streamlit.io
Apache License 2.0
110 stars 459 forks source link

State in the docs that the contents of a st.Page must be on root level #1102

Closed george-gca closed 2 months ago

george-gca commented 2 months ago

Link to doc page in question (if any): https://docs.streamlit.io/develop/api-reference/navigation/st.page

Name of the Streamlit feature whose docs need improvement: st.navigation and st.Page

What you think the docs should say: There should be stated somewhere in the docs (I think both in st.navigation and st.Page) that the code for the page must be on the root of the page.

That might seem obvious, but I was migrating some code to be on a page, and in that code I previously used if __name__ == '__main__': to separate the main code from the functions. I thought that since st.navigation uses run() to run the navigation, maybe creating a run() function inside the page would work, but it didn't.