gpt4 book ai didi

python - Tkinter 文件对话框后 Matplotlib 图形不工作

转载 作者:行者123 更新时间:2023-11-28 16:42:34 24 4
gpt4 key购买 nike

我正在使用我发现的以下功能作为对 this question 的回复显示用于文件选择的对话框窗口。

[编辑:事实证明这里的发行版差异仅仅是因为 Matplotlib 在 Fedora 上使用 gtk3agg,在每个系统上使用 TkAgg 绘制窗口]

在 Fedora 18 上:一切正常。

在 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."

有什么建议吗?

最佳答案

我只需要在对话函数的末尾有一个 root.destroy()!

关于python - Tkinter 文件对话框后 Matplotlib 图形不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17435360/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com