回复: why tkinter do not quit?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

回复: why tkinter do not quit?

luofeiyu
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() ??
 
------------------ 原始邮件 ------------------
发送时间: 2011年8月9日(星期二) 晚上9:50
收件人: "守株待兔"<[hidden email]>;
抄送: "Tkinter-discuss"<[hidden email]>;
主题: 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 守株待兔 <[hidden email]>
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
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss





_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss
Reply | Threaded
Open this post in threaded view
|

Re: 回复: why tkinter do not quit?

Igor Novikov


2011/8/9 守株待兔 <[hidden email]>


what is the difference  between  quit and quit() ??

quit is a reference to callable but quit() is a method call.
The code command = top.quit just passes a callable reference,
but command = top.quit() passes result of top.quit() execution.
Possibly exception could be raised in last case.

--
Regards,

Igor Novikov
sK1 Project
http://sk1project.org



_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss