Re: [Tkinter] messed callbacks

2009-09-10 Thread Giacomo Boffi
Scott David Daniels scott.dani...@acm.org writes: Giacomo Boffi wrote: Giacomo Boffi giacomo.bo...@polimi.it writes: ... | def create_cb(a,b): | return lambda: output(a+'-'+b) | | def doit(fr,lst): | for c1,c2 in zip(lst[::2], lst[1::2]): | subframe=Frame(fr) |

Re: [Tkinter] messed callbacks

2009-09-10 Thread Giacomo Boffi
John Posner jjpos...@optimum.net writes: def output(x,y,op): if op == : print x, ---, y elif op == : print x, ---, y else: print Operation argument error! uh, nice!, i'll adapt this to my real problem thank you John,

Re: [Tkinter] messed callbacks

2009-09-10 Thread Giacomo Boffi
Terry Reedy tjre...@udel.edu writes: Reedy's Lambda Rule: [detailed explanation omitted] i'm beginning to _understand_ what's going on with my code Terry Jan Reedy thanks, grazie 1000 Terry, g -- Lord, what fools these mortals be! --

[Tkinter] messed callbacks

2009-09-09 Thread Giacomo Boffi
i have this test program (that i already posted on it.comp.lang.python) [ test.py ] from Tkinter import * def output(s): print s def doit(fr,lst): for c1,c2 in zip(lst[::2], lst[1::2]): subframe=Frame(fr) Label(subframe,text=c1+' - '+c2).pack(side='left',expand=1,fill='both')

Re: [Tkinter] messed callbacks

2009-09-09 Thread Diez B. Roggisch
Giacomo Boffi wrote: i have this test program (that i already posted on it.comp.lang.python) [ test.py ] from Tkinter import * def output(s): print s def doit(fr,lst): for c1,c2 in zip(lst[::2], lst[1::2]): subframe=Frame(fr) Label(subframe,text=c1+' -

Re: [Tkinter] messed callbacks

2009-09-09 Thread Giacomo Boffi
Diez B. Roggisch de...@nospam.web.de writes: Giacomo Boffi wrote: def doit(fr,lst): for c1,c2 in zip(lst[::2], lst[1::2]): subframe=Frame(fr) Label(subframe,text=c1+' - '+c2).pack(side='left',expand=1,fill='both') Button(subframe,text='',command=lambda:

Re: [Tkinter] messed callbacks

2009-09-09 Thread Giacomo Boffi
Giacomo Boffi giacomo.bo...@polimi.it writes: ok, i'll try again following your advice ,[ test.py ] | from Tkinter import * | | def output(s): | print s | | def create_cb(a,b): | return lambda: output(a+'-'+b) | | def doit(fr,lst): | for c1,c2 in zip(lst[::2], lst[1::2]): |

Re: [Tkinter] messed callbacks

2009-09-09 Thread Scott David Daniels
Giacomo Boffi wrote: Giacomo Boffi giacomo.bo...@polimi.it writes: ... | def create_cb(a,b): | return lambda: output(a+'-'+b) | | def doit(fr,lst): | for c1,c2 in zip(lst[::2], lst[1::2]): | subframe=Frame(fr) | Label(subframe,text=c1+' -

Re: [Tkinter] messed callbacks

2009-09-09 Thread Terry Reedy
Giacomo Boffi wrote: Diez B. Roggisch de...@nospam.web.de writes: Giacomo Boffi wrote: def doit(fr,lst): for c1,c2 in zip(lst[::2], lst[1::2]): subframe=Frame(fr) Label(subframe,text=c1+' - '+c2).pack(side='left',expand=1,fill='both') Button(subframe,text='',command=lambda:

Re: [Tkinter] messed callbacks

2009-09-09 Thread John Posner
snip def cb12(): return output(c1+'-'+c2) def cb21(): return output(c2+'-'+c1) I think these can be simplified, e.g: def cb12(): output(c1+'-'+c2) But I'd go with the functools.partial approach. You can save some code by making output() do more of the work: