Spaces:
Running
Running
Create new file
Browse files- apps/multiapp.py +50 -0
apps/multiapp.py
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import streamlit as st
|
3 |
+
from PIL import Image
|
4 |
+
import tempfile
|
5 |
+
import logging
|
6 |
+
logger = logging.getLogger(__name__)
|
7 |
+
|
8 |
+
# Initialization
|
9 |
+
if 'file' not in st.session_state:
|
10 |
+
st.session_state['pipeline'] = None
|
11 |
+
|
12 |
+
|
13 |
+
class MultiApp:
|
14 |
+
"""
|
15 |
+
Framework for combining multiple streamlit applications.
|
16 |
+
"""
|
17 |
+
def __init__(self):
|
18 |
+
self.apps = []
|
19 |
+
#if 'file' not in st.session_state:
|
20 |
+
# st.session_state['file'] = None
|
21 |
+
|
22 |
+
def add_app(self, title, func):
|
23 |
+
"""Adds a new application.
|
24 |
+
Parameters
|
25 |
+
----------
|
26 |
+
func:
|
27 |
+
the python function to render this app.
|
28 |
+
title:
|
29 |
+
title of the app. Appears in the dropdown in the sidebar.
|
30 |
+
"""
|
31 |
+
self.apps.append({
|
32 |
+
"title": title,
|
33 |
+
# "icon": icon,
|
34 |
+
"function": func
|
35 |
+
})
|
36 |
+
|
37 |
+
def run(self):
|
38 |
+
|
39 |
+
st.sidebar.write(format_func=lambda app: app['title'])
|
40 |
+
#image = Image.open('appStore/img/sdsn.png')
|
41 |
+
#st.sidebar.image(image)
|
42 |
+
st.sidebar.markdown("## 📌 Pages ")
|
43 |
+
app = st.sidebar.radio(
|
44 |
+
'Pages',
|
45 |
+
self.apps,
|
46 |
+
format_func=lambda app: app['title'])
|
47 |
+
app['function']()
|
48 |
+
st.sidebar.markdown('')
|
49 |
+
|
50 |
+
|