feat: Implement shared network directory browsing for cross-platform compatibility
This commit is contained in:
parent
61b139fcb9
commit
a2a33c2a69
@ -17,6 +17,30 @@ from main import (
|
|||||||
setup_logging
|
setup_logging
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def get_shared_path(title="Select Path"):
|
||||||
|
"""Get path from shared network location"""
|
||||||
|
try:
|
||||||
|
# Define the base shared directory - modify this to match your network share
|
||||||
|
base_dir = "/mnt/shared" # or wherever your Windows shares are mounted
|
||||||
|
|
||||||
|
# List available directories
|
||||||
|
available_dirs = [d for d in os.listdir(base_dir)
|
||||||
|
if os.path.isdir(os.path.join(base_dir, d))]
|
||||||
|
|
||||||
|
# Create a selection widget
|
||||||
|
selected_dir = st.selectbox(
|
||||||
|
f"{title} (Select shared folder)",
|
||||||
|
options=available_dirs,
|
||||||
|
key=f"select_{title.lower().replace(' ', '_')}"
|
||||||
|
)
|
||||||
|
|
||||||
|
if selected_dir:
|
||||||
|
full_path = os.path.join(base_dir, selected_dir)
|
||||||
|
return full_path
|
||||||
|
except Exception as e:
|
||||||
|
st.error(f"Error accessing shared directories: {str(e)}")
|
||||||
|
return None
|
||||||
|
|
||||||
def select_directory_with_dialog(title="Select Directory"):
|
def select_directory_with_dialog(title="Select Directory"):
|
||||||
"""Use dialog command to select directory in terminal environment"""
|
"""Use dialog command to select directory in terminal environment"""
|
||||||
try:
|
try:
|
||||||
@ -190,14 +214,11 @@ 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'):
|
||||||
st.info("""
|
shared_path = get_shared_path("Source Directory")
|
||||||
To browse for a directory:
|
if shared_path:
|
||||||
1. Open Windows File Explorer
|
st.session_state['source_dir'] = shared_path
|
||||||
2. Navigate to your desired folder
|
st.session_state['source_dir_input'] = shared_path
|
||||||
3. Click in the address bar (or press Alt+D)
|
st.experimental_rerun()
|
||||||
4. Copy the full path (Ctrl+C)
|
|
||||||
5. Paste it here (Ctrl+V)
|
|
||||||
""")
|
|
||||||
|
|
||||||
# Add a check and display for source directory status
|
# Add a check and display for source directory status
|
||||||
if source_dir:
|
if source_dir:
|
||||||
@ -218,14 +239,11 @@ 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'):
|
||||||
st.info("""
|
shared_path = get_shared_path("Destination Directory")
|
||||||
To browse for a directory:
|
if shared_path:
|
||||||
1. Open Windows File Explorer
|
st.session_state['dest_dir'] = shared_path
|
||||||
2. Navigate to your desired folder
|
st.session_state['dest_dir_input'] = shared_path
|
||||||
3. Click in the address bar (or press Alt+D)
|
st.experimental_rerun()
|
||||||
4. Copy the full path (Ctrl+C)
|
|
||||||
5. Paste it here (Ctrl+V)
|
|
||||||
""")
|
|
||||||
|
|
||||||
# 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