refactor: Improve directory processing UI with session state and rerun
This commit is contained in:
parent
79b2bb0835
commit
6b5c851a00
@ -214,22 +214,24 @@ if uploaded_files:
|
|||||||
|
|
||||||
with col1:
|
with col1:
|
||||||
source_dir = st.text_input("Source Directory Path",
|
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")
|
source_browse = st.button("Browse Source Directory")
|
||||||
if source_browse:
|
if source_browse:
|
||||||
path = get_directory_path("Select Source Directory")
|
path = get_directory_path("Select Source Directory")
|
||||||
if path:
|
if path:
|
||||||
source_dir = path
|
st.session_state['source_dir'] = path
|
||||||
st.session_state['source_dir'] = path # Persist the selection
|
st.experimental_rerun()
|
||||||
|
|
||||||
dest_dir = st.text_input("Destination Directory Path",
|
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")
|
dest_browse = st.button("Browse Destination Directory")
|
||||||
if dest_browse:
|
if dest_browse:
|
||||||
path = get_directory_path("Select Destination Directory")
|
path = get_directory_path("Select Destination Directory")
|
||||||
if path:
|
if path:
|
||||||
dest_dir = path
|
st.session_state['dest_dir'] = path
|
||||||
st.session_state['dest_dir'] = path # Persist the selection
|
st.experimental_rerun()
|
||||||
|
|
||||||
with col2:
|
with col2:
|
||||||
if file_type == "Excel":
|
if file_type == "Excel":
|
||||||
@ -241,7 +243,8 @@ if uploaded_files:
|
|||||||
passwords = []
|
passwords = []
|
||||||
if password_option == "Password File":
|
if password_option == "Password File":
|
||||||
password_path = st.text_input("Password File Path",
|
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")
|
password_browse = st.button("Browse Password File")
|
||||||
if password_browse:
|
if password_browse:
|
||||||
try:
|
try:
|
||||||
@ -254,8 +257,8 @@ if uploaded_files:
|
|||||||
filetypes=[("Text Files", "*.txt")]
|
filetypes=[("Text Files", "*.txt")]
|
||||||
)
|
)
|
||||||
if file_path:
|
if file_path:
|
||||||
password_path = file_path
|
|
||||||
st.session_state['password_path'] = file_path
|
st.session_state['password_path'] = file_path
|
||||||
|
st.experimental_rerun()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
st.error(f"Error opening file dialog: {str(e)}")
|
st.error(f"Error opening file dialog: {str(e)}")
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user