[Tkinter-discuss] Can't do proper event binding in a for loop

Firat Ozgul ozgulfirat at gmail.com
Tue Oct 19 12:19:03 CEST 2010


for loop doesn't work, because in a for loop all events will be bound all at
once, and you will only see the effect of the last binding. You need
something that binds events one by one.

If I were you, I would use the next() method of Python iterators:



2010/10/19 thea_t <siatogia at yahoo.com>

> Hi everyone,
> I've been writing a long GUI in Python using Tkinter. One thing that I
> don't
> understand is why I can't bind events to widgets in a loop. In the code
> below, binding works well if I do it manually (commented out code) but not
> in a for loop. Am I doing something wrong?
> http://old.nabble.com/file/p29995174/events.py events.py
> --
> View this message in context:
> http://old.nabble.com/Can%27t-do-proper-event-binding-in-a-for-loop-tp29995174p29995174.html
> Sent from the Python - tkinter-discuss mailing list archive at Nabble.com.
> _______________________________________________
> 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/20101019/fff98fbd/attachment.html>

More information about the Tkinter-discuss mailing list