![]() |
Can a button perform two actions?
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! :D
|
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.
-- Paul :
class Multicall(object): |
Quote:
Quote:
If you really want some manner of serial function caller, why not simply: :
|
Yeah... ptmcg's response is definitely going overboard. Not to mention, most likely not even applicable under these circumstances
If it were wxWidgets, it would be as simple as this: :
class MyFrame(wxFrame):Unless I grossely misunderstand the concern? ... |
:beard: I guess my OO training from Smalltalk/C++/Java days is still showing, I instinctively jump to writing a class, especially since Python offers such nice built-in class impersonation features, such as classes as numerics (for operator overloading) or classes as callables.
After I posted that last note, it dawned on me that a simple closure (as Arevos so clearly showed) would do just as well. I think I'll revisit pyparsing one of these days and see how much "class overkill" can be winnowed out. Fortunately, I *can* be trained... |
Sorry for the late reply. I am using Tkinter.
|
| All times are GMT -5. The time now is 2:57 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC