-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.py
More file actions
33 lines (30 loc) · 1015 Bytes
/
util.py
File metadata and controls
33 lines (30 loc) · 1015 Bytes
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
import base64
import streamlit as st
def set_background(image_file):
with open(image_file, "rb") as f:
img_data = f.read()
b64_encoded = base64.b64encode(img_data).decode()
style = f"""
<style>
.stApp {{
background: rgba(255, 255, 255, 0); /* Adjust the last value for transparency */
background-image: url(data:image/png;base64,{b64_encoded});
background-size: cover;
background-blend-mode: lighten; /* Adjust blend mode as needed */
}}
</style>
"""
st.markdown(style, unsafe_allow_html=True)
def set_sidebar_background(image_file):
with open(image_file, "rb") as f:
img_data = f.read()
b64_encoded = base64.b64encode(img_data).decode()
style = f"""
<style>
.stApp {{
background-image: url(data:image/png;base64,{b64_encoded});
background-size: cover;
}}
</style>
"""
st.sidebar.markdown(style, unsafe_allow_html=True)