[Tutor] Tkinter entry box text changed event

Phil phil_lor at bigpond.com
Mon Apr 10 05:18:39 EDT 2017


On Mon, 10 Apr 2017 09:31:10 +0200
Peter Otten <__peter__ at web.de> wrote:

>     entry.bind("<FocusOut>", bye)

Thank you Peter and Alan,

I had tried key-press but that caused the error message shown bellow which made me think that I was not on the correct track. So in desperation, after hours of frustration, I tried StringVar() because I'd seen that in a Stack overflow answer.

Adapting Peter's example I have:

self.numbers[i].bind("<FocusOut>", self.my_method)

def my_method(self.event):
    print("method called")

(self.event) is a syntax error and if I leave off "self", this is the result:

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python3.4/tkinter/__init__.py", line 1536, in __call__
    return self.func(*args)
TypeError: my_method() takes 1 positional argument but 2 were given

I must be close, surely.

-- 
Regards,
Phil


More information about the Tutor mailing list