File size: 2,106 Bytes
35ca880 | 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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | import base64
import streamlit as st
def get_base64(bin_file):
with open(bin_file, 'rb') as f:
data = f.read()
return base64.b64encode(data).decode()
def add_logo(width, padding, margin):
padding_top, padding_right, padding_bottom, padding_left = padding
margin_top, margin_right, margin_bottom, margin_left = margin
bin_str = get_base64('images/logo1.png')
link = 'https://www.lifepulse.ai'
html_code = f'''
<a href="{link}" target = _blank>
<img src="data:image/png;base64,{bin_str}"
style="
margin: auto;
width: {width}%;
margin-top: {margin_top}px;
margin-right: {margin_right}px;
margin-bottom: {margin_bottom}px;
margin-left: {margin_left}%;
padding-top: {padding_top}px;
padding-right: {padding_right}px;
padding-bottom: {padding_bottom}px;
padding-left: {padding_left}%;
"/>
</a>
'''
return html_code
def new_line(n=1):
for i in range(n):
st.write("\n")
def local_css(file_name):
with open(file_name) as f:
st.markdown(f'<style>{f.read()}</style>', unsafe_allow_html=True)
def remote_css(url):
st.markdown(f'<link href="{url}" rel="stylesheet">', unsafe_allow_html=True)
def add_header(png_file):
bin_str = get_base64(png_file)
page_bg_img = f'''
<style>
.header {{
background: url("data:image/png;base64,{bin_str}");
background-size: cover; /* Adjust as needed */
background-repeat: no-repeat; /* Adjust as needed */
background-position: center center; /* Adjust as needed */
text-align: center;
max-width: 100%;
position: relative;
padding: 3.5rem 0 0.5rem;
margin: 0 0 1rem;
color: #FFF;
z-index: 999999999;
}}
</style>
'''
st.markdown(page_bg_img, unsafe_allow_html=True) |