我正在使用以下函数作为对this question的回复,以显示文件选择的对话窗口 .
[编辑:这里的发行版差异只是因为Matplotlib在Fedora和TkAgg上使用gtk3agg在每个系统上绘制窗口]
On Fedora 18: 一切正常 .
On Ubuntu 12.10: Matplotlib在关闭文件对话框后显示的任何数字后挂起 . 例如,在下面的代码中,在Ubuntu上,我永远无法访问"made it"行 . 我仍然可以输入终端,但没有任何反应 . 如果我删除文件对话框,Matplotlib数字按预期工作 .
import Tkinter, tkFileDialog
import pylab
def ask_for_config_file():
print "Please provide location of configuration file."
root = Tkinter.Tk()
root.withdraw()
file_path = tkFileDialog.askopenfilename()
return file_path
def main():
config_file_path = ask_for_config_file()
pylab.figure()
pylab.show()
print "Made it."
有什么建议?
1 回答
我只需要在对话框功能结束时使用
root.destroy()
!