10
我正在使用以下代码片段来打开文件选择器对话框。它打开对话框正常,但是在选择一个文件后,对话框在我的代码执行期间保持打开,这段时间为3-4分钟。我认为root.destroy()
会关闭打开的文件对话框,就像关闭其他Tkinter窗口一样,但似乎并非如此。Tkinter askopenfilename()将不会关闭
from tkinter import *
from tkinter.filedialog import askopenfilename
root = Tk()
root.withdraw()
file_path = askopenfilename()
root.destroy()
我该如何去选择文件后打开文件对话框关闭?我使用的版本3.4.3 OSX 10.10
工作正常
root.update()
前askopenfilename()
,Python 2.7版 – VRage忘记根窗户,想要回来? 'root.withdraw()'你失去根窗口不能回头! – dsgdfg
@SDilmac'root.deiconify()'把它带回 – maccartm