summaryrefslogtreecommitdiff
path: root/Lib/idlelib
diff options
context:
space:
mode:
authorTerry Jan Reedy <tjreedy@udel.edu>2015-11-12 15:03:17 -0500
committerTerry Jan Reedy <tjreedy@udel.edu>2015-11-12 15:03:17 -0500
commite19f3ec07228aeaa9bd1379413a3054953a5c51e (patch)
tree958f95fe937af722c99f472ed2c9f1bc83880e8b /Lib/idlelib
parent2f85555531c79184767d4954f20e310beda99421 (diff)
parentd0c0f0041c3eb561adfa57179bc41f4dae212317 (diff)
downloadcpython-git-e19f3ec07228aeaa9bd1379413a3054953a5c51e.tar.gz
Merge with 3.4
Diffstat (limited to 'Lib/idlelib')
-rw-r--r--Lib/idlelib/ClassBrowser.py2
-rw-r--r--Lib/idlelib/ColorDelegator.py2
-rw-r--r--Lib/idlelib/EditorWindow.py2
-rwxr-xr-xLib/idlelib/PyShell.py6
-rw-r--r--Lib/idlelib/TreeWidget.py2
-rw-r--r--Lib/idlelib/config-main.def2
-rw-r--r--Lib/idlelib/configDialog.py29
-rw-r--r--Lib/idlelib/configHandler.py28
8 files changed, 48 insertions, 25 deletions
diff --git a/Lib/idlelib/ClassBrowser.py b/Lib/idlelib/ClassBrowser.py
index 5be65efb9b..d09c52fe4d 100644
--- a/Lib/idlelib/ClassBrowser.py
+++ b/Lib/idlelib/ClassBrowser.py
@@ -56,7 +56,7 @@ class ClassBrowser:
self.settitle()
top.focus_set()
# create scrolled canvas
- theme = idleConf.GetOption('main','Theme','name')
+ theme = idleConf.CurrentTheme()
background = idleConf.GetHighlight(theme, 'normal')['background']
sc = ScrolledCanvas(top, bg=background, highlightthickness=0, takefocus=1)
sc.frame.pack(expand=1, fill="both")
diff --git a/Lib/idlelib/ColorDelegator.py b/Lib/idlelib/ColorDelegator.py
index 13a9010313..9f31349604 100644
--- a/Lib/idlelib/ColorDelegator.py
+++ b/Lib/idlelib/ColorDelegator.py
@@ -60,7 +60,7 @@ class ColorDelegator(Delegator):
self.tag_raise('sel')
def LoadTagDefs(self):
- theme = idleConf.GetOption('main','Theme','name')
+ theme = idleConf.CurrentTheme()
self.tagdefs = {
"COMMENT": idleConf.GetHighlight(theme, "comment"),
"KEYWORD": idleConf.GetHighlight(theme, "keyword"),
diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py
index 34ef89d06e..58a01dc1a2 100644
--- a/Lib/idlelib/EditorWindow.py
+++ b/Lib/idlelib/EditorWindow.py
@@ -739,7 +739,7 @@ class EditorWindow(object):
# Called from self.filename_change_hook and from configDialog.py
self._rmcolorizer()
self._addcolorizer()
- theme = idleConf.GetOption('main','Theme','name')
+ theme = idleConf.CurrentTheme()
normal_colors = idleConf.GetHighlight(theme, 'normal')
cursor_color = idleConf.GetHighlight(theme, 'cursor', fgBg='fg')
select_colors = idleConf.GetHighlight(theme, 'hilite')
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py
index 57aa6dae2e..058dfb92e5 100755
--- a/Lib/idlelib/PyShell.py
+++ b/Lib/idlelib/PyShell.py
@@ -152,7 +152,7 @@ class PyShellEditorWindow(EditorWindow):
# possible due to update in restore_file_breaks
return
if color:
- theme = idleConf.GetOption('main','Theme','name')
+ theme = idleConf.CurrentTheme()
cfg = idleConf.GetHighlight(theme, "break")
else:
cfg = {'foreground': '', 'background': ''}
@@ -338,7 +338,7 @@ class ModifiedColorDelegator(ColorDelegator):
def LoadTagDefs(self):
ColorDelegator.LoadTagDefs(self)
- theme = idleConf.GetOption('main','Theme','name')
+ theme = idleConf.CurrentTheme()
self.tagdefs.update({
"stdin": {'background':None,'foreground':None},
"stdout": idleConf.GetHighlight(theme, "stdout"),
@@ -621,7 +621,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
item = RemoteObjectBrowser.StubObjectTreeItem(self.rpcclt, oid)
from idlelib.TreeWidget import ScrolledCanvas, TreeNode
top = Toplevel(self.tkconsole.root)
- theme = idleConf.GetOption('main','Theme','name')
+ theme = idleConf.CurrentTheme()
background = idleConf.GetHighlight(theme, 'normal')['background']
sc = ScrolledCanvas(top, bg=background, highlightthickness=0)
sc.frame.pack(expand=1, fill="both")
diff --git a/Lib/idlelib/TreeWidget.py b/Lib/idlelib/TreeWidget.py
index 4844a695ad..a19578fdcb 100644
--- a/Lib/idlelib/TreeWidget.py
+++ b/Lib/idlelib/TreeWidget.py
@@ -249,7 +249,7 @@ class TreeNode:
except AttributeError:
# padding carefully selected (on Windows) to match Entry widget:
self.label = Label(self.canvas, text=text, bd=0, padx=2, pady=2)
- theme = idleConf.GetOption('main','Theme','name')
+ theme = idleConf.CurrentTheme()
if self.selected:
self.label.configure(idleConf.GetHighlight(theme, 'hilite'))
else:
diff --git a/Lib/idlelib/config-main.def b/Lib/idlelib/config-main.def
index 3622cb2a30..8ebbc1b4c2 100644
--- a/Lib/idlelib/config-main.def
+++ b/Lib/idlelib/config-main.def
@@ -65,6 +65,8 @@ num-spaces= 4
[Theme]
default= 1
name= IDLE Classic
+name2=
+# name2 set in user config-main.cfg for themes added after 2015 Oct 1
[Keys]
default= 1
diff --git a/Lib/idlelib/configDialog.py b/Lib/idlelib/configDialog.py
index f5388178e0..9b16459d54 100644
--- a/Lib/idlelib/configDialog.py
+++ b/Lib/idlelib/configDialog.py
@@ -263,6 +263,7 @@ class ConfigDialog(Toplevel):
self.buttonDeleteCustomTheme=Button(
frameTheme, text='Delete Custom Theme',
command=self.DeleteCustomTheme)
+ self.new_custom_theme = Label(frameTheme, bd=2)
##widget packing
#body
@@ -286,6 +287,7 @@ class ConfigDialog(Toplevel):
self.optMenuThemeBuiltin.pack(side=TOP, fill=X, padx=5, pady=5)
self.optMenuThemeCustom.pack(side=TOP, fill=X, anchor=W, padx=5, pady=5)
self.buttonDeleteCustomTheme.pack(side=TOP, fill=X, padx=5, pady=5)
+ self.new_custom_theme.pack(side=TOP, fill=X, pady=5)
return frame
def CreatePageKeys(self):
@@ -503,20 +505,15 @@ class ConfigDialog(Toplevel):
def VarChanged_builtinTheme(self, *params):
value = self.builtinTheme.get()
if value == 'IDLE Dark':
- tkMessageBox.showwarning(
- title="The 'IDLE Dark' Text Color Theme",
- message="IDLE Dark is new in October, 2015. Trying to "
- "run earlier versions of IDLE with it selected "
- "will disable colorizing, or worse.\n\n"
- "If you might ever run an earlier release of IDLE, "
- "then before exiting this version, "
- "either switch to another theme or "
- "hit the 'Save as New Custom Theme' button. "
- "The latter requires a new name, such as "
- "'Custom Dark', but the custom theme will work "
- "with any IDLE release, and can be modified.",
- parent=self)
- self.AddChangedItem('main', 'Theme', 'name', value)
+ if idleConf.GetOption('main', 'Theme', 'name') != 'IDLE New':
+ self.AddChangedItem('main', 'Theme', 'name', 'IDLE Classic')
+ self.AddChangedItem('main', 'Theme', 'name2', value)
+ self.new_custom_theme.config(text='New theme, see Help',
+ fg='#500000')
+ else:
+ self.AddChangedItem('main', 'Theme', 'name', value)
+ self.AddChangedItem('main', 'Theme', 'name2', '')
+ self.new_custom_theme.config(text='', fg='black')
self.PaintThemeSample()
def VarChanged_customTheme(self, *params):
@@ -1350,14 +1347,14 @@ help_common = '''\
When you click either the Apply or Ok buttons, settings in this
dialog that are different from IDLE's default are saved in
a .idlerc directory in your home directory. Except as noted,
-hese changes apply to all versions of IDLE installed on this
+these changes apply to all versions of IDLE installed on this
machine. Some do not take affect until IDLE is restarted.
[Cancel] only cancels changes made since the last save.
'''
help_pages = {
'Highlighting':'''
Highlighting:
-The IDLE Dark color theme is new in Octover 2015. It can only
+The IDLE Dark color theme is new in October 2015. It can only
be used with older IDLE releases if it is saved as a custom
theme, with a different name.
'''
diff --git a/Lib/idlelib/configHandler.py b/Lib/idlelib/configHandler.py
index 83abad7847..336d96973e 100644
--- a/Lib/idlelib/configHandler.py
+++ b/Lib/idlelib/configHandler.py
@@ -372,8 +372,32 @@ class IdleConf:
return theme
def CurrentTheme(self):
- "Return the name of the currently active theme."
- return self.GetOption('main', 'Theme', 'name', default='')
+ """Return the name of the currently active text color theme.
+
+ idlelib.config-main.def includes this section
+ [Theme]
+ default= 1
+ name= IDLE Classic
+ name2=
+ # name2 set in user config-main.cfg for themes added after 2015 Oct 1
+
+ Item name2 is needed because setting name to a new builtin
+ causes older IDLEs to display multiple error messages or quit.
+ See https://bugs.python.org/issue25313.
+ When default = True, name2 takes precedence over name,
+ while older IDLEs will just use name.
+ """
+ default = self.GetOption('main', 'Theme', 'default',
+ type='bool', default=True)
+ if default:
+ theme = self.GetOption('main', 'Theme', 'name2', default='')
+ if default and not theme or not default:
+ theme = self.GetOption('main', 'Theme', 'name', default='')
+ source = self.defaultCfg if default else self.userCfg
+ if source['highlight'].has_section(theme):
+ return theme
+ else:
+ return "IDLE Classic"
def CurrentKeys(self):
"Return the name of the currently active key set."