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@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to