Hi community,
So I was trying to create two buttons, one takes pdf and the other for OCR. So when I tried using columns, this happened, but the UI for the same doesn’t seem cool when you click one button the dropdown isn’t working for me(might not be for you as well), also it doesn’t close itself after the file gets selected.
Any fixes?
import streamlit as st
from streamlit_extras.stylable_container import stylable_container
st.markdown(
'<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css"/>',
unsafe_allow_html=True,
)
columns = st.columns((1,5,1,5))
with columns[0]:
if "clicked" not in st.session_state:
st.session_state.clicked = False
def set_clicked():
st.session_state.clicked = True
st.button("📎", on_click=set_clicked)
if st.session_state.clicked:
allowed_types = ["pdf", "xlsx", "docx", "doc", "txt"]
attachment_selected = st.file_uploader("Upload a file", type=allowed_types)
with columns[2]:
if "clickedpdf" not in st.session_state:
st.session_state.clickedpdf = False
def set_clicked():
st.session_state.clickedpdf = True
with stylable_container(
key="container_with_border",
css_styles=r"""
button div:before {
font-family: 'Font Awesome 5 Free';
content: '\f1c1';
display: inline-block;
padding-right: 3px;
vertical-align: middle;
font-weight: 900;
}
""",
):
st.button("", on_click=set_clicked, use_container_width=True)
if st.session_state.clickedpdf:
allowed_types = ["pdf"]
pdf_selected = st.file_uploader("Upload a file", type=allowed_types)