Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Dennis Lee Bieber Newsgroups: comp.lang.python Subject: Re: Key Binding Problem Date: Wed, 23 Mar 2016 20:34:08 -0400 Organization: IISS Elusive Unicorn Lines: 40 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de n9eSVq8kL/WtpZO/zG655gPot9d34SNSJQ62E4K1lYoA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'handler': 0.04; 'method,': 0.07; 'callback': 0.09; 'handlers': 0.09; 'message-id:@4ax.com': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'def': 0.13; 'wed,': 0.15; 'argument': 0.15; '","': 0.16; '"."': 0.16; '2016': 0.16; '>on': 0.16; 'did,': 0.16; 'invoked,': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'reedy': 0.16; 'subject:Problem': 0.16; 'wrote:': 0.16; 'passes': 0.18; 'url:home': 0.18; 'load': 0.20; 'meant': 0.22; 'arguments': 0.22; 'class,': 0.22; 'mind.': 0.22; 'pass': 0.22; 'code,': 0.23; '(which': 0.26; 'header:X-Complaints- To:1': 0.26; 'separate': 0.27; 'question': 0.27; 'tend': 0.27; 'function': 0.28; '-0500,': 0.29; 'invoke': 0.29; 'way?': 0.29; 'classes': 0.30; 'post': 0.31; 'class': 0.33; 'file': 0.34; 'previous': 0.34; 'but': 0.36; 'depends': 0.36; 'visual': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'method': 0.37; 'received:org': 0.37; 'charset:us-ascii': 0.37; 'itself': 0.38; 'anything': 0.38; 'why': 0.39; 'data': 0.39; 'to:addr:python.org': 0.40; 'called': 0.40; '(that': 0.63; 'information': 0.63; 'mar': 0.65; 'python-list': 0.66; 'receive': 0.71; 'yourself,': 0.72; 'case?': 0.84; 'dennis': 0.91; 'slipped': 0.91; 'received:108': 0.93 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: adsl-108-73-117-233.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:105578 On Wed, 23 Mar 2016 10:58:09 -0500, Wildman via Python-list 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 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. >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? -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/