[Tkinter-discuss] Python 3.2 and binding Mousewheel on Mac

Michael O'Donnell michael.odonnell at uam.es
Sun Apr 22 14:51:00 CEST 2012


Hi Kevin,

Kevin:  I can't reproduce the issue in Python 2.7 (I don't have 3.x on
my system) nor can I reproduce it when run directly from Tk. The
equivalent Tk code:

Mick:    On my own Mac, the code works on 2.7.3 but not 3.2.
This was also reported by someone back in 2011.

Ned's comments on bugs.python explain why this is
the case:  (http://bugs.python.org/issue10731)

To quote Ned:

It looks like the problem is that the current Cocoa Tcl/Tk 8.5.x
returns an incorrect MouseWheel event.  Using the supplied test
program and breakpointing in PythonCmd (around Modules/_tkinter.c:2027
in default), I found that it is being called from Tcl for MouseWheel
events with an "argc" of 20, which looks suspiciously like the length
of argv[1], "4302153816mouse_wheel", rather than the number of
arguments which should be more like 3.  It may also be an issue that
affects Python because _tkinter still uses the older Tcl_CreateCommand
interface rather than the newer Tcl_CreateObjCommand.  The same Tcl
behavior is observed with Python 2.7 _tkinter.c but there the bogus
arguments are translated using PyString_FromString which is unaffected
by the garbage arguments.  It might be possible to workaround this
problem in _tkinter but the next step is to open a Tcl/Tk issue
against the Cocoa implementation and push for a proper fix there.

Mick


More information about the Tkinter-discuss mailing list