Spaces:
Sleeping
Sleeping
Commit
·
40fa5b9
1
Parent(s):
5a94297
Add logo
Browse files- app.py → 1_Input.py +9 -2
- media/gravity_logo.png +0 -0
- pages/1_Input.py +0 -3
- pages/2_Validate.py +16 -0
- scripts/utils.py +46 -0
app.py → 1_Input.py
RENAMED
@@ -16,9 +16,16 @@ import seaborn as sns
|
|
16 |
|
17 |
# Path manipulation
|
18 |
from pathlib import Path
|
|
|
|
|
19 |
|
20 |
-
# Custom imports
|
21 |
import project_config
|
|
|
|
|
|
|
|
|
22 |
|
23 |
# Page title
|
24 |
-
st.title("
|
|
|
|
16 |
|
17 |
# Path manipulation
|
18 |
from pathlib import Path
|
19 |
+
import sys
|
20 |
+
sys.path.append('./scripts')
|
21 |
|
22 |
+
# Custom and other imports
|
23 |
import project_config
|
24 |
+
from utils import add_logo
|
25 |
+
|
26 |
+
# Insert logo
|
27 |
+
add_logo(project_config.MEDIA_DIR / 'gravity_logo.png')
|
28 |
|
29 |
# Page title
|
30 |
+
st.title("Input")
|
31 |
+
|
media/gravity_logo.png
ADDED
![]() |
pages/1_Input.py
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
|
3 |
-
st.title("Input")
|
|
|
|
|
|
|
|
pages/2_Validate.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
# Path manipulation
|
4 |
+
from pathlib import Path
|
5 |
+
import sys
|
6 |
+
sys.path.append('..')
|
7 |
+
sys.path.append('scripts')
|
8 |
+
|
9 |
+
# Custom and other imports
|
10 |
+
import project_config
|
11 |
+
from utils import add_logo
|
12 |
+
|
13 |
+
# Insert logo
|
14 |
+
add_logo(project_config.MEDIA_DIR / 'gravity_logo.png')
|
15 |
+
|
16 |
+
st.title("Validate")
|
scripts/utils.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import base64
|
2 |
+
import streamlit as st
|
3 |
+
|
4 |
+
# From https://stackoverflow.com/questions/73251012/put-logo-and-title-above-on-top-of-page-navigation-in-sidebar-of-streamlit-multi
|
5 |
+
# See also https://arnaudmiribel.github.io/streamlit-extras/extras/app_logo/
|
6 |
+
@st.cache_data()
|
7 |
+
def get_base64_of_bin_file(png_file):
|
8 |
+
with open(png_file, "rb") as f:
|
9 |
+
data = f.read()
|
10 |
+
return base64.b64encode(data).decode()
|
11 |
+
|
12 |
+
def build_markup_for_logo(
|
13 |
+
png_file,
|
14 |
+
background_position="50% 10%",
|
15 |
+
margin_top="10%",
|
16 |
+
padding="20px",
|
17 |
+
image_width="80%",
|
18 |
+
image_height="",
|
19 |
+
):
|
20 |
+
binary_string = get_base64_of_bin_file(png_file)
|
21 |
+
return """
|
22 |
+
<style>
|
23 |
+
[data-testid="stSidebarNav"] {
|
24 |
+
background-image: url("data:image/png;base64,%s");
|
25 |
+
background-repeat: no-repeat;
|
26 |
+
background-position: %s;
|
27 |
+
margin-top: %s;
|
28 |
+
padding: %s;
|
29 |
+
background-size: %s %s;
|
30 |
+
}
|
31 |
+
</style>
|
32 |
+
""" % (
|
33 |
+
binary_string,
|
34 |
+
background_position,
|
35 |
+
margin_top,
|
36 |
+
padding,
|
37 |
+
image_width,
|
38 |
+
image_height,
|
39 |
+
)
|
40 |
+
|
41 |
+
def add_logo(png_file):
|
42 |
+
logo_markup = build_markup_for_logo(png_file)
|
43 |
+
st.markdown(
|
44 |
+
logo_markup,
|
45 |
+
unsafe_allow_html=True,
|
46 |
+
)
|