On Wed, 23 Mar 2016 20:34:08 -0400, Dennis Lee Bieber wrote: > On Wed, 23 Mar 2016 10:58:09 -0500, Wildman via Python-list > <python-list@python.org> declaimed the following: > >>On Wed, 23 Mar 2016 02:47:47 -0400, Terry Reedy wrote: >> >>> def load_image(self, _): >>> # load image file >>> >>> You must pass the bound method, as you did, and not the function itself >>> (which has two parameters). >> >>I meant to ask a followup question in my previous post but >>it slipped my mind. >> >>What is the best thing to do... >>Define all procedures this way, (self. event)? > > Not "." but "," -- separate arguments
That was a typo. My fingers have dyslexia. > Anything that is a method in a class object will tend to receive the > object itself as the first argument (commonly called "self" in Python, "me" > in Visual BASIC, "this" in C++). Tk callback functions (I think you were > using Tkinter) likely pass the event data (that is, what triggered the > callback -- a key-in callback passes information about the key that was > pressed). > >>Define all event handlers this way? > > If they are methods of a Tk class, then likely they need this format... > But for classes you create yourself, it depends on how you intend to invoke > them. Thanks for the info. >>Define only the event handlers that will be called from >>elsewhere in the code, as in this case? > > Uhm... If an event handler is never invoked, why write it? I was referring to procedures called by a button click as opposed to a procedure calledd from elsewhere in the code. I guess there is no difference. I assume that is what you meant. -- <Wildman> GNU/Linux user #557453 The cow died so I don't need your bull! -- https://mail.python.org/mailman/listinfo/python-list