[tkinter] Event from menu event?

kiki kiki at pixar.com
Tue May 25 14:17:41 EDT 1999


John Michelsen wrote:

> How about:
>
> for each_class in draw_class_name:
>     mymenu.add_command(label = each_class, command = lambda v=each_class:
> myfunc(v))
>
> I came across the following lambda statement in PIL's thresholder.py:
> im = self.image.point(lambda v,t=self.value: v>=t, "1")
> and wondered why you couldn't simply put:
> im = self.image.point(lambda v: v>=self.value, "1")
> But you do need to put the default argument in the lambda statement.
>
> John

Great!  That worked too.  A lot cleaner too.  Thanx!

Python being an interpreted language has got me giddy with bad coding
practice, and I've been over-using the fun but entirely too dangerous compile,
eval, and exec commands! weee! :-)

Kiki





More information about the Python-list mailing list