More Tkinter menu problems

John Michelsen john.michelsen at gte.net
Wed Jun 2 23:52:27 EDT 1999


>  self.menu.add_command(label = new_name,
>   command = lambda temp_color = new_color:
>   self.select_color(temp_color))
>
>but I get a Name Error on "self".  So now "self" is out of scope when
>the menu call happens.


try:
self.menu.add_command(label = new_name,
    command = lambda c=new_color, f=self.select_color: f(c))

John






More information about the Python-list mailing list