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


Groups > comp.lang.python > #105510

Re: Key Binding Problem

From Wildman <best_lay@yahoo.com>
Subject Re: Key Binding Problem
Newsgroups comp.lang.python
References <o6ydncSeoNfrnm_LnZ2dnUU7-IfNnZ2d@giganews.com> <mailman.27.1458702187.2244.python-list@python.org>
Organization Wildman Productions
Message-ID <L6KdnXoY773thm_LnZ2dnUU7-QOdnZ2d@giganews.com> (permalink)
Date 2016-03-22 23:28 -0500

Show all headers | View raw


On Wed, 23 Mar 2016 03:02:51 +0000, MRAB wrote:

> On 2016-03-23 02:46, Wildman via Python-list wrote:
>> My question is how do I coax bind into executing the
>> button procedures?  Or is there a way to generate the
>> button click event from the binding?
>>
> It won't let you bind to a function called "load_image" because there 
> isn't a function called "load_image"!
> 
> The "Window" class, however, does have a method with that name.
> 
> Try binding the keys in Window.__init__ or Window.init_window:
> 
>      def init_window(self):
>          ...
>          root.bind("<l>", self.load_image)

Here is what I tried:

class Window(tk.Frame):

    def __init__(self, master = None):
        tk.Frame.__init__(self,master)
        self.master = master
        root.bind("l", self.load_image)

I get this error and it doesn't make any sense to me:

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1535, in __call__
    return self.func(*args)
TypeError: load_image() takes exactly 1 argument (2 given)

-- 
<Wildman> GNU/Linux user #557453
The cow died so I don't need your bull!

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