Quote:
Originally Posted by poopman
I've build a GUI script and I would like one of the buttons to perform an action that I have defined in the script and also quit the GUI interface. I can only figure out how to assign the button to do one or the other, but not both. Any advice? Thanks! 
|
What GUI system are you using? There are a number of them available for Python, and the answer will depend upon your choice.
Quote:
|
Originally Posted by ptmcg
You could create a class that implements __call__ that takes all of the methods and calls them in turn. Here's a version that returns all of the return values in a list, unless an exception is thrown, in which case None is returned.
|
Uh, that doesn't really sound like the best solution to the problem, as ingenious as it is. Why do you need the return values? Presumably the callback function attached to the button requires no return value, so there's no need for that code. And you might as well keep the exceptions, as if the return value is discarded, you'd want them around if something goes wrong.
If you really want some manner of serial function caller, why not simply:
def multicall(*funcs):
def caller(*args):
for func in funcs: func(*args)
return caller
However, it's probably just easier to create your own function.