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] Tkinter vs Tk strangness

2010-10-19 Thread Michael Lange
Hi, Thus spoketh daniel.sc...@srnl.doe.gov unto us on Tue, 19 Oct 2010 15:48:09 -0400: > I've tested Python2.7 and it exhibits the same problems so it must not > ship with a new enough version of Tcl either. As far as I see, Python2.7 still comes with Tk8.5.2 . > > What are my options? If I'

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] Tkinter vs Tk strangness

2010-10-19 Thread Daniel . Schep
I've tested Python2.7 and it exhibits the same problems so it must not ship with a new enough version of Tcl either. What are my options? If I'm not mistaken I can't just swap the version of Tcl used by Python, but building Python from source (on windows) seems like a headache. Is it possible t

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] Tkinter vs Tk strangness

2010-10-19 Thread Michael Lange
Hi, Thus spoketh daniel.sc...@srnl.doe.gov unto us on Mon, 18 Oct 2010 15:57:48 -0400: > I wanted to do this instead of using the Tcl from ActiveState but > couldn't find a tclsh or wish executable in Python's Tcl install. How > would I run code using Python's Tcl distribution? > I don't use w

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/