policy_test / appStore /multiapp.py
peter2000's picture
Update appStore/multiapp.py
eea1b81
raw
history blame
1.39 kB
"""Frameworks for running multiple Streamlit applications as a single app.
"""
import streamlit as st
from PIL import Image
# Initialization
if 'file' not in st.session_state:
st.session_state['file'] = None
class MultiApp:
"""
Framework for combining multiple streamlit applications.
"""
def __init__(self):
self.apps = []
def add_app(self, title, func):
"""Adds a new application.
Parameters
----------
func:
the python function to render this app.
title:
title of the app. Appears in the dropdown in the sidebar.
"""
self.apps.append({
"title": title,
# "icon": icon,
"function": func
})
def run(self):
if 'file' not in st.session_state:
st.session_state['file'] = None
st.sidebar.write(format_func=lambda app: app['title'])
image = Image.open('appStore/img/sdsn.png')
st.sidebar.image(image)
app = st.sidebar.radio(
'Pages',
self.apps,
format_func=lambda app: app['title'])
app['function']()
st.sidebar.markdown('')
st.sidebar.markdown("## πŸ“Œ Upload document ")
file = st.sidebar.file_uploader('', type=['pdf', 'docx', 'txt']) #Upload PDF File
st.session_state['file'] = file