From profversaggi at gmail.com Sun Jan 24 23:09:50 2016 From: profversaggi at gmail.com (Matthew Versaggi) Date: Sun, 24 Jan 2016 23:09:50 -0500 Subject: [Pygui] Button Action method raises error in Actions.py: Fn takes 5 args (1 given) Message-ID: Dear PyGUI members, I've run into a showstopper with PyGUI and hope to find a way around it or else I'll have to abandon the framework altogether. I'm *importing *(many) modules into the GUI framework, one of which I invoke via the *action *keyword for a simple button. I do a quick define of a wrapper function in PyGUI and there call my imported module. This module takes *ONE *argument (a string), however the error message I get is that it takes *FIVE *arguments. This is not true and is a bug in the PyGUI system. Here is my traceback: Traceback (most recent call last): File "C:\Anaconda\lib\site-packages\GUI\WinUtils.py", line 93, in OnCommand self._forward_reflected_message(lParam, name) File "C:\Anaconda\lib\site-packages\GUI\WinUtils.py", line 103, in _forward_reflected_message meth(*args) File "C:\Anaconda\lib\site-packages\GUI\Button.py", line 58, in _win_bn_clicked self.do_action() File "C:\Anaconda\lib\site-packages\GUI\*Actions.py*", line* 61*, in do_action self.do_named_action('action') File "C:\Anaconda\lib\site-packages\GUI\*Actions.py*", *line 46*, in do_named_action raise et, et("%s (while doing action %r%r)" % (ev, action, args)), tb TypeError: *function takes exactly 5 arguments (1 given)* For extremely simple functions of my imports, this works fine, but for more complicated ones, this fails. I'm using Anaconda Python 2.7.10 if that helps. This is the PyGUI Function in question, the offending line is in bold.... class ActionBase(object): """Mixin class providing base support for action properties.""" def do_named_action(self, name): #print "ActionBase.do_named_action:", repr(name) ### action = getattr(self, name) #print "...action =", repr(action) ### if action: try: if isinstance(action, tuple): args = action[1:] action = action[0] else: args = () if isinstance(action, str): #print "...handling", action ### self.handle(action, *args) else: action(*args) except ApplicationError: raise except: import sys et, ev, tb = sys.exc_info() *raise et, et("%s (while doing action %r%r)" % (ev, action, args)), tb* I would appreciate any insights into a fix, workaround, alteration, something - this is a showstopper for using this framework if I can't get an imported method to operate. Thanks very much for your time in advance... -matt -- ######################################################### Matthew R. Versaggi, Artificial Intelligence Engineer, Imagine One, LTD President & CEO: Versaggi Information Systems, Inc. Adjunct Professor of eBusiness DePaul University Email: mailto:matt at versaggi.com, ProfVersaggi at gmail.com M: 630-292-8422 LinkedIn: http://www.linkedin.com/in/versaggi About Me: http://www.matt-versaggi.com/resume/ ######################################################### -------------- next part -------------- An HTML attachment was scrubbed... URL: From greg.ewing at canterbury.ac.nz Sun Jan 24 23:42:08 2016 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Mon, 25 Jan 2016 17:42:08 +1300 Subject: [Pygui] Button Action method raises error in Actions.py: Fn takes 5 args (1 given) In-Reply-To: References: Message-ID: <56A5A7A0.4000300@canterbury.ac.nz> Matthew Versaggi wrote: > This > module takes *ONE *argument (a string), however the error message I get > is that it takes *FIVE *arguments. This is not true and is a bug in the > PyGUI system. I think the code in do_named_action that tries to re-raise the exception is getting into trouble and masking the real cause of your problem. Try commenting out the whole "except:" clause in that function, i.e. these four lines: > except: > import sys > et, ev, tb = sys.exc_info() > *raise et, et("%s (while doing action %r%r)" % (ev, action, args)), tb* That should let the original exception propagate and hopefully show you what's really happening. -- Greg