Hi, @blackary , should I insert this inside the function def paper_input() or after the imports/ somewhere else?
Here is my code snippet of the page:
import streamlit as st,pandas as pd,os, math
import streamlit_ext as ste
from streamlit_extras.switch_page_button import switch_page
from streamlit_extras.add_vertical_space import add_vertical_space
st.markdown(st.session_state.style, unsafe_allow_html=True)
st.write('<style>div.block-container{padding-top:2rem;}</style>', unsafe_allow_html=True)
st.markdown(st.session_state.paddingstyle, unsafe_allow_html=True)
#Add Logo
st.markdown(
f"""
<style>
[data-testid="stSidebarNav"] {{
background-image: url({"https://www.metamorfoze.nl/themes/custom/metamorfoze/static/images/logo_m.png"});
background-repeat: no-repeat;
padding-top: 150px;
background-position: 20px 20px;
}}
</style>
""",
unsafe_allow_html=True,
)
#user input
def paper_input():
list_pH,list_intdp=[],[]
original_title = '<p style="font-family:Sans serif; font-size: 30px;"><b>Collection Objects Details</b></p>'
st.markdown(original_title, unsafe_allow_html=True)
col1, col2, col3, col4 = st.columns(4)
with col1:
objectno = ste.number_input("Enter number of type of objects",1,4,key='noofobjecttype')
for counter in range (objectno):
if(objectno>1):
st.markdown("#### Type {} Object Chemical Properties".format(counter+1))
colc, cold = st.columns(2)
with colc:
pH = ste.slider("Select pH level",min_value=3,max_value=9,value=8,step=1,key='ph{}'.format(counter+2))
with cold:
int_dp = ste.slider("Select Initial DP",min_value=500,max_value=2500,value=1200,step=50,key='dp{}'.format(counter+2))
if isinstance(pH, tuple):
pH = pH[0]
if isinstance(int_dp, tuple):
int_dp = int_dp[0]
list_pH.append(pH)
list_intdp.append(int_dp)
else:
st.markdown("#### Object Chemical Properties")
cola, colb = st.columns(2)
with cola:
pH = ste.slider("Select pH level",min_value=3,max_value=9,value=8,step=1,key='ph1')
with colb:
int_dp = ste.slider("Select Initial DP",min_value=500,max_value=2500,value=1200,step=50,key='dp1')
if isinstance(pH, tuple):
pH = pH[0]
if isinstance(int_dp, tuple):
int_dp = int_dp[0]
list_pH.append(pH)
list_intdp.append(int_dp)
add_vertical_space(3)
original_title = '<p style="font-family:Sans serif; font-size: 30px;"><b>Critical DP of Collection</b></p>'
st.markdown(original_title, unsafe_allow_html=True)
col10, col11, col12 = st.columns(3)
with col10:
crit_dp = ste.slider("Select Critical DP",min_value=200,max_value=400,step=50,key='critdp')
if isinstance(crit_dp, tuple):
crit_dp = crit_dp[0]
add_vertical_space(5)
col1, col2, col3, col4, col5 = st.columns(5)
with col1:
prev_page = st.button("Previous Page<Weather Data")
with col3:
save_button = st.button("Save Inputs")
with col5:
next_page = st.button("Next Page>Repository Sizing")
if prev_page:
switch_page("Weather Data")
if save_button:
valuelist = [objectno,list_pH,list_intdp,crit_dp]
columnlist = ['Number of object types', 'List of pH Values', 'List of Initial DP Values', 'Critical DP']
#Current working directory
cwd = os.getcwd()
#set path to subdirectory and inputfilename
inputfilesnamewithpath = cwd+'\\Inputfiles\\PaperUserInputs.csv'
#Write the inputs to a csv file
inputdf = pd.DataFrame([valuelist], columns = columnlist)
inputdf.to_csv(inputfilesnamewithpath, index=False)
if next_page:
switch_page("Repository Sizing")
paper_input()