Skip to content

gh-154511: IDLE - Update mousewheel event handling #154512

Open
terryjreedy wants to merge 3 commits into
python:mainfrom
terryjreedy:x11wheel
Open

gh-154511: IDLE - Update mousewheel event handling #154512
terryjreedy wants to merge 3 commits into
python:mainfrom
terryjreedy:x11wheel

Conversation

@terryjreedy

@terryjreedy terryjreedy commented Jul 22, 2026

Copy link
Copy Markdown
Member

Move x11_buttons boolean and wheel_event function
to util.py.  Move test to test_util.
@terryjreedy

terryjreedy commented Jul 22, 2026

Copy link
Copy Markdown
Member Author

Quick manual checks on linux and macOS would be nice: load a non-trivial file such as editor.py and scroll up and down. Scrolling in a sidebar should not be affected by this PR. Open a module browser and expand enough to scroll both over the items and in the blank space. @StanFromIreland I forget whether you have mac or only linux.

EDIT: I have done the above on Windows and the unittest is system independent, as it patches the x11 indicator (which Serhiy wrote and tested on x11.)

@StanFromIreland

Copy link
Copy Markdown
Member

@StanFromIreland I forget whether you have mac or only linux.

Only Linux, maybe ask a Mac expert to test it on a Mac.

Comment thread Lib/idlelib/util.py Outdated
# On X11, Tk 8.6- signals mouse wheel rotations with <Button-4> and
# <Button-5> events. With 8.7+, it generates <Mousewheel events
# as on other systems. Used here, editor, tree, and test_sidebar.
x11_buttons = (tkinter.BaseWidget._windowingsystem == 'x11' and

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Bug: x11_buttons is always false.

_windowingsystem is a property, and it's accessed here on the class, not an instance.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed by creating root. After pulling pyshell.main into a new start/main module, I will consider possibility of making util.root the master root. The windowing system could also be saved and imported by macos. Separate issue/pr.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Anyway, wheel should now work on linux and 8.6.

@terryjreedy

Copy link
Copy Markdown
Member Author

@ronaldoussoren @ned-deily Could one of you quickly test that scrolling still works on macOS in editor and module browser?

@terryjreedy

terryjreedy commented Jul 23, 2026

Copy link
Copy Markdown
Member Author

Failures are mysteries to me.
test_idle worker non-zero exit code�[0m (Exit code -5 (SIGTRAP)) macOS
?? no detail
test_idle worker non-zero exit code�[0m (Exit code -11 (SIGSEGV)) macOS intel and macOS free threading
File "/Users/runner/work/cpython/cpython/Lib/tkinter/init.py", line 1579 in update
File "/Users/runner/work/cpython/cpython/Lib/test/support/init.py", line 306 in _is_gui_available
File "/Users/runner/work/cpython/cpython/Lib/test/support/init.py", line 346 in requires
File "/Users/runner/work/cpython/cpython/Lib/idlelib/idle_test/test_configdialog.py", line 7 in
?? How does patch affect tkinter.init when running test_configdialog??

UBSan has repeated failures like this:
Traceback (most recent call last):
File "/home/runner/work/cpython/cpython/Lib/unittest/loader.py", line 433, in _find_test_path
module = self._get_module_from_name(name)
File "/home/runner/work/cpython/cpython/Lib/unittest/loader.py", line 374, in _get_module_from_name
import(name)
~~~~~~~~~~^^^^^^
File "/home/runner/work/cpython/cpython/Lib/idlelib/idle_test/test_browser.py", line 3, in
from idlelib import browser
File "/home/runner/work/cpython/cpython/Lib/idlelib/browser.py", line 16, in
from idlelib import pyshell
File "/home/runner/work/cpython/cpython/Lib/idlelib/pyshell.py", line 39, in
from idlelib.editor import EditorWindow
File "/home/runner/work/cpython/cpython/Lib/idlelib/editor.py", line 29, in
from idlelib.util import py_extensions
File "/home/runner/work/cpython/cpython/Lib/idlelib/util.py", line 73, in
root = tkinter.Tk() # Use this as process root?
File "/home/runner/work/cpython/cpython/Lib/tkinter/init.py", line 2687, in init
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_tkinter.TclError: no display name and no $DISPLAY environment variable
Failed to import test module: idlelib.idle_test.test_debugobj

with different idle_test.test_x for each failure
Hypothesis has failures like this also.
?? Why does this particular (and new) Tk() call fail?? and just on some tests.

Re-running some

Comment thread Lib/idlelib/util.py
Comment on lines +73 to +76
root = tkinter.Tk() # Use this as process root?
x11_buttons = (tkinter.Button(root)._windowingsystem == 'x11' and
tkinter.TkVersion <= 8.6)
root.destroy()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Simply do not make it a global variable. If you want to share a code, make it a function that takes a widget as argument.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Which? x11_buttons is just False/True. Creating root at top level is a standard idiom for non-class tkinter code. Is tcl/tk broken on macOS? I'm not sure I understand the second sentence. Are you suggesting something like below?
(I now realize that root counts as a widget, and that widget._win... is root.win... .

def x11b(widget):
    return widget._windowingsystem == 'x11' and tkinter.TkVersion <= 8.6
x11_buttons = x11b(root)

A function makes no sense to me since the windowing system does not depend on the widget, so it seems sensible to cache it (which, I just read, tkinter does).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants