[Tkinter] messed callbacks

Giacomo Boffi giacomo.boffi at polimi.it
Thu Sep 10 06:05:25 EDT 2009


Scott David Daniels <Scott.Daniels at Acm.Org> writes:

> Giacomo Boffi wrote:
>> Giacomo Boffi <giacomo.boffi at 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+' <-> '+c2).pack(side='left',expand=1,fill='both')
>> |     Button(subframe,text='>',command=create_cb(c1,c2)).pack()
>> |     Button(subframe,text='<',command=create_cb(c2,c1)).pack()
>> |     subframe.pack(fill='x',expand=1)
> ...
>> works ok, now i have to fully understand my previous error
>
> This is really why functools.partial exists.

i take due note, tx

> Also note from Pep 8, spaces are cheap and make the code easier to
> read.

space-crunch was just for posting on usenet, 80 cols terminals etc.

grazie,
                                                                       g
-- 
Sarò un'ingenua ma continuo a pensarla come prima, anche se
probabilmente i fatti mi smentiscono.  -- Francy, in IHC



More information about the Python-list mailing list