IsaacKerson commited on
Commit
00cd5ae
1 Parent(s): 8b02b83

add multipage.py

Browse files
Files changed (2) hide show
  1. multipage.py +42 -0
  2. vocabulary_old.db +0 -0
multipage.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ This file is the framework for generating multiple Streamlit applications
3
+ through an object oriented framework.
4
+ """
5
+
6
+ # Import necessary libraries
7
+ import streamlit as st
8
+
9
+ # Define the multipage class to manage the multiple apps in our program
10
+ class MultiPage:
11
+ """Framework for combining multiple streamlit applications."""
12
+
13
+ def __init__(self) -> None:
14
+ """Constructor class to generate a list which will store all our applications as an instance variable."""
15
+ self.pages = []
16
+
17
+ def add_page(self, title, func) -> None:
18
+ """Class Method to Add pages to the project
19
+
20
+ Args:
21
+ title ([str]): The title of page which we are adding to the list of apps
22
+
23
+ func: Python function to render this page in Streamlit
24
+ """
25
+
26
+ self.pages.append(
27
+ {
28
+ "title": title,
29
+ "function": func
30
+ }
31
+ )
32
+
33
+ def run(self):
34
+ # Drodown to select the page to run
35
+ page = st.sidebar.selectbox(
36
+ 'App Navigation',
37
+ self.pages,
38
+ format_func=lambda page: page['title']
39
+ )
40
+
41
+ # run the app function
42
+ page['function']()
vocabulary_old.db DELETED
Binary file (49.2 kB)