gh-154511: Consolidate IDLE's mouse wheel handling in util - #156974
Merged
serhiy-storchaka merged 1 commit intoSep 6, 2026
Conversation
Move wheel_event there from idlelib.tree and add x11_buttons(widget) and bind_wheel(widget, func), used by the editor, the tree and test_sidebar. wheel_event now reads the direction from the event, not the platform. Move its test from test_tree, and test the fix_ functions of util too. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
terryjreedy
approved these changes
Sep 6, 2026
terryjreedy
left a comment
Member
There was a problem hiding this comment.
I reviewed most of the code other than the 'other' new test_util tests. On Windows,
I manually scrolled in editor, editor module browser with Editor class expanded, and settings font sample. All look normal.
|
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15. |
|
GH-157021 is a backport of this pull request to the 3.15 branch. |
|
GH-157022 is a backport of this pull request to the 3.14 branch. |
|
GH-157023 is a backport of this pull request to the 3.13 branch. |
serhiy-storchaka
added a commit
that referenced
this pull request
Sep 6, 2026
…-156974) (GH-157023) Move wheel_event there from idlelib.tree and add x11_buttons(widget) and bind_wheel(widget, func), used by the editor, the tree and test_sidebar. wheel_event now reads the direction from the event, not the platform. Move its test from test_tree, and test the fix_ functions of util too. (cherry picked from commit 57594aa) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
serhiy-storchaka
added a commit
that referenced
this pull request
Sep 6, 2026
…-156974) (GH-157022) Move wheel_event there from idlelib.tree and add x11_buttons(widget) and bind_wheel(widget, func), used by the editor, the tree and test_sidebar. wheel_event now reads the direction from the event, not the platform. Move its test from test_tree, and test the fix_ functions of util too. (cherry picked from commit 57594aa) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An alternative to #154512.
wheel_eventmoves fromidlelib.treetoidlelib.util, with its test, and gains two neighbours:x11_buttons(widget), which tells whether Tk reports a wheel rotation to that widget as<Button-4>/<Button-5>, as it does on X11 before Tk 8.7, or as<MouseWheel>, andbind_wheel(widget, func), which binds whichever of them Tk sends. The editor, the tree andtest_sidebaruse these instead of working out the windowing system themselves.x11_buttonstakes a widget because the windowing system is a property of the display, which only a widget knows. As a module-level constant it would need a root at import time, andutilmust not create one:pyshellimportsfix_win_hidpifrom it and calls it before any Tk operation,run.pyimports it in the user process, andtest_idlecurrently runs headless. For the same reasonutilstill imports tkinter only inside the function that needs a name from it.wheel_eventnow reads the direction from the event, by number for a button and by delta for a wheel, rather than from the platform, so it stays right whichever event arrives.The
fix_functions thatutilalready had are tested too; they were only called, never checked, by thesetUpClassof other test modules.fix_win_hidpiruns in a subprocess, as DPI awareness is process-wide and cannot be undone.The unneeded
<Button-4>/<Button-5>bindings insidebar.pyare left for a later PR, as in gh-154511.