Matplotlib数字在Tkinter文件对话框后不起作用 [英] Matplotlib figures not working after Tkinter file dialog
问题描述
我正在使用以下功能,该功能是对问题以显示用于选择文件的对话框窗口。
I'm using the following function which I found as a reply to this question to show a dialog window for file selection.
在Fedora 18上:一切正常。
在Ubuntu 12.10上::Matplotlib在关闭文件对话框后显示的任何图形后挂起。例如,在下面的代码中,在Ubuntu上,我永远无法进入 make it行。尽管什么都没发生,但我仍然可以在终端中输入内容。如果我删除文件对话框,则Matplotlib会按预期工作。
On Ubuntu 12.10: Matplotlib hangs after closing any figure displayed after the file dialog. For example, in the code below, on Ubuntu I can never get to the "made it" line. I am still able to type in the terminal, though nothing happens. If I remove the file dialog, Matplotlib figures work as expected.
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."
有什么建议吗?
推荐答案
在对话框功能的末尾,我只需要一个 root.destroy()
!
I just needed a root.destroy()
at the end of the dialog function!
这篇关于Matplotlib数字在Tkinter文件对话框后不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!