Mike Steiner wrote:
> Does this work - does the "command=" parameter allow the function
> value to contain parameters too? If so, it would solve the problem
> easily!
>
> --- Martin Franklin <[EMAIL PROTECTED]> wrote:
>> [ stuff omitted ]
>> for text, external, filename in my_buttons:
>> b = Button(self, text=text, command=self.launchit(external,
>> filename))
>> b.grid()
>
Mike,
Sorry I should have provided some doc strings ;) The magic in my
example is here:-
## this function is called when you create the Button widget
def launchit(external, filename):
external_short = os.path.split()[1]
## this inner function has access to the outer functions
## namespace
def real_launchit():
os.spawnl(os.P_NOWAIT, external, external_short, filename)
## return a reference to the inner function
## this 'reference to a function' will be called when the button
## is pressed
return real_launchit
on re-reading the example I noticed I had made a couple of typoes
Cheers
Martin
_______________________________________________
Tkinter-discuss mailing list
[email protected]
http://mail.python.org/mailman/listinfo/tkinter-discuss