View Single Post
Old Feb 19th, 2007, 3:35 PM   #3
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Quote:
Originally Posted by poopman View Post
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:
python Syntax (Toggle Plain Text)
  1. def multicall(*funcs):
  2. def caller(*args):
  3. for func in funcs: func(*args)
  4. return caller
However, it's probably just easier to create your own function.
Arevos is offline   Reply With Quote