diff options
-rw-r--r-- | Lib/idlelib/__init__.py | 1 | ||||
-rw-r--r-- | Lib/idlelib/colorizer.py | 11 | ||||
-rw-r--r-- | Lib/idlelib/config.py | 20 | ||||
-rw-r--r-- | Lib/idlelib/editor.py | 11 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/__init__.py | 2 | ||||
-rw-r--r-- | Lib/idlelib/macosx.py | 6 | ||||
-rwxr-xr-x | Lib/idlelib/pyshell.py | 25 | ||||
-rw-r--r-- | Lib/test/test_idle.py | 2 |
8 files changed, 38 insertions, 40 deletions
diff --git a/Lib/idlelib/__init__.py b/Lib/idlelib/__init__.py index 711f61b..fef21be 100644 --- a/Lib/idlelib/__init__.py +++ b/Lib/idlelib/__init__.py @@ -1,6 +1,7 @@ """The idlelib package implements the Idle application. Idle includes an interactive shell and editor. +Starting with Python 3.6, IDLE requires tcl/tk 8.5 or later. Use the files named idle.* to start Idle. The other files are private implementations. Their details are subject to diff --git a/Lib/idlelib/colorizer.py b/Lib/idlelib/colorizer.py index ec84b81..5b6dc67 100644 --- a/Lib/idlelib/colorizer.py +++ b/Lib/idlelib/colorizer.py @@ -2,7 +2,6 @@ import time import re import keyword import builtins -from tkinter import TkVersion from idlelib.delegator import Delegator from idlelib.config import idleConf @@ -49,11 +48,8 @@ def color_config(text): # Called from htest, Editor, and Turtle Demo. insertbackground=cursor_color, selectforeground=select_colors['foreground'], selectbackground=select_colors['background'], - ) - if TkVersion >= 8.5: - text.config( - inactiveselectbackground=select_colors['background']) - + inactiveselectbackground=select_colors['background'], # new in 8.5 + ) class ColorDelegator(Delegator): @@ -277,5 +273,8 @@ def _color_delegator(parent): # htest # p.insertfilter(d) if __name__ == "__main__": + import unittest + unittest.main('idlelib.idle_test.test_colorizer', + verbosity=2, exit=False) from idlelib.idle_test.htest import run run(_color_delegator) diff --git a/Lib/idlelib/config.py b/Lib/idlelib/config.py index b9e1c6d..4d87de0 100644 --- a/Lib/idlelib/config.py +++ b/Lib/idlelib/config.py @@ -22,7 +22,6 @@ import os import sys from configparser import ConfigParser -from tkinter import TkVersion from tkinter.font import Font, nametofont class InvalidConfigType(Exception): pass @@ -713,16 +712,13 @@ class IdleConf: bold = self.GetOption(configType, section, 'font-bold', default=0, type='bool') if (family == 'TkFixedFont'): - if TkVersion < 8.5: - family = 'Courier' - else: - f = Font(name='TkFixedFont', exists=True, root=root) - actualFont = Font.actual(f) - family = actualFont['family'] - size = actualFont['size'] - if size <= 0: - size = 10 # if font in pixels, ignore actual size - bold = actualFont['weight']=='bold' + f = Font(name='TkFixedFont', exists=True, root=root) + actualFont = Font.actual(f) + family = actualFont['family'] + size = actualFont['size'] + if size <= 0: + size = 10 # if font in pixels, ignore actual size + bold = actualFont['weight'] == 'bold' return (family, size, 'bold' if bold else 'normal') def LoadCfgFiles(self): @@ -740,7 +736,7 @@ class IdleConf: idleConf = IdleConf() # TODO Revise test output, write expanded unittest -### module test +# if __name__ == '__main__': def dumpCfg(cfg): print('\n', cfg, '\n') diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py index b214c6a..d04fc08 100644 --- a/Lib/idlelib/editor.py +++ b/Lib/idlelib/editor.py @@ -110,13 +110,10 @@ class EditorWindow(object): 'wrap': 'none', 'highlightthickness': 0, 'width': self.width, - 'height': idleConf.GetOption('main', 'EditorWindow', - 'height', type='int')} - if TkVersion >= 8.5: - # Starting with tk 8.5 we have to set the new tabstyle option - # to 'wordprocessor' to achieve the same display of tabs as in - # older tk versions. - text_options['tabstyle'] = 'wordprocessor' + 'tabstyle': 'wordprocessor', # new in 8.5 + 'height': idleConf.GetOption( + 'main', 'EditorWindow', 'height', type='int'), + } self.text = text = MultiCallCreator(Text)(text_frame, **text_options) self.top.focused_widget = self.text diff --git a/Lib/idlelib/idle_test/__init__.py b/Lib/idlelib/idle_test/__init__.py index 845c92d..ad067b4 100644 --- a/Lib/idlelib/idle_test/__init__.py +++ b/Lib/idlelib/idle_test/__init__.py @@ -1,6 +1,8 @@ '''idlelib.idle_test is a private implementation of test.test_idle, which tests the IDLE application as part of the stdlib test suite. Run IDLE tests alone with "python -m test.test_idle". +Starting with Python 3.6, IDLE requires tcl/tk 8.5 or later. + This package and its contained modules are subject to change and any direct use is at your own risk. ''' diff --git a/Lib/idlelib/macosx.py b/Lib/idlelib/macosx.py index 4e4dcd6..b16e052 100644 --- a/Lib/idlelib/macosx.py +++ b/Lib/idlelib/macosx.py @@ -199,12 +199,6 @@ def overrideRootMenu(root, flist): ('About IDLE', '<<about-idle>>'), None, ])) - tkversion = root.tk.eval('info patchlevel') - if tuple(map(int, tkversion.split('.'))) < (8, 4, 14): - # for earlier AquaTk versions, supply a Preferences menu item - mainmenu.menudefs[0][1].append( - ('_Preferences....', '<<open-config-dialog>>'), - ) if isCocoaTk(): # replace default About dialog with About IDLE one root.createcommand('tkAboutDialog', about_dialog) diff --git a/Lib/idlelib/pyshell.py b/Lib/idlelib/pyshell.py index 9fc46ca..38c12cd 100755 --- a/Lib/idlelib/pyshell.py +++ b/Lib/idlelib/pyshell.py @@ -1,5 +1,20 @@ #! /usr/bin/env python3 +try: + from tkinter import * +except ImportError: + print("** IDLE can't import Tkinter.\n" + "Your Python may not be configured for Tk. **", file=sys.__stderr__) + sys.exit(1) +import tkinter.messagebox as tkMessageBox +if TkVersion < 8.5: + root = Tk() # otherwise create root in main + root.withdraw() + tkMessageBox.showerror("Idle Cannot Start", + "Idle requires tcl/tk 8.5+, not $s." % TkVersion, + parent=root) + sys.exit(1) + import getopt import os import os.path @@ -16,14 +31,6 @@ import linecache from code import InteractiveInterpreter from platform import python_version, system -try: - from tkinter import * -except ImportError: - print("** IDLE can't import Tkinter.\n" - "Your Python may not be configured for Tk. **", file=sys.__stderr__) - sys.exit(1) -import tkinter.messagebox as tkMessageBox - from idlelib.editor import EditorWindow, fixwordbreaks from idlelib.filelist import FileList from idlelib.colorizer import ColorDelegator @@ -1536,7 +1543,7 @@ def main(): if system() == 'Windows': iconfile = os.path.join(icondir, 'idle.ico') root.wm_iconbitmap(default=iconfile) - elif TkVersion >= 8.5: + else: ext = '.png' if TkVersion >= 8.6 else '.gif' iconfiles = [os.path.join(icondir, 'idle_%d%s' % (size, ext)) for size in (16, 32, 48)] diff --git a/Lib/test/test_idle.py b/Lib/test/test_idle.py index 0b34e97..46f1a5c 100644 --- a/Lib/test/test_idle.py +++ b/Lib/test/test_idle.py @@ -4,6 +4,8 @@ from test.support import import_module # Skip test if _thread or _tkinter wasn't built or idlelib was deleted. import_module('threading') # imported by PyShell, imports _thread tk = import_module('tkinter') # imports _tkinter +if tk.TkVersion < 8.5: + raise unittest.SkipTest("IDLE requires tk 8.5 or later.") idletest = import_module('idlelib.idle_test') # Without test_main present, regrtest.runtest_inner (line1219) calls |