-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
53 lines (42 loc) · 1.72 KB
/
app.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
41
42
43
44
45
46
47
48
49
50
51
52
53
import streamlit as st
from streamlit_option_menu import option_menu
from configs.app_config import WEB_NAME, ICON, LAYOUT, LIGHT_THEME_CSS
from configs.pages_config import PAGES_DICT, MENU_ICON
from utils.preprocessing import process_image_body
from web_pages.creation_page import enter_creation_page
from web_pages.intro_page import enter_intro_page
class App:
"""
Set up and execute web application.
Methods:
__init__(): set up the page configuration and prepare background image.
execute(): execute web application, including theme and menu options.
"""
def __init__(self):
"""
Initialize App class: set up page configuration and process background image.
"""
st.set_page_config(page_title=WEB_NAME, page_icon=ICON, layout=LAYOUT)
background_image_body = process_image_body()
st.markdown(background_image_body, unsafe_allow_html=True)
@staticmethod
def execute():
"""
Apply theme and menu options to execute web application.
Also determine which page to display based on selected menu option.
"""
st.markdown(LIGHT_THEME_CSS, unsafe_allow_html=True)
options = [PAGES_DICT["creation"]["name"], PAGES_DICT["intro"]["name"]]
icons = [PAGES_DICT["creation"]["icon"], PAGES_DICT["intro"]["icon"]]
with st.sidebar:
selected_page = option_menu(
"Menu",
options,
menu_icon=MENU_ICON,
icons=icons,
styles="icon",
)
if selected_page == PAGES_DICT["creation"]["name"]:
enter_creation_page()
if selected_page == PAGES_DICT["intro"]["name"]:
enter_intro_page()