-
Notifications
You must be signed in to change notification settings - Fork 1
/
multiapp.py
42 lines (34 loc) · 944 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
33
34
35
36
37
38
39
40
import pandas_datareader as data
import streamlit as st
class MultiApp:
"""Framework for combining multiple streamlit applications.
Usage:
def foo():
st.title("Hello Foo")
def bar():
st.title("Hello Bar")
app = MultiApp()
app.add_app("Foo", foo)
app.add_app("Bar", bar)
app.run()
It is also possible keep each application in a separate file.
import foo
import bar
app = MultiApp()
app.add_app("Foo", foo.app)
app.add_app("Bar", bar.app)
app.run()
"""
def __init__(self):
self.apps = []
def add_app(self, title, func):
self.apps.append({
"title": title,
"function": func
})
def run(self):
app = st.radio(
'',
self.apps,
format_func=lambda app: app['title'])
app['function']()