[Tkinter-discuss] 回复: why tkinter do not quit?
守株待兔
1248283536 at qq.com
Tue Aug 9 16:00:46 CEST 2011
it's so strage for me to understand
code1
import Tkinter
top=Tkinter.Tk()
button=Tkinter.Button(top,text = 'Hello Button',command = top.quit)
button.pack()
top.mainloop()
code1 can run ,when you click button ,it will quit
code2
import Tkinter
top=Tkinter.Tk()
button=Tkinter.Button(top,text = 'Hello Button',command = top.quit())
button.pack()
top.mainloop()
code2 can run too ,but when you click button,it will not quit.
what is the difference between quit and quit() ??
------------------ 原始邮件 ------------------
发件人: "Igor Novikov"<igor.e.novikov at gmail.com>;
发送时间: 2011年8月9日(星期二) 晚上9:50
收件人: "守株待兔"<1248283536 at qq.com>;
抄送: "Tkinter-discuss"<Tkinter-discuss at python.org>;
主题: Re: [Tkinter-discuss] why tkinter do not quit?
Hi,
root.quit is a reference to object field but not a quit() method.
Try using root.quit() This should resolve an issue.
--
Regards,
Igor Novikov
sK1 Project
http://sk1project.org
2011/8/9 守株待兔 <1248283536 at qq.com>
here is my program:
from Tkinter import *
def helloButton():
print 'hello button'
root.quit
root = Tk()
Button(root,text = 'Hello Button',command = helloButton).pack()
root.mainloop()
when i click on my button,print is ok,why root.quit have no effect?
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss at python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20110809/1e056b1d/attachment.html>
More information about the Tkinter-discuss
mailing list