gh-154511: IDLE - Update mousewheel event handling #154512
Conversation
Move x11_buttons boolean and wheel_event function to util.py. Move test to test_util.
|
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.) |
Only Linux, maybe ask a Mac expert to test it on a Mac. |
| # 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 |
There was a problem hiding this comment.
Bug: x11_buttons is always false.
_windowingsystem is a property, and it's accessed here on the class, not an instance.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Anyway, wheel should now work on linux and 8.6.
|
@ronaldoussoren @ned-deily Could one of you quickly test that scrolling still works on macOS in editor and module browser? |
|
Failures are mysteries to me. UBSan has repeated failures like this: with different idle_test.test_x for each failure Re-running some |
| root = tkinter.Tk() # Use this as process root? | ||
| x11_buttons = (tkinter.Button(root)._windowingsystem == 'x11' and | ||
| tkinter.TkVersion <= 8.6) | ||
| root.destroy() |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
Uh oh!
There was an error while loading. Please reload this page.