Issue #25313: Change the handling of new built-in text color themes to better

address the compatibility problem introduced by the addition of IDLE Dark.
Consistently use the revised idleConf.CurrentTheme everywhere in idlelib.
This commit is contained in:
Terry Jan Reedy 2015-11-12 15:02:57 -05:00
parent 84023247b4
commit d0c0f0041c
8 changed files with 48 additions and 25 deletions

View file

@ -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."