GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-154511: Consolidate IDLE's mouse wheel handling in util by serhiy-storchaka · Pull Request #156974 · python/cpython

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Sep 5, 2026

Copy link
Copy Markdown
Member

An alternative to #154512.

wheel_event moves from idlelib.tree to idlelib.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>, and bind_wheel(widget, func), which binds whichever of them Tk sends. The editor, the tree and test_sidebar use these instead of working out the windowing system themselves.

x11_buttons takes 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, and util must not create one: pyshell imports fix_win_hidpi from it and calls it before any Tk operation, run.py imports it in the user process, and test_idle currently runs headless. For the same reason util still imports tkinter only inside the function that needs a name from it.

wheel_event now 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 that util already had are tested too; they were only called, never checked, by the setUpClass of other test modules. fix_win_hidpi runs in a subprocess, as DPI awareness is process-wide and cannot be undone.

The unneeded <Button-4>/<Button-5> bindings in sidebar.py are left for a later PR, as in gh-154511.

  • Issue: IDLE - Update mousewheel event handling #154511

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@serhiy-storchaka @claude
pythongh-154511: Consolidate IDLE's mouse wheel handling in util
98213fc
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 <[email protected]>
@serhiy-storchaka
serhiy-storchaka requested a review from terryjreedy as a code owner September 5, 2026 09:54
@bedevere-app bedevere-app Bot mentioned this pull request Sep 5, 2026
IDLE - Update mousewheel event handling #154511
Open
@bedevere-app bedevere-app Bot added the awaiting core review label Sep 5, 2026
@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Sep 5, 2026
@serhiy-storchaka serhiy-storchaka mentioned this pull request Sep 5, 2026
gh-154511: IDLE - Update mousewheel event handling #154512
Closed
terryjreedy
terryjreedy approved these changes Sep 6, 2026
View reviewed changes

@terryjreedy terryjreedy left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Sep 6, 2026
@serhiy-storchaka
serhiy-storchaka merged commit 57594aa into python:main Sep 6, 2026
63 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label Sep 6, 2026
@miss-islington-app

miss-islington-app Bot commented Sep 6, 2026

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka
serhiy-storchaka deleted the idle-mousewheel-util branch September 6, 2026 06:15
@bedevere-app

bedevere-app Bot commented Sep 6, 2026

Copy link
Copy Markdown

GH-157021 is a backport of this pull request to the 3.15 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Sep 6, 2026
@bedevere-app

bedevere-app Bot commented Sep 6, 2026

Copy link
Copy Markdown

GH-157022 is a backport of this pull request to the 3.14 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Sep 6, 2026
@bedevere-app

bedevere-app Bot commented Sep 6, 2026

Copy link
Copy Markdown

GH-157023 is a backport of this pull request to the 3.13 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label Sep 6, 2026
serhiy-storchaka added a commit that referenced this pull request Sep 6, 2026
@miss-islington @serhiy-storchaka @claude
[3.13] gh-154511: Consolidate IDLE's mouse wheel handling in util (GH…
19693af
…-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 <[email protected]>
Co-authored-by: Claude Opus 5 <[email protected]>
serhiy-storchaka added a commit that referenced this pull request Sep 6, 2026
@miss-islington @serhiy-storchaka @claude
[3.14] gh-154511: Consolidate IDLE's mouse wheel handling in util (GH…
a9152fb
…-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 <[email protected]>
Co-authored-by: Claude Opus 5 <[email protected]>
clin1234 pushed a commit to clin1234/cpython that referenced this pull request Sep 12, 2026
@serhiy-storchaka @claude @clin1234
pythongh-154511: Consolidate IDLE's mouse wheel handling in util (pyt…
597b67b
…honGH-156974)

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 <[email protected]>
serhiy-storchaka added a commit to TheLizzard/cpython that referenced this pull request Sep 15, 2026
@serhiy-storchaka
Merge branch 'main' into fix-issue-140389
7ed1654
wheel_event() and its tests moved from idlelib.tree to idlelib.util in
pythonGH-156974, so the horizontal scrolling change is re-applied there.
@serhiy-storchaka serhiy-storchaka mentioned this pull request Sep 15, 2026
gh-140389: fixed touchpad horizontal scrolling in IDLE editor #140390
Open
terryjreedy pushed a commit that referenced this pull request Oct 9, 2026
@miss-islington @serhiy-storchaka @claude
[3.15] gh-154511: Consolidate IDLE's mouse wheel handling in util (GH…
240efc0
…-156974) (#157021)

* gh-154511: Consolidate IDLE's mouse wheel handling in util (GH-156974)

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 <[email protected]>
Co-authored-by: Claude Opus 5 <[email protected]>

Misc.tk_scaling is new in 3.16, and fix_scaling itself calls "tk
scaling" here.

Co-Authored-By: Claude Opus 5 <[email protected]>

---------

Co-authored-by: Serhiy Storchaka <[email protected]>
Co-authored-by: Claude Opus 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@terryjreedy terryjreedy terryjreedy approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@serhiy-storchaka @terryjreedy
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.