refactor: Improve directory processing UI with session state and rerun
This commit is contained in:
parent
79b2bb0835
commit
6b5c851a00
@ -207,29 +207,31 @@ if uploaded_files:
|
||||
mime="application/zip",
|
||||
)
|
||||
|
||||
else: # Directory Processing
|
||||
else: # Directory Processing
|
||||
st.header("Directory Processing")
|
||||
|
||||
col1, col2 = st.columns(2)
|
||||
|
||||
with col1:
|
||||
source_dir = st.text_input("Source Directory Path",
|
||||
help="Enter the full path to the directory containing files to process")
|
||||
help="Enter the full path to the directory containing files to process",
|
||||
value=st.session_state.get('source_dir', ''))
|
||||
source_browse = st.button("Browse Source Directory")
|
||||
if source_browse:
|
||||
path = get_directory_path("Select Source Directory")
|
||||
if path:
|
||||
source_dir = path
|
||||
st.session_state['source_dir'] = path # Persist the selection
|
||||
st.session_state['source_dir'] = path
|
||||
st.experimental_rerun()
|
||||
|
||||
dest_dir = st.text_input("Destination Directory Path",
|
||||
help="Enter the full path where processed files will be saved")
|
||||
help="Enter the full path where processed files will be saved",
|
||||
value=st.session_state.get('dest_dir', ''))
|
||||
dest_browse = st.button("Browse Destination Directory")
|
||||
if dest_browse:
|
||||
path = get_directory_path("Select Destination Directory")
|
||||
if path:
|
||||
dest_dir = path
|
||||
st.session_state['dest_dir'] = path # Persist the selection
|
||||
st.session_state['dest_dir'] = path
|
||||
st.experimental_rerun()
|
||||
|
||||
with col2:
|
||||
if file_type == "Excel":
|
||||
@ -241,7 +243,8 @@ if uploaded_files:
|
||||
passwords = []
|
||||
if password_option == "Password File":
|
||||
password_path = st.text_input("Password File Path",
|
||||
help="Enter the full path to the text file containing passwords")
|
||||
help="Enter the full path to the text file containing passwords",
|
||||
value=st.session_state.get('password_path', ''))
|
||||
password_browse = st.button("Browse Password File")
|
||||
if password_browse:
|
||||
try:
|
||||
@ -254,8 +257,8 @@ if uploaded_files:
|
||||
filetypes=[("Text Files", "*.txt")]
|
||||
)
|
||||
if file_path:
|
||||
password_path = file_path
|
||||
st.session_state['password_path'] = file_path
|
||||
st.experimental_rerun()
|
||||
except Exception as e:
|
||||
st.error(f"Error opening file dialog: {str(e)}")
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user