Skip to content

Commit

Permalink
Merge branch 'recources' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenaH84 committed Feb 16, 2024
2 parents a64358f + a45e19f commit b7be548
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 15 deletions.
18 changes: 15 additions & 3 deletions streamlit/Introduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

st.set_page_config(
page_title="BattMo",
page_icon=Image.open(os.path.join(os.path.dirname(os.path.abspath(__file__)),"images", "battmo_logo.png"))
page_icon=Image.open(os.path.join(os.path.dirname(os.path.abspath(__file__)),"images", "battmo_logo.png")),
#layout="wide"
)

##############################
Expand All @@ -23,18 +24,29 @@
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))

# set config is done before import to avoid streamlit error
from app_scripts.app_controller import set_heading, set_page_navigation, set_external_links
from app_scripts.app_controller import set_heading, set_page_navigation, set_external_links, set_acknowlegent_info
from app_scripts import app_view

def run_app():

#Set Introduction page heading wil title, BattMo logo, and BattMo info.
set_heading()

app_view.st_space(space_width=3)

#Set page navigation
set_page_navigation()
col = set_page_navigation()

#Set external links to websites and documentation
set_external_links()

with st.sidebar:
app_view.st_space(space_width=3)

#Set funding acknowledgement
set_acknowlegent_info(col)



if __name__ == "__main__":
run_app()
3 changes: 3 additions & 0 deletions streamlit/app_scripts/app_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ def set_material_description():
def get_results_data():
return view.GetResultsData()

def set_acknowlegent_info(col):
return view.SetAcknowledgementInfo(col)


#####################################
# Images
Expand Down
65 changes: 53 additions & 12 deletions streamlit/app_scripts/app_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,16 @@ def __init__(self, logo):
devices. It simulates the Current-Voltage response of a battery using
Physics-based models.
"""
self.info = "Hover over the following buttons to see what you can find on each page."

# Set heading
self.set_heading()


def set_heading(self):
self.set_title_and_logo()
self.set_description()
self.set_description()
self.set_info()

def set_title_and_logo(self):
# Title and subtitle
Expand All @@ -92,7 +94,11 @@ def set_title_and_logo(self):

def set_description(self):
# Description
st.text(self.description)
st.write(self.description)

def set_info(self):

st.info(self.info)


class SetPageNavigation:
Expand All @@ -101,33 +107,36 @@ class SetPageNavigation:
"""
def __init__(self):

self.info = "Hover over the following buttons to see what you can find on each page."
self.help_simulation = "Define your input parameters and run a simulation."
self.help_results = "Download and visualize your results."
self.help_materials_and_models = "See which pre-defined materials and which simulation models are available."
self.set_page_navigation()

def set_page_navigation(self):

self.set_info()
self.set_page_buttons()


def set_info(self):
col = self.set_page_buttons()

st.info(self.info)
return col


def set_page_buttons(self):

simulation_page = st.button(label = "Simulation",
_,col1,_ = st.columns([2.95,2,2.5])
st_space(space_width=6)
_,col2,_ = st.columns([3.15,2,2.5])
st_space(space_width=6)
_,col3,col4 = st.columns([2.45,2,2.5])
st_space(space_width=6)

simulation_page = col1.button(label = "Simulation",
help = self.help_simulation
)

results_page = st.button(label = "Results",
results_page = col2.button(label = "Results",
help = self.help_results
)

materials_and_models_page = st.button(label = "Materials and models",
materials_and_models_page = col3.button(label = "Materials and models",
help = self.help_materials_and_models
)

Expand All @@ -140,6 +149,38 @@ def set_page_buttons(self):
if materials_and_models_page:
switch_page("Materials and models")

return col4


class SetAcknowledgementInfo:
"""
Used to render the info on the funding of the project on the 'Introduction' page.
"""
def __init__(self,col):

self.col = col
self.text = "This project has received [funding](https://github.com/BattMoTeam/BattMo#) from the European Union"
self.flag_image = Image.open(os.path.join(app_access.get_path_to_images_dir(), "flag_of_europe.jpg"))

self.set_acknowledgement()

def set_acknowledgement(self):

#col1,col2,col3 = st.columns([1,2,3])
#_,col2 = st.columns([4,1.5])
self.set_europe_flag()
self.set_funding_info()


def set_funding_info(self):

st.write(self.text)

def set_europe_flag(self):

st.image(self.flag_image, width = 90)



class SetExternalLinks:
"""
Expand Down
Binary file added streamlit/images/flag_of_europe.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b7be548

Please sign in to comment.