From fc3feba657572ea3b5a4ada087bf8dc1b45d58ab Mon Sep 17 00:00:00 2001 From: "Bobby Abellana (aider)" Date: Tue, 11 Feb 2025 16:21:13 -0800 Subject: [PATCH] fix: Resolve nonlocal variable error in directory selection --- src/streamlit_app.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/streamlit_app.py b/src/streamlit_app.py index d00f7f0..18b289a 100644 --- a/src/streamlit_app.py +++ b/src/streamlit_app.py @@ -215,14 +215,14 @@ with col1: root.wm_attributes('-topmost', 1) root.after(10) # Add a small delay # Create and run the main loop in a way that doesn't block - path = None + path_holder = [] def select_dir(): - nonlocal path path = filedialog.askdirectory(title="Select Source Directory") + path_holder.append(path) root.quit() root.after(20, select_dir) root.mainloop() - if path: + if path_holder and path_holder[0]: st.session_state['source_dir_selected'] = path st.rerun() root.destroy() @@ -272,14 +272,14 @@ with col1: root.wm_attributes('-topmost', 1) root.after(10) # Add a small delay # Create and run the main loop in a way that doesn't block - path = None + path_holder = [] def select_dir(): - nonlocal path path = filedialog.askdirectory(title="Select Destination Directory") + path_holder.append(path) root.quit() root.after(20, select_dir) root.mainloop() - if path: + if path_holder and path_holder[0]: st.session_state['dest_dir_selected'] = path st.rerun() root.destroy()