refactor: Replace file browser selector with system file manager approach
This commit is contained in:
parent
67bfc5c103
commit
1662c3d2dd
@ -3,7 +3,6 @@ import os
|
||||
import logging
|
||||
import warnings
|
||||
import shutil
|
||||
from streamlit_file_browser_selector import st_file_browser_selector
|
||||
from io import BytesIO
|
||||
import tempfile
|
||||
import zipfile
|
||||
@ -191,15 +190,16 @@ with col1:
|
||||
col_src1, col_src2 = st.columns([1, 4])
|
||||
with col_src1:
|
||||
if st.button("Browse", key='source_browse'):
|
||||
selected_path = st_file_browser_selector(
|
||||
path=source_dir or os.path.expanduser("~"),
|
||||
key="source_selector",
|
||||
folder_only=True
|
||||
)
|
||||
if selected_path:
|
||||
st.session_state['source_dir'] = selected_path
|
||||
st.session_state['source_dir_input'] = selected_path
|
||||
st.experimental_rerun()
|
||||
try:
|
||||
import subprocess
|
||||
result = subprocess.run(
|
||||
['xdg-open', os.path.expanduser("~")],
|
||||
capture_output=True,
|
||||
text=True
|
||||
)
|
||||
st.info("Please copy the desired directory path and paste it in the text field above")
|
||||
except Exception as e:
|
||||
st.error(f"Error opening file manager: {str(e)}")
|
||||
|
||||
# Add a check and display for source directory status
|
||||
if source_dir:
|
||||
@ -217,15 +217,16 @@ with col1:
|
||||
col_dest1, col_dest2 = st.columns([1, 4])
|
||||
with col_dest1:
|
||||
if st.button("Browse", key='dest_browse'):
|
||||
selected_path = st_file_browser_selector(
|
||||
path=dest_dir or os.path.expanduser("~"),
|
||||
key="dest_selector",
|
||||
folder_only=True
|
||||
)
|
||||
if selected_path:
|
||||
st.session_state['dest_dir'] = selected_path
|
||||
st.session_state['dest_dir_input'] = selected_path
|
||||
st.experimental_rerun()
|
||||
try:
|
||||
import subprocess
|
||||
result = subprocess.run(
|
||||
['xdg-open', os.path.expanduser("~")],
|
||||
capture_output=True,
|
||||
text=True
|
||||
)
|
||||
st.info("Please copy the desired directory path and paste it in the text field above")
|
||||
except Exception as e:
|
||||
st.error(f"Error opening file manager: {str(e)}")
|
||||
|
||||
# Add a check and display for destination directory status
|
||||
if dest_dir:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user