Tkinter code (with pmw) executing to soon please help

Gabriel Genellina gagsl-py at yahoo.com.ar
Sat Jan 13 23:29:55 EST 2007


<Eric_Dexter at msn.com> escribió en el mensaje 
news:1168746063.322340.10410 at l53g2000cwa.googlegroups.com...

> Instead of creating my buttons and waiting for me to press them to
> execute they are executing when I create them and won't do my callback
> when I press them..  thanks for any help in advance

This is a very frequent beginner's mistake. You are *calling* the event 
handler at the moment you create the buttons. You have to provide a 
*callable* but not call it yet.

> button[num] = Tkinter.Button(frame,text =  returnstring,
> command=callback(returnstring))#

So `callback` should return a function, like this:

def callback(text):
  def handler(event):
    print text

-- 
Gabriel Genellina 






More information about the Python-list mailing list