> 
> the easiest way to do this is to create a new function object for each
> file, and use default argument binding to pass in the right filename:
> 
>     for file in self.allfiles:
>         def callback(fname=file):
>             self.showFile(fname, parent)
>         self.showfilemenu_bar.addmenuitem('Show Files',
>             'command',label=file, command=callback)
> 
> the "def" statement creates a new instance of the callback function for
> each iteration.  the "fname" variable is bound to the current file object,
> while "self" and "parent" are bound to the variables with the same names
> in the outer scope.
> 
> </F>
> 

That was exactly what I was looking for.  It worked perfectly. Thanks.

John

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to