Mysterious tkinter bug: tk.Button doesn't think it passed event <1>

MRAB python at mrabarnett.plus.com
Thu Jul 2 19:42:01 EDT 2015


On 2015-07-02 23:33, Ben Elam wrote:
> I've stripped things down to the least amount of code necessary to reproduce the error. I can make tk.Button handle event '<3>' but not event '<1>'. That is, the function the event is passed to receives the event and can even print the address of the event object, but a callback later produces an error suggesting that no event was actually passed to the function. Also, tk.Label handles '<1>' without problem. What gives?
>
> Code, errors, and slightly more details here:
>
> http://ingcake.github.io/2015/07/02/tkinter-feature-request---clickable-button/
>
> I hope I'm just doing something dumb; any help would be much appreciated.
>
For a start, you're binding buttonHandler1 to button1 twice:

1. Passed via the 'command' keyword on line 13.

2 Via 'bind' on line 14.

In 1, no argument will be passed. The handler you've defined expects an
argument, so there'll be an exception, although the program will
continue afterwards.

In 2, an event argument will be passed.




More information about the Python-list mailing list