refactor: Replace Linux-specific directory selection with cross-platform tkinter dialog
This commit is contained in:
parent
47f4287470
commit
800ae3b262
@ -168,25 +168,13 @@ with col1:
|
|||||||
key='source_dir_input',
|
key='source_dir_input',
|
||||||
help="Enter the full path to the directory containing files to process")
|
help="Enter the full path to the directory containing files to process")
|
||||||
|
|
||||||
if st.button("Select Source Directory", key='source_browse'):
|
if st.button("Browse Source Directory", key='source_browse'):
|
||||||
try:
|
try:
|
||||||
import subprocess
|
|
||||||
if platform.system() == "Linux":
|
|
||||||
result = subprocess.run(
|
|
||||||
['zenity', '--file-selection', '--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()
|
|
||||||
else: # Windows or MacOS
|
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
from tkinter import filedialog
|
from tkinter import filedialog
|
||||||
root = tk.Tk()
|
root = tk.Tk()
|
||||||
root.withdraw()
|
root.withdraw()
|
||||||
|
root.wm_attributes('-topmost', 1)
|
||||||
path = filedialog.askdirectory(title="Select Source Directory")
|
path = filedialog.askdirectory(title="Select Source Directory")
|
||||||
if path:
|
if path:
|
||||||
st.session_state['source_dir'] = path
|
st.session_state['source_dir'] = path
|
||||||
@ -202,25 +190,13 @@ with col1:
|
|||||||
key='dest_dir_input',
|
key='dest_dir_input',
|
||||||
help="Enter the full path where processed files will be saved")
|
help="Enter the full path where processed files will be saved")
|
||||||
|
|
||||||
if st.button("Select Destination Directory", key='dest_browse'):
|
if st.button("Browse Destination Directory", key='dest_browse'):
|
||||||
try:
|
try:
|
||||||
import subprocess
|
|
||||||
if platform.system() == "Linux":
|
|
||||||
result = subprocess.run(
|
|
||||||
['zenity', '--file-selection', '--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()
|
|
||||||
else: # Windows or MacOS
|
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
from tkinter import filedialog
|
from tkinter import filedialog
|
||||||
root = tk.Tk()
|
root = tk.Tk()
|
||||||
root.withdraw()
|
root.withdraw()
|
||||||
|
root.wm_attributes('-topmost', 1)
|
||||||
path = filedialog.askdirectory(title="Select Destination Directory")
|
path = filedialog.askdirectory(title="Select Destination Directory")
|
||||||
if path:
|
if path:
|
||||||
st.session_state['dest_dir'] = path
|
st.session_state['dest_dir'] = path
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user