Streamlit Multipages set default "wide layout"

Hello. Simple question, is there a way to set the default layout to ā€œwide modeā€?

I use ā€œset_page_configā€ but because I can only use this on the main app.py, when i refresh or reload the browser tab (Iā€™m using streamlit cloud) whilst Iā€™m on another page other than app.py the layout wide mode is again reset. Itā€™s fixed if I go back app.py and back to the other pages again. So, set_page_config is not cutting it. Can we make it so that the default layout is ā€œwideā€ so i dont have to use set_page_config?

One other annoying thing about this during development is when i change something in my code and Iā€™m not on app.py and streamlit autoreloads because of the changes in the code, it gives an error saying something like:

streamlit.errors.StreamlitAPIException: set_page_config() can only be called once per app

but i only have it on app.py. I think one thing that could fix this is a function that makes it so that when the code autoupdates or the browser tab is reloaded, because we have multipages, it should redirect back to app.py where it can find set_page_config (or at least a function we can use to manually redirect the page combined with session_states)

Thank you in advance

Hi @Shiro,

Thanks for posting!

st.set_page_config should enable you to toggle between wide and centered mode dynamically when switching between pages of a multi-page app. Since the function works nicely with callbacks, if youā€™re selecting a page in a multipage app using an st.selectbox , for example, you could call st.set_page_config with the desired layout argument within the callback to the widget depending on the page that youā€™re on.

Related GH issue where @vdonato explained the above

Caroline :balloon:

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