问题描述
我正在使用以下代码片段打开文件选择器对话框.它可以很好地打开对话框,但是在选择文件后,对话框在我其余代码的执行期间保持打开状态,即 3-4 分钟.我认为 root.destroy()
会像关闭其他 Tkinter 窗口一样关闭打开的文件对话框,但似乎并非如此.
I'm using the following code snippet to open a file chooser dialog box. It opens up the dialog fine, but after a file is chosen the dialog box stays open for the duration of the execution of the rest of my code, which is 3-4 min. I thought root.destroy()
would close the open file dialog like it closes other Tkinter windows but that doesn't seem to be the case.
from tkinter import *
from tkinter.filedialog import askopenfilename
root = Tk()
root.withdraw()
file_path = askopenfilename()
root.destroy()
在选择文件后如何关闭打开文件对话框?我在 OSX 10.10 上使用 3.4.3 版
How would I go about getting the open file dialog to close after the file is chosen? I'm using version 3.4.3 on OSX 10.10
推荐答案
为了结束这个问题,这里是答案:
For the sake of closing this question, here is the answer:
在askopenfilename()
这篇关于Tkinter askopenfilename() 不会关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!