-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutils.py
More file actions
26 lines (22 loc) · 679 Bytes
/
Copy pathutils.py
File metadata and controls
26 lines (22 loc) · 679 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
import base64
import streamlit as st
def set_background(image_file):
"""
This function sets the background of a Streamlit app to an image specified by the given image file.
Parameters:
image_file (str): The path to the image file to be used as the background.
Returns:
None
"""
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.markdown(style, unsafe_allow_html=True)