Spaces:
Sleeping
Sleeping
Delete appStore/multiapp.py
Browse files- appStore/multiapp.py +0 -69
appStore/multiapp.py
DELETED
@@ -1,69 +0,0 @@
|
|
1 |
-
"""Frameworks for running multiple Streamlit applications as a single app.
|
2 |
-
"""
|
3 |
-
import streamlit as st
|
4 |
-
from streamlit_option_menu import option_menu
|
5 |
-
from utils.uploadAndExample import add_upload
|
6 |
-
|
7 |
-
class MultiApp:
|
8 |
-
"""Framework for combining multiple streamlit applications.
|
9 |
-
Usage:
|
10 |
-
def foo():
|
11 |
-
st.title("Hello Foo")
|
12 |
-
def bar():
|
13 |
-
st.title("Hello Bar")
|
14 |
-
app = MultiApp()
|
15 |
-
app.add_app("Foo", foo)
|
16 |
-
app.add_app("Bar", bar)
|
17 |
-
app.run()
|
18 |
-
It is also possible keep each application in a separate file.
|
19 |
-
import foo
|
20 |
-
import bar
|
21 |
-
app = MultiApp()
|
22 |
-
app.add_app("Foo", foo.app)
|
23 |
-
app.add_app("Bar", bar.app)
|
24 |
-
app.run()
|
25 |
-
"""
|
26 |
-
def __init__(self):
|
27 |
-
self.apps = []
|
28 |
-
|
29 |
-
def add_app(self,title,icon, func):
|
30 |
-
"""Adds a new application.
|
31 |
-
Parameters
|
32 |
-
----------
|
33 |
-
func:
|
34 |
-
the python function to render this app.
|
35 |
-
title:
|
36 |
-
title of the app. Appears in the dropdown in the sidebar.
|
37 |
-
"""
|
38 |
-
self.apps.append({
|
39 |
-
"title": title,
|
40 |
-
"icon": icon,
|
41 |
-
"function": func
|
42 |
-
})
|
43 |
-
|
44 |
-
def run(self):
|
45 |
-
|
46 |
-
st.sidebar.write(format_func=lambda app: app['title'])
|
47 |
-
#image = Image.open('docStore/img/sdsn.png')
|
48 |
-
#st.sidebar.image(image, width =200)
|
49 |
-
|
50 |
-
with st.sidebar:
|
51 |
-
selected = option_menu(None, [page["title"] for page in self.apps],
|
52 |
-
icons=[page["icon"] for page in self.apps],
|
53 |
-
menu_icon="cast", default_index=0)
|
54 |
-
st.markdown("---")
|
55 |
-
|
56 |
-
|
57 |
-
for index, item in enumerate(self.apps):
|
58 |
-
if item["title"] == selected:
|
59 |
-
self.apps[index]["function"]()
|
60 |
-
break
|
61 |
-
|
62 |
-
|
63 |
-
choice = st.sidebar.radio(label = 'Select the Document',
|
64 |
-
help = 'You can upload the document \
|
65 |
-
or else you can try a example document',
|
66 |
-
options = ('Upload Document', 'Try Example'),
|
67 |
-
horizontal = True)
|
68 |
-
add_upload(choice)
|
69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|