Hello there i am using streamlit and ifcopenshell to create an app that processes IFC models. I hit a wall in the initial build up of this app. I am trying to output a text box and an apply button however when i run the code these entities don't appear. I would appreciate some direction in the code.
import streamlit as st
import ifcopenshell
def callback_upload():
st.session_state["is_file_upload"] = True
st.session_state["ifc_file"] = ifcopenshell.file.from_string(st.session_state["uploaded_file"].getvalue().decode("utf-8"))
def main():
st.set_page_config(
layout= "wide",
page_title="IFC Stream",
page_icon="✍️",
)
st.title("StreamLite IFC")
st.markdown(
"""
### click on the browse file to begin
"""
)
uploaded_file = st.sidebar.file_uploader("choose a file", key="uploaded_file",on_change= callback_upload)
if "is_file_uploaded" in st.session_state and st.session_state["is_file_uploaded"]:
st.sidebar.success("file is loaded!")
st.sidebar.write("you may now reload a new file")
col1, col2 = st.columns (2)
with col1:
project_name = st.session_state["ifc_file"].by_type("IfcProject")[0].Name
st.write(project_name)
with col2:
st.text_input("✍️", key="project_name_input")
st.button("Apply", key="project_name_apply")
if __name__ == "__main__":
main()
I quickly tried to re-run your code, and there is a typo in "is_file_uploaded
":
def callback_upload():
st.session_state["is_file_uploaded"] = True
st.session_state["ifc_file"] = ifcopenshell.file.from_string(st.session_state["uploaded_file"].getvalue().decode("utf-8"))
However, as I did not manage to install a compatible version of ifcopenshell
, I was not able to fully test (I don't get the apply
button). I have another error afterwards but hopefully you won't have it.