[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-bugs-list
Subject:    [ python-Bugs-834351 ] Mouse wheel crashes program
From:       noreply () sourceforge ! net (SourceForge ! net)
Date:       2005-05-31 13:11:38
Message-ID: E1Dd6Ww-0000o4-V8 () sc8-sf-web2 ! sourceforge ! net
[Download RAW message or body]

Bugs item #834351, was opened at 2003-11-02 01:37
Message generated for change (Comment added) made by birkenfeld
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=834351&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Tkinter
>Group: Python 2.4
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: Reinhold Birkenfeld (birkenfeld)
Date: 2005-05-31 15:11

Message:
Logged In: YES 
user_id=1188172

Bumping, as it is still the same with 2.4 on my box.

----------------------------------------------------------------------

Comment By: nikolaus heger (orthorim)
Date: 2005-05-12 16: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 03: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 16: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 16: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 06: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 18: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 03:42

Message:
Logged In: YES 
user_id=899035

I'm using Win98SE. 

----------------------------------------------------------------------

Comment By: Martin v. L?wis (loewis)
Date: 2003-11-02 19: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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic