Skip to content

Commit e7b5f48

Browse files
committed
Fix x11_buttons definition
1 parent 7312224 commit e7b5f48

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

Lib/idlelib/idle_test/test_util.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
"""Test util, coverage %"""
22

33
import unittest
4-
from idlelib import util
4+
from test.support import requires
5+
requires('gui')
6+
from idlelib import util # Creates root and widget.
57

68

79
class UtilTest(unittest.TestCase):

Lib/idlelib/util.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* warning stuff (pyshell, run).
1414
"""
1515
import sys
16-
import tkinter
16+
import tkinter # This module requires gui to run (import).
1717

1818
# .pyw is for Windows; .pyi is for typing stub files.
1919
# The extension order is needed for iomenu open/save dialogs.
@@ -70,8 +70,10 @@ def fix_x11_paste(root):
7070
# On X11, Tk 8.6- signals mouse wheel rotations with <Button-4> and
7171
# <Button-5> events. With 8.7+, it generates <Mousewheel events
7272
# as on other systems. Used here, editor, tree, and test_sidebar.
73-
x11_buttons = (tkinter.BaseWidget._windowingsystem == 'x11' and
73+
root = tkinter.Tk() # Use this as process root?
74+
x11_buttons = (tkinter.Button(root)._windowingsystem == 'x11' and
7475
tkinter.TkVersion <= 8.6)
76+
root.destroy()
7577

7678
def wheel_event(event, widget=None): # Bound in editor and tree.
7779
"""Handle scrollwheel event.

0 commit comments

Comments
 (0)