fix: Resolve nonlocal variable error in directory selection
This commit is contained in:
parent
034cb8059d
commit
fc3feba657
@ -215,14 +215,14 @@ with col1:
|
|||||||
root.wm_attributes('-topmost', 1)
|
root.wm_attributes('-topmost', 1)
|
||||||
root.after(10) # Add a small delay
|
root.after(10) # Add a small delay
|
||||||
# Create and run the main loop in a way that doesn't block
|
# Create and run the main loop in a way that doesn't block
|
||||||
path = None
|
path_holder = []
|
||||||
def select_dir():
|
def select_dir():
|
||||||
nonlocal path
|
|
||||||
path = filedialog.askdirectory(title="Select Source Directory")
|
path = filedialog.askdirectory(title="Select Source Directory")
|
||||||
|
path_holder.append(path)
|
||||||
root.quit()
|
root.quit()
|
||||||
root.after(20, select_dir)
|
root.after(20, select_dir)
|
||||||
root.mainloop()
|
root.mainloop()
|
||||||
if path:
|
if path_holder and path_holder[0]:
|
||||||
st.session_state['source_dir_selected'] = path
|
st.session_state['source_dir_selected'] = path
|
||||||
st.rerun()
|
st.rerun()
|
||||||
root.destroy()
|
root.destroy()
|
||||||
@ -272,14 +272,14 @@ with col1:
|
|||||||
root.wm_attributes('-topmost', 1)
|
root.wm_attributes('-topmost', 1)
|
||||||
root.after(10) # Add a small delay
|
root.after(10) # Add a small delay
|
||||||
# Create and run the main loop in a way that doesn't block
|
# Create and run the main loop in a way that doesn't block
|
||||||
path = None
|
path_holder = []
|
||||||
def select_dir():
|
def select_dir():
|
||||||
nonlocal path
|
|
||||||
path = filedialog.askdirectory(title="Select Destination Directory")
|
path = filedialog.askdirectory(title="Select Destination Directory")
|
||||||
|
path_holder.append(path)
|
||||||
root.quit()
|
root.quit()
|
||||||
root.after(20, select_dir)
|
root.after(20, select_dir)
|
||||||
root.mainloop()
|
root.mainloop()
|
||||||
if path:
|
if path_holder and path_holder[0]:
|
||||||
st.session_state['dest_dir_selected'] = path
|
st.session_state['dest_dir_selected'] = path
|
||||||
st.rerun()
|
st.rerun()
|
||||||
root.destroy()
|
root.destroy()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user