Streamlit navigation button

Hi ,

I have 2 pages main.py and sample.py
I want to make a button in main.py so it can navigate to sample.py.

You can call switch_page when the button is pressed. You may be interested in page_link too.

1 Like

Hi , I dont want main and display to be present in sidebar. so the main.py is main page there is one button submit , when I click on it it should go to sample.py and display it. I tried both but it is giving me side bar also, which I donโ€™t want. Is there any way ?

image

You can use the switch page feature and hide the sidebar simultaneously, hence the only way to access the other page is through the button. You can refer to the following,

I dont want to completely hide my side bar as it contain more thingsโ€ฆ Is it possible to hide certain things from side bar

For that you have the configuration option client.showSidebarNavigation

sorry I am not getting this

Whether to show the pages navigation menu in the sidebar is a configuration option that defaults to true. You can set it to false in the command line when you run the script:

streamlit run main.py --client.showSidebarNavigation false

You can also use environment variables or a configuration file as explained in the docs:

Let me know if there is something that you donโ€™t understand.

1 Like

both main.py and sample.py is a streamlit code so when I am using switch_page or page_link sample.py is not getting displayed

It works for me. You must be doing something different.

Your sample.py should be inside the pages folder for it to work.

Hi @Ritushree_Pagare if I got it correct may be you are looking something page redirect.

You can try st.link_button this will allow you to open new page on click.
Thanks