feat: Add macOS directory selection support via AppleScript
This commit is contained in:
parent
70e3af157e
commit
caf7844972
@ -173,6 +173,21 @@ with col1:
|
|||||||
with col_src1:
|
with col_src1:
|
||||||
if st.button("Browse", key='source_browse'):
|
if st.button("Browse", key='source_browse'):
|
||||||
try:
|
try:
|
||||||
|
if platform.system() == "Darwin": # macOS
|
||||||
|
try:
|
||||||
|
result = subprocess.run(
|
||||||
|
['osascript', '-e', 'choose folder with prompt "Select Source Directory"'],
|
||||||
|
capture_output=True,
|
||||||
|
text=True
|
||||||
|
)
|
||||||
|
if result.returncode == 0:
|
||||||
|
path = result.stdout.strip()
|
||||||
|
st.session_state['source_dir'] = path
|
||||||
|
st.session_state['source_dir_input'] = path
|
||||||
|
st.experimental_rerun()
|
||||||
|
except Exception as e:
|
||||||
|
st.error(f"Error using AppleScript: {str(e)}")
|
||||||
|
else: # Windows or Linux
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
from tkinter import filedialog
|
from tkinter import filedialog
|
||||||
root = tk.Tk()
|
root = tk.Tk()
|
||||||
@ -204,6 +219,21 @@ with col1:
|
|||||||
with col_dest1:
|
with col_dest1:
|
||||||
if st.button("Browse", key='dest_browse'):
|
if st.button("Browse", key='dest_browse'):
|
||||||
try:
|
try:
|
||||||
|
if platform.system() == "Darwin": # macOS
|
||||||
|
try:
|
||||||
|
result = subprocess.run(
|
||||||
|
['osascript', '-e', 'choose folder with prompt "Select Destination Directory"'],
|
||||||
|
capture_output=True,
|
||||||
|
text=True
|
||||||
|
)
|
||||||
|
if result.returncode == 0:
|
||||||
|
path = result.stdout.strip()
|
||||||
|
st.session_state['dest_dir'] = path
|
||||||
|
st.session_state['dest_dir_input'] = path
|
||||||
|
st.experimental_rerun()
|
||||||
|
except Exception as e:
|
||||||
|
st.error(f"Error using AppleScript: {str(e)}")
|
||||||
|
else: # Windows or Linux
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
from tkinter import filedialog
|
from tkinter import filedialog
|
||||||
root = tk.Tk()
|
root = tk.Tk()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user