fix: Resolve nonlocal variable error in directory selection

This commit is contained in:
Bobby Abellana (aider) 2025-02-11 16:21:13 -08:00
parent 034cb8059d
commit fc3feba657

View File

@ -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()