Bugs item #834351, was opened at 2003-11-02 00:37 Message generated for change (Comment added) made by orthorim You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=834351&group_id=5470
Category: Tkinter Group: Python 2.2.3 Status: Open Resolution: None Priority: 5 Submitted By: Gary Richardson (garyrxx) Assigned to: Martin v. Löwis (loewis) Summary: Mouse wheel crashes program Initial Comment: The following program (by Michael Peuser) crashes as soon as the mouse wheel is moved. See my post to c.l.p. on Oct 29. Gary Richardson #------------------------- from Tkinter import * def _onMouseWheel(event): print event root = Tk() root.bind('<MouseWheel>',_onMouseWheel) root.mainloop() ---------------------------------------------------------------------- Comment By: nikolaus heger (orthorim) Date: 2005-05-12 14:41 Message: Logged In: YES user_id=933256 sdati, thanks for this workaround. it's awesome. i am now happily mouse-wheeling :) I did make a small improvement to it so it works for all MouseWheel type events. Instead of if sequence == "<MouseWheel>": i say if type(sequence) == str and sequence.__contains__("MouseWheel"): This way, all permutations of mouse events are covered, e.g. "<Control-MouseWheel>" ---------------------------------------------------------------------- Comment By: Steve Davis (sdati) Date: 2005-02-08 02:40 Message: 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. ---------------------------------------------------------------------- Comment By: John Speno (corvus) Date: 2005-01-04 15:40 Message: Logged In: YES user_id=2138 I wasn't able to reproduce this in pure Tcl/Tk (under Wish). No surprise there. In wish, I used this: toplevel .top bind .top <MouseWheel> {puts 'foo'} And mouse wheeling in the Toplevel widget made a bunch of 'foo's appear in the wish console without crashing. HTH. ---------------------------------------------------------------------- Comment By: John Speno (corvus) Date: 2005-01-04 15:02 Message: Logged In: YES user_id=2138 Me too. Python 2.3.4 with Tcl/Tk 8.4.9. Crash on Scroll Wheeling in WinXP SP 1. (users report it happening in SP 2 also). I'll try to make this happen in pure Tcl/Tk rather than Tkinter too. ---------------------------------------------------------------------- Comment By: John Fouhy (johnfouhy) Date: 2004-10-26 04:13 Message: Logged In: YES user_id=1084032 I can reproduce this bug. I am running Python 2.3.4 on WinXP SP2. tk84.dll is version 8.4.3; tcl84.dll is also 8.4.3. The mousewheel works correctly with a Tkinter.Text object with no additional bindings. ---------------------------------------------------------------------- Comment By: Jon Ashley (ash101) Date: 2003-12-04 17:02 Message: Logged In: YES user_id=923903 Happens for me too, on Win2K with python 2.3.2. The fault is in TCL84.DLL at an offset of 1002a58c, if that means anything to anyone. ---------------------------------------------------------------------- Comment By: Gary Richardson (garyrxx) Date: 2003-11-03 02:42 Message: Logged In: YES user_id=899035 I'm using Win98SE. ---------------------------------------------------------------------- Comment By: Martin v. Löwis (loewis) Date: 2003-11-02 18:37 Message: Logged In: YES user_id=21627 What operating system are you using? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=834351&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com