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

2010-10-19 Thread thea_t
Very clever! Thanks! Mick O'Donnell wrote: > > Much simpler, and closer to the original posters intention. > Replace your up_and_down function with: > > def up_and_down(*buttons): > > for i in range(len(buttons)-1): > buttons[i].bind("", lambda e, x=buttons[i+1]: x.focus_set()) > > f

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

2010-10-19 Thread Michael Lange
Thus spoketh "Michael O'Donnell" unto us on Tue, 19 Oct 2010 21:43:57 +0200: > Much simpler, and closer to the original posters intention. > Replace your up_and_down function with: > > def up_and_down(*buttons): > > for i in range(len(buttons)-1): > buttons[i].bind("", lambda e, x=button

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

2010-10-19 Thread Michael O'Donnell
Much simpler, and closer to the original posters intention. Replace your up_and_down function with: def up_and_down(*buttons): for i in range(len(buttons)-1): buttons[i].bind("", lambda e, x=buttons[i+1]: x.focus_set()) for i in range(1, len(buttons)): buttons[i].bind("", lambda e, x

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

2010-10-19 Thread thea_t
Thank you guys! I know what's wrong now! :) Michael Lange wrote: > > Hi, > > Thus spoketh Firat Ozgul > unto us on Tue, 19 Oct 2010 13:19:03 +0300: > >> Hello, >> >> 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 t

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

2010-10-19 Thread Michael Lange
Hi, Thus spoketh Firat Ozgul unto us on Tue, 19 Oct 2010 13:19:03 +0300: > Hello, > > 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

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

2010-10-19 Thread Firat Ozgul
Hello, 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: http://paste-it.net/public/pe0b871/

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

2010-10-18 Thread thea_t
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.nabbl