Issue #24759: IDLE requires tk 8.5 and availability ttk widgets.

Delete now unneeded tk version tests and code for older versions.
This commit is contained in:
Terry Jan Reedy 2016-06-09 21:09:15 -04:00
parent 82ae15597f
commit 1080d13a7d
8 changed files with 38 additions and 40 deletions

View File

@ -1,6 +1,7 @@
"""The idlelib package implements the Idle application. """The idlelib package implements the Idle application.
Idle includes an interactive shell and editor. 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. Use the files named idle.* to start Idle.
The other files are private implementations. Their details are subject to The other files are private implementations. Their details are subject to

View File

@ -2,7 +2,6 @@ import time
import re import re
import keyword import keyword
import builtins import builtins
from tkinter import TkVersion
from idlelib.delegator import Delegator from idlelib.delegator import Delegator
from idlelib.config import idleConf from idlelib.config import idleConf
@ -49,11 +48,8 @@ def color_config(text): # Called from htest, Editor, and Turtle Demo.
insertbackground=cursor_color, insertbackground=cursor_color,
selectforeground=select_colors['foreground'], selectforeground=select_colors['foreground'],
selectbackground=select_colors['background'], selectbackground=select_colors['background'],
) inactiveselectbackground=select_colors['background'], # new in 8.5
if TkVersion >= 8.5: )
text.config(
inactiveselectbackground=select_colors['background'])
class ColorDelegator(Delegator): class ColorDelegator(Delegator):
@ -277,5 +273,8 @@ def _color_delegator(parent): # htest #
p.insertfilter(d) p.insertfilter(d)
if __name__ == "__main__": if __name__ == "__main__":
import unittest
unittest.main('idlelib.idle_test.test_colorizer',
verbosity=2, exit=False)
from idlelib.idle_test.htest import run from idlelib.idle_test.htest import run
run(_color_delegator) run(_color_delegator)

View File

@ -22,7 +22,6 @@ import os
import sys import sys
from configparser import ConfigParser from configparser import ConfigParser
from tkinter import TkVersion
from tkinter.font import Font, nametofont from tkinter.font import Font, nametofont
class InvalidConfigType(Exception): pass class InvalidConfigType(Exception): pass
@ -713,16 +712,13 @@ class IdleConf:
bold = self.GetOption(configType, section, 'font-bold', default=0, bold = self.GetOption(configType, section, 'font-bold', default=0,
type='bool') type='bool')
if (family == 'TkFixedFont'): if (family == 'TkFixedFont'):
if TkVersion < 8.5: f = Font(name='TkFixedFont', exists=True, root=root)
family = 'Courier' actualFont = Font.actual(f)
else: family = actualFont['family']
f = Font(name='TkFixedFont', exists=True, root=root) size = actualFont['size']
actualFont = Font.actual(f) if size <= 0:
family = actualFont['family'] size = 10 # if font in pixels, ignore actual size
size = actualFont['size'] bold = actualFont['weight'] == 'bold'
if size <= 0:
size = 10 # if font in pixels, ignore actual size
bold = actualFont['weight']=='bold'
return (family, size, 'bold' if bold else 'normal') return (family, size, 'bold' if bold else 'normal')
def LoadCfgFiles(self): def LoadCfgFiles(self):
@ -740,7 +736,7 @@ class IdleConf:
idleConf = IdleConf() idleConf = IdleConf()
# TODO Revise test output, write expanded unittest # TODO Revise test output, write expanded unittest
### module test #
if __name__ == '__main__': if __name__ == '__main__':
def dumpCfg(cfg): def dumpCfg(cfg):
print('\n', cfg, '\n') print('\n', cfg, '\n')

View File

@ -110,13 +110,10 @@ class EditorWindow(object):
'wrap': 'none', 'wrap': 'none',
'highlightthickness': 0, 'highlightthickness': 0,
'width': self.width, 'width': self.width,
'height': idleConf.GetOption('main', 'EditorWindow', 'tabstyle': 'wordprocessor', # new in 8.5
'height', type='int')} 'height': idleConf.GetOption(
if TkVersion >= 8.5: 'main', 'EditorWindow', 'height', type='int'),
# 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'
self.text = text = MultiCallCreator(Text)(text_frame, **text_options) self.text = text = MultiCallCreator(Text)(text_frame, **text_options)
self.top.focused_widget = self.text self.top.focused_widget = self.text

View File

@ -1,6 +1,8 @@
'''idlelib.idle_test is a private implementation of test.test_idle, '''idlelib.idle_test is a private implementation of test.test_idle,
which tests the IDLE application as part of the stdlib test suite. which tests the IDLE application as part of the stdlib test suite.
Run IDLE tests alone with "python -m test.test_idle". 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 This package and its contained modules are subject to change and
any direct use is at your own risk. any direct use is at your own risk.
''' '''

View File

@ -199,12 +199,6 @@ def overrideRootMenu(root, flist):
('About IDLE', '<<about-idle>>'), ('About IDLE', '<<about-idle>>'),
None, 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(): if isCocoaTk():
# replace default About dialog with About IDLE one # replace default About dialog with About IDLE one
root.createcommand('tkAboutDialog', about_dialog) root.createcommand('tkAboutDialog', about_dialog)

View File

@ -1,5 +1,20 @@
#! /usr/bin/env python3 #! /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 getopt
import os import os
import os.path import os.path
@ -16,14 +31,6 @@ import linecache
from code import InteractiveInterpreter from code import InteractiveInterpreter
from platform import python_version, system 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.editor import EditorWindow, fixwordbreaks
from idlelib.filelist import FileList from idlelib.filelist import FileList
from idlelib.colorizer import ColorDelegator from idlelib.colorizer import ColorDelegator
@ -1536,7 +1543,7 @@ def main():
if system() == 'Windows': if system() == 'Windows':
iconfile = os.path.join(icondir, 'idle.ico') iconfile = os.path.join(icondir, 'idle.ico')
root.wm_iconbitmap(default=iconfile) root.wm_iconbitmap(default=iconfile)
elif TkVersion >= 8.5: else:
ext = '.png' if TkVersion >= 8.6 else '.gif' ext = '.png' if TkVersion >= 8.6 else '.gif'
iconfiles = [os.path.join(icondir, 'idle_%d%s' % (size, ext)) iconfiles = [os.path.join(icondir, 'idle_%d%s' % (size, ext))
for size in (16, 32, 48)] for size in (16, 32, 48)]

View File

@ -4,6 +4,8 @@ from test.support import import_module
# Skip test if _thread or _tkinter wasn't built or idlelib was deleted. # Skip test if _thread or _tkinter wasn't built or idlelib was deleted.
import_module('threading') # imported by PyShell, imports _thread import_module('threading') # imported by PyShell, imports _thread
tk = import_module('tkinter') # imports _tkinter 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') idletest = import_module('idlelib.idle_test')
# Without test_main present, regrtest.runtest_inner (line1219) calls # Without test_main present, regrtest.runtest_inner (line1219) calls