Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #105578

Re: Key Binding Problem

From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Newsgroups comp.lang.python
Subject Re: Key Binding Problem
Date 2016-03-23 20:34 -0400
Organization IISS Elusive Unicorn
Message-ID <mailman.74.1458780091.2244.python-list@python.org> (permalink)
References <o6ydncSeoNfrnm_LnZ2dnUU7-IfNnZ2d@giganews.com> <mailman.27.1458702187.2244.python-list@python.org> <L6KdnXoY773thm_LnZ2dnUU7-QOdnZ2d@giganews.com> <mailman.31.1458715678.2244.python-list@python.org> <GZ-dnUtlpauMIG_LnZ2dnUU7-S-dnZ2d@giganews.com>

Show all headers | View raw


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

	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/

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Key Binding Problem Wildman <best_lay@yahoo.com> - 2016-03-22 21:46 -0500
  Re: Key Binding Problem MRAB <python@mrabarnett.plus.com> - 2016-03-23 03:02 +0000
    Re: Key Binding Problem Wildman <best_lay@yahoo.com> - 2016-03-22 23:28 -0500
      Re: Key Binding Problem Terry Reedy <tjreedy@udel.edu> - 2016-03-23 02:47 -0400
        Re: Key Binding Problem Wildman <best_lay@yahoo.com> - 2016-03-23 10:40 -0500
        Re: Key Binding Problem Wildman <best_lay@yahoo.com> - 2016-03-23 10:58 -0500
          Re: Key Binding Problem Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-03-23 20:34 -0400
            Re: Key Binding Problem Wildman <best_lay@yahoo.com> - 2016-03-23 21:17 -0500
              Re: Key Binding Problem Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-03-24 08:06 -0400
                Re: Key Binding Problem Wildman <best_lay@yahoo.com> - 2016-03-24 11:19 -0500
                Re: Key Binding Problem Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-03-24 21:43 -0400
                Re: Key Binding Problem Wildman <best_lay@yahoo.com> - 2016-03-24 23:37 -0500
                Re: Key Binding Problem Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-03-25 12:50 -0400
  Re: Key Binding Problem Terry Reedy <tjreedy@udel.edu> - 2016-03-22 23:52 -0400
    Re: Key Binding Problem Wildman <best_lay@yahoo.com> - 2016-03-22 23:30 -0500

csiph-web