Python 如何在不丢失序列的情况下关闭matplotlib图形?
我有一节课。在与按钮连接的方法之一中,可以查看保存在外部文件中的2条曲线Python 如何在不丢失序列的情况下关闭matplotlib图形?,python,matplotlib,tkinter,Python,Matplotlib,Tkinter,我有一节课。在与按钮连接的方法之一中,可以查看保存在外部文件中的2条曲线 self.btnView = tk.Button(master, text="View", width = 10, height =2, fg = "blue",command=self.ViewCurve) 方法如下: def ViewCurve(self): .... fig, axs = plt.subplots(2,figsize=(8,6)) .... plt.show()
self.btnView = tk.Button(master, text="View", width = 10, height =2, fg = "blue",command=self.ViewCurve)
方法如下:
def ViewCurve(self):
....
fig, axs = plt.subplots(2,figsize=(8,6))
....
plt.show()
plt.close(fig)
print("end method")
我的问题很简单。这个数字出现了,但是当我手动关闭它时(窗口右上方有x),代码不会打印最后一个字符串“end method”。好像我打断了这个序列。
另一件有趣的事情是:当我用命令大师关闭GUI时。退出,我可以看到字符串。
我怎样才能解决它
提前谢谢