mirror of https://github.com/python/cpython
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:
parent
82ae15597f
commit
1080d13a7d
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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.
|
||||
'''
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue