我正在开发一个显示matplotlib图形的Tkinter。我使用变量'window‘初始化Tk解释器;而不是'root’/ 'main‘= Tk()。GUI是由类MyWindow格式化的。
class MyWindow:
def __init__(self, win):三个GUI‘可视’按钮显示matplotlib图形。mpl图形的功能在一个名为“图表”的模块中。在下面的示例中,“概述”是一个可视按钮。
self.btn5=Button(win, text='Overview')
self.b5=Button(win, text='Overview', width='6', height='2', command=self.overview)
self.b5.place(x=50, y=160)
def overview(self):
from charts import overview
overview()“退出”按钮退出可视窗口和GUI本身。退出按钮代码:
self.btn6=Button(win, text='Quit')
self.b6=Button(win, text='Quit', width='6', height='2', command=window.quit)
self.b6.place(x=50, y=230)
def quit(self):
self.win.destroy()所有功能都按预期工作,除非“退出”按钮。我必须按“退出”次数与GUI打开的窗口数相同。
,即启动GUI并打开“概述”可视化;我需要单击“退出”两次以关闭“概述”和GUI本身。
我已经尝试过将退出按钮‘命令’和退出函数调整为带前缀self、win和window (而没有前缀)的‘ve()/ quit()的所有组合。
发布于 2020-07-17 19:10:44
尝试使用名为Python的内置函数quit(),它将退出程序,终止其进程。
def quit(self):
quit()https://stackoverflow.com/questions/62960388
复制相似问题