Re: [Tkinter] messed callbacks

2009-09-10 Thread Giacomo Boffi
Terry Reedy 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!" -- http://mail.

Re: [Tkinter] messed callbacks

2009-09-10 Thread Giacomo Boffi
John Posner 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
Scott David Daniels writes: > Giacomo Boffi wrote: >> Giacomo Boffi 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+' <-> >> '+c2).p

Re: [Tkinter] messed callbacks

2009-09-09 Thread John Posner
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: #---

Re: [Tkinter] messed callbacks

2009-09-09 Thread Terry Reedy
Giacomo Boffi wrote: "Diez B. Roggisch" 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: output(c1+'->'

Re: [Tkinter] messed callbacks

2009-09-09 Thread Scott David Daniels
Giacomo Boffi wrote: Giacomo Boffi 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+' <-> '+c2).pack(side='left',expand=1,fill='both') | Button(su

Re: [Tkinter] messed callbacks

2009-09-09 Thread Giacomo Boffi
Giacomo Boffi 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]): | subframe=Frame(fr) |

Re: [Tkinter] messed callbacks

2009-09-09 Thread Giacomo Boffi
"Diez B. Roggisch" 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: output(c1+'->'+c2)

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+' <->

[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')