New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mouse wheel crashes program #39484
Comments
The following program (by Michael Peuser) crashes as Gary Richardson #------------------------- from Tkinter import *
def _onMouseWheel(event):
print event
root = Tk()
root.bind('<MouseWheel>',_onMouseWheel)
root.mainloop() |
Logged In: YES What operating system are you using? |
Logged In: YES I'm using Win98SE. |
Logged In: YES Happens for me too, on Win2K with python 2.3.2. The fault is |
Logged In: YES I can reproduce this bug. I am running Python 2.3.4 on tk84.dll is version 8.4.3; tcl84.dll is also 8.4.3. The mousewheel works correctly with a Tkinter.Text object |
Logged In: YES Me too. Python 2.3.4 with Tcl/Tk 8.4.9. Crash on Scroll Wheeling in WinXP I'll try to make this happen in pure Tcl/Tk rather than Tkinter too. |
Logged In: YES I wasn't able to reproduce this in pure Tcl/Tk (under Wish). No surprise toplevel .top And mouse wheeling in the Toplevel widget made a bunch of 'foo's appear in HTH. |
Logged In: YES I have determined the root cause of this problem. It actually does lie in From Tk source -- tkWinX.c: case WM_MOUSEWHEEL: This line causes Tk to call TkpGetString() when ExpandPercents() is So, the workaround from the Python side is pretty ugly, but I have 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 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 |
Logged In: YES sdati, thanks for this workaround. it's awesome. i am now I did make a small improvement to it so it works for all This way, all permutations of mouse events are covered, e.g. |
Logged In: YES Bumping, as it is still the same with 2.4 on my box. |
3.0.1, WinXP, with two 3.0 revisions: from tkinter import *
def _onMouseWheel(event):
print(event)
root = Tk()
root.bind('<MouseWheel>',_onMouseWheel) In IDLE shell, nothing changes, wheel works normally. In interpreter window, wheel continues to work normally. Unless someone can verify that there is a problem in 2.6.1, or in 3.0.1 |
This is a tk issue, so the best way to fix this (if you don't want to Unfortunately the proposed workaround is way too specific, imagine if If we want to be safe, Tkinter should be passing only valid |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: