jozi
November 16, 2023, 3:17pm
1
To display pages in the main .py file, I use show_pages as follows:
from st_pages import hide_pages, show_pages, Page
show_pages(
[
Page("app.py"),
Page("pages/1_A.py"),
Page("pages/2_B.py"),
]
)
But what if I want to hide a page using hide_pages ?
If I add to the code above:
hide_pages(
[
Page("pages/test.py"),
]
)
And then I want to open a test page using the url http://localhost:8501/test ,
it prints:
Page not found
You have requested page /test, but no corresponding file was found in the app’s pages/ directory. Running the app’s main page.
Goyo
November 16, 2023, 6:33pm
2
Doesn’t the call to hide_pages actually hide the pages?
jozi
November 16, 2023, 7:13pm
3
According to the documentation, these pages should only be hidden via CSS and can still be visited using the URL.
These pages are only hidden via CSS, and can still be visited by the URL.
jozi
November 16, 2023, 7:32pm
5
And if i try to open the hidden page using URL it says:
Page not found
You have requested page /test, but no corresponding file was found in the app’s pages/ directory. Running the app’s main page.
jozi
November 17, 2023, 8:53pm
6
miukki
April 15, 2024, 5:42am
7
the following code should work:
from st_pages import show_pages, hide_pages, Page
show_pages(
[
Page("home.py"),
Page("pages/test.py"),
Page("pages/example.py"),
]
)
hide_pages(
[
"Example",#correct use name
]
)
D111
October 12, 2024, 2:19am
8
ImportError: cannot import name ‘show_pages’ from ‘st_pages’
How to solve this?
Also I found hide_pages is overwritten if we have Python scripts inside the pages folder
How to overcome this?
D111
October 12, 2024, 5:32am
9
I was not able to get this hide_pages, and show_pages functionality to work. However the purpose I tried to get this to work was because of the sidebar.
This streamlit discussion
Go inspect the source code and was able to disable the sidebar/navbar completely.
For me the data-testid is “stSidebar”
st.markdown(
"""
<style>
[data-testid="stSidebar"] {
display: none
}
</style>
""",
unsafe_allow_html=True,
)
system
Closed
April 10, 2025, 5:32am
10
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.