守株待兔 | 9 Aug 15:18 2011

why tkinter do not quit?

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
Igor Novikov | 9 Aug 15:50 2011
Picon

Re: 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




_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
守株待兔 | 9 Aug 16:00 2011

回复: why tkinter do not quit?

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




_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
Igor Novikov | 9 Aug 16:20 2011
Picon

Re: 回复: why tkinter do not quit?



2011/8/9 守株待兔 <1248283536 <at> qq.com>


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
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
守株待兔 | 10 Aug 05:14 2011

回复: 回复: why tkinter do not quit?

i am sitll confused,please  see the following

>>> def  abc():
...   print  "i am abc"
...   return  "i am not abc"
...
>>> abc
<function abc at 0xb780d17c>
>>> abc()
i am abc
'i am not abc'
>>>
code1

import Tkinter
def  abc():
  print  "i am abc"
  return  "i am not abc" 
top=Tkinter.Tk()
button=Tkinter.Button(top,text = 'Hello Button',command =abc)
button.pack()
top.mainloop()

when you click button ,the output is :
i am abc
my question is :where is the "i am not abc"??

code2
import Tkinter
def  abc():
  print  "i am abc"
  return  "i am not abc" 
top=Tkinter.Tk()
button=Tkinter.Button(top,text = 'Hello Button',command =abc())
button.pack()
top.mainloop()

when code2 run ,there is output  "i am abc",(where is "i am not abc")?

when you click button ,there is no reaction, why?



 
------------------ 原始邮件 ------------------
发件人: "Igor Novikov"<igor.e.novikov <at> gmail.com>;
发送时间: 2011年8月9日(星期二) 晚上10:20
收件人: "守株待兔"<1248283536 <at> qq.com>;
抄送: "Tkinter-discuss"<Tkinter-discuss <at> python.org>;
主题: Re: 回复: [Tkinter-discuss] why tkinter do not quit?
 


2011/8/9 守株待兔 <1248283536 <at> qq.com>


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
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
Kevin Walzer | 10 Aug 06:10 2011

Re: »Ø¸´£º »Ø¸´£º why tkinter do not quit?

On 8/9/11 11:14 PM, ÊØÖê´ýÍÃ wrote:
> when code2 run ,there is output  "i am abc",(where is "i am not abc")?

print "i am abc"

displays the string "i am abc" in standard output.

return "i am not abc"

is the return value of the function--it is not displayed. You'd have to 
use the "print" command for that.

--

-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
Bob van der Poel | 10 Aug 18:13 2011
Picon

Re: 回复: 回复: why tkinter do not quit?

2011/8/9 守株待兔 <1248283536 <at> qq.com>:
> i am sitll confused,please  see the following
>>>> def  abc():
> ...   print  "i am abc"
> ...   return  "i am not abc"
> ...
>>>> abc
> <function abc at 0xb780d17c>
>>>> abc()
> i am abc
> 'i am not abc'
>>>>
> code1
>
> import Tkinter
> def  abc():
>   print  "i am abc"
>   return  "i am not abc"
> top=Tkinter.Tk()
> button=Tkinter.Button(top,text = 'Hello Button',command =abc)
> button.pack()
> top.mainloop()
>
> when you click button ,the output is :
> i am abc
> my question is :where is the "i am not abc"??

When a function is called as a callback there is no return value. If
you want a value from a callback you need to have the callback save it
"somewhere".

> code2
> import Tkinter
> def  abc():
>   print  "i am abc"
>   return  "i am not abc"
> top=Tkinter.Tk()
> button=Tkinter.Button(top,text = 'Hello Button',command =abc())
> button.pack()
> top.mainloop()
>
> when code2 run ,there is output  "i am abc",(where is "i am not abc")?
>
> when you click button ,there is no reaction, why?
>
>
>
>
> ------------------ 原始邮件 ------------------
> 发件人: "Igor Novikov"<igor.e.novikov <at> gmail.com>;
> 发送时间: 2011年8月9日(星期二) 晚上10:20
> 收件人: "守株待兔"<1248283536 <at> qq.com>;
> 抄送: "Tkinter-discuss"<Tkinter-discuss <at> python.org>;
> 主题: Re: 回复: [Tkinter-discuss] why tkinter do not quit?
>
>
> 2011/8/9 守株待兔 <1248283536 <at> qq.com>
>>
>>
>> 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
> Tkinter-discuss <at> python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss
>
>

--

-- 
**** Listen to my CD at http://www.mellowood.ca/music/cedars ****
Bob van der Poel ** Wynndel, British Columbia, CANADA **
EMAIL: bob <at> mellowood.ca
WWW:   http://www.mellowood.ca
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
Alan Gauld | 12 Aug 01:56 2011

Re: 回复: 回复: why tkinter do not quit?

On 10/08/11 04:14, 守株待兔 wrote:
> i am sitll confused,please see the following
>  >>> def abc():
> ... print "i am abc"
> ... return "i am not abc"
> ...
>  >>> abc
> <function abc at 0xb780d17c>
>  >>> abc()
> i am abc
> 'i am not abc'

The first line is the print statement in the function.
The second line is the return value of the function. The interpreter 
always displays the value of any expression you type

Wen you run the function in the script the return value is not 
displayed, and since Tkinter does not store the return value of an 
action it just gets lost.

> when you click button ,the output is :
> i am abc
> my question is :where is the "i am not abc"??

Lost in the garbage inside Tkinter.

> button=Tkinter.Button(top,text = 'Hello Button',command =abc())
> button.pack()
> top.mainloop()
>
> when code2 run ,there is output "i am abc",(where is "i am not abc")?
>
> when you click button ,there is no reaction, why?

The parentheses after abc() say to Python to execute the function.
So you have assigned the return value of your function to the button's 
command. So the command stores 'i am not abc' - a string.
But the button cannot execute the string so when you click it nothing 
happens.

HTH,
--

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
守株待兔 | 12 Aug 15:32 2011

pixels and plot

in my computer ,xrandr:
Screen 0: minimum 320 x 200, current 1280 x 800, maximum 8192 x 8192
i want to konw how can   matplotlab  draw  (x,y)  which has  2000  pairs or more  (x,y)  data??

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
守株待兔 | 17 Aug 04:41 2011

bind between event and callback

code1
from Tkinter import *
root = Tk()
def callback(event):
    print "i am here"
   
frame = Frame(root, width=100, height=100)
frame.bind("<Return>", callback)
frame.pack()
root.mainloop()

when  i press  "enter",there is no output  "i am here"
code2
from Tkinter import *
root = Tk()
def callback(event):
    print "i am here"
   
frame = Frame(root, width=100, height=100)
frame.bind("<Key>", callback)
frame.pack()
root.mainloop()

when  i press  any key ,there is no output  "i am here"

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Gmane