-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmultiapp.py
32 lines (26 loc) · 955 Bytes
/
multiapp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import streamlit as st
class MultiApp:
def __init__(self):
self.apps = []
def add_app(self, title, func):
self.apps.append({
"title": title,
"function": func
})
def run(self):
# Initialize session state if not already initialized
if 'selected_app' not in st.session_state:
st.session_state.selected_app = self.apps[0]['title']
# Sidebar app selection
selected_title = st.sidebar.selectbox(
'Navigation',
[app['title'] for app in self.apps],
index=[app['title'] for app in self.apps].index(st.session_state.selected_app)
)
# Update session state with selected app
st.session_state.selected_app = selected_title
# Run the selected app's function
for app in self.apps:
if app['title'] == selected_title:
app['function']()
break