Hello,
I am currently working on building an app to process data. Essentially, the user uploads some data, selects a processing option (currently, there is only the AMA option), enters specific parameters, and then initiates the processing. To achieve this, I used the ‘st.sidebar.number_input’ option to gather the user’s inputs for the processing function. However, I encountered an issue: when I input the first parameter value, the program does not wait for the second parameter input. The sidebar closes prematurely, and the program does not execute.
My function ‘f_AMA’ requires the data and parameters dx and dy to run. The intention is for the function to run after clicking the ‘Run’ button.
Any assistance is greatly appreciated. Below is my code. Thank you.
import streamlit as st
from proc_AMA import func_AMA as f_AMA
st.set_page_config(layout='wide',page_title="TEST")
def main():
st.title("TITLE")
st.subheader("SUBHEADER")
data = data_load()
if st.button("AMA",type="secondary",key="AMA_bt"):
dx,dy = get_input_AMA()
if st.button("Run",type="primary",key="RUN_bt"):
if data != None and dx != None and dy != None:
f_AMA(data,dx,dy)
else:
st.write("Upload the file, input dx and dy parameters !!!")
def data_load():
uploaded_file = st.file_uploader("Choose a file")
return uploaded_file
def get_input_AMA():
st.sidebar.header("Configuration")
dx = st.sidebar.number_input("dx",key="dx_box",value=None,)
dy = st.sidebar.number_input("dy",key="dy_box",value=None)
return dx,dy
if __name__ == "__main__":
main()