当前位置: 首页 > news >正文

做商城网站/软文网站大全

做商城网站,软文网站大全,12345汽车网址大全,3d网络游戏前十名在jupyter和pycharm中均会出现此问题。 问题的具体描述:按钮功能为,点击按钮关闭窗口。当调用父类(或继承的类)中的quit方法传递给command,会出现按钮按下,但窗口未关闭,程序无响应。 问题的具…

=======================================================================

在jupyter和pycharm中均会出现此问题。

问题的具体描述:按钮功能为,点击按钮关闭窗口。当调用父类(或继承的类)中的quit方法传递给command,会出现按钮按下,但窗口未关闭,程序无响应。

问题的具体原因还不清楚。

解决方法
  使用sys库中的exit方法来进行关闭窗口的操作,无异常发生。

下面是例子:

=======================================================================

from tkinter import *def greeting():print('Hello stdout world!...')win = Frame()
win.pack(side=TOP, expand=YES, fill=BOTH)
Button(win, text='Hello', command=greeting).pack(side=LEFT, fill=Y)
Label(win,  text='Hello container world').pack(side=TOP)
Button(win, text='Quit', command=win.quit).pack(side=RIGHT, expand=YES,fill=X)win.mainloop()

代码描述:

按下Hello按钮将触发此文件中定义的greeting函数,该函数将再次打印到stdout。

按下退出按钮调用由win从Frame类(Frame)继承的标准tkinter退出方法。退出与Tk具有相同的效果。退出我们之前使用的)。

修改后正常程序正常关闭。

from tkinter import *
from tkinter_test.gui6 import Hello
from sys import exitclass HelloContainer(Frame):def __init__(self,parent=None):Frame.__init__(self,parent)self.pack()self.makeWidgets()def makeWidgets(self):Hello(self).pack(side=RIGHT)Button(self,text='Attach',command=exit).pack(side=LEFT)if __name__ == '__main__':HelloContainer().mainloop()

从sys导入exit
将command=win.quit修改为command=exit

相关文章:

  • 深圳做商城网站/链友咨询