This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author sdati
Recipients
Date 2005-02-08.02:40:56
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Logged In: YES 
user_id=1214285

I have determined the root cause of this problem.  It actually does lie in 
Tk, but is only revealed by Python Tkinter because of the way Python 
deals with events.

From Tk source -- tkWinX.c:

case WM_MOUSEWHEEL:
...
event.xany.send_event = -1
...

This line causes Tk to call TkpGetString() when ExpandPercents() is 
called with '%A' (which is done by Python for ALL events, including 
<MouseWheel>).  This, in turn, causes segmentation fault because 
event.xkey.trans_chars and event.xkey.nbytes are not initialized.

So, the workaround from the Python side is pretty ugly, but I have 
tested it and verified that it works.  There is probably a better way, but 
this was the obvious solution to me, since I have never needed to look at 
the Tkinter interface before:

In Tkinter.py, define a new _subst_format and _subst_format_str:

    _subst_format_workaround = ('%#', '%b', '%f', '%h', '%k',
             '%s', '%t', '%w', '%x', '%y',
             '%D', '%E', '%K', '%N', '%W', '%T', '%X', '%Y', '%D')
    _subst_format_str_workaround = " ".join(_subst_format_workaround)

Note that '%A' entry in _subst_format is replaced with '%D' entry in 
_subst_format_workaround.

Now, in Misc._bind(),

if sequence == "<MouseWheel>":
    cmd = ('%sif {"[%s %s]" == "break"} break\n'
           %
           (add and '+' or '',
            funcid, self._subst_format_str_workaround))
else:
    cmd = ('%sif {"[%s %s]" == "break"} break\n'
           %
           (add and '+' or '',
            funcid, self._subst_format_str))

I am submitting this bug to Tcl/Tk maintainers to request that they fix 
(Project: Tk Toolkit Request ID 1118340), but in the meantime (and for 
all older versions of Tk), it seems like a workaround in the Tkinter code 
might be appropriate.
History
Date User Action Args
2007-08-23 14:18:00adminlinkissue834351 messages
2007-08-23 14:18:00admincreate