Hi, I am building a multipage app, but cannot change the page when I run it locally. I currently have the different pages set-up as radio options in the sidebar. When I click on a different page/radio button, it jumps back to the first page again. There’s no error message - it just pretends as if I never tried to change the page.
I’m using a Python venv in PyCharm.
streamlit: 0.85.1
python: 3.8.2
macOS: Big Sur 11.4
The code for my app.py file looks like this…
import streamlit as st
from multiapp import MultiApp
# FIRST PAGE
def something():
st.title('SOMETHING')
# SECOND PAGE
def something_else():
st.title('Something Else')
# CREATE PAGES IN APP
app = MultiApp()
app.add_app("First Page", something)
app.add_app("Another Page", something_else)
app.run()
I’m using a file called multiapp that has the following code
"""Frameworks for running multiple Streamlit applications as a single app.
"""
import streamlit as st
class MultiApp:
"""Framework for combining multiple streamlit applications."""
def __init__(self):
self.apps = []
def add_app(self, title, func):
"""Adds a new application."""
self.apps.append({
"title": title,
"function": func
})
def run(self):
app = st.sidebar.radio(
'Go To',
self.apps,
format_func=lambda app: app['title'])
app['function']()