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