summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorTerry Jan Reedy <tjreedy@udel.edu>2014-07-27 08:07:18 (GMT)
committerTerry Jan Reedy <tjreedy@udel.edu>2014-07-27 08:07:18 (GMT)
commit110796fb1588b1ab433f327f84175dffde229df8 (patch)
tree454bb45860a1090b27b3310d0d429bd79a539a2e /Lib
parent87355a77db6fea8d0718701a86632db7ed2e3f14 (diff)
downloadcpython-110796fb1588b1ab433f327f84175dffde229df8.zip
cpython-110796fb1588b1ab433f327f84175dffde229df8.tar.gz
cpython-110796fb1588b1ab433f327f84175dffde229df8.tar.bz2
Reduce unnecessary 2.7 versus 3.4+ differences in idlelib/configDialog.py.
Only change 2.7 version. Remove ".keys()" from "x in y.keys()" (leave .keys() elsewhere alone). Change "string.join" to "' '.join" (and string.join(s, ';') to ';'.join(s)). Change spacing to match 3.4 (will later make spacing changes to both).
Diffstat (limited to 'Lib')
-rw-r--r--Lib/idlelib/configDialog.py57
1 files changed, 28 insertions, 29 deletions
diff --git a/Lib/idlelib/configDialog.py b/Lib/idlelib/configDialog.py
index 449ca0f..db1cea6 100644
--- a/Lib/idlelib/configDialog.py
+++ b/Lib/idlelib/configDialog.py
@@ -11,7 +11,6 @@ Refer to comments in EditorWindow autoindent code for details.
"""
from Tkinter import *
import tkMessageBox, tkColorChooser, tkFont
-import string
from idlelib.configHandler import idleConf
from idlelib.dynOptionMenuWidget import DynOptionMenu
@@ -209,7 +208,7 @@ class ConfigDialog(Toplevel):
(' ','normal'),('stderr','stderr'),('\n','normal'))
for txTa in textAndTags:
text.insert(END,txTa[0],txTa[1])
- for element in self.themeElements.keys():
+ for element in self.themeElements:
text.tag_bind(self.themeElements[element][0],'<ButtonPress-1>',
lambda event,elem=element: event.widget.winfo_toplevel()
.highlightTarget.set(elem))
@@ -576,7 +575,7 @@ class ConfigDialog(Toplevel):
def GetDefaultItems(self):
dItems={'main':{},'highlight':{},'keys':{},'extensions':{}}
- for configType in dItems.keys():
+ for configType in dItems:
sections=idleConf.GetSectionList('default',configType)
for section in sections:
dItems[configType][section]={}
@@ -617,9 +616,9 @@ class ConfigDialog(Toplevel):
else:
currentKeySetName=self.customKeys.get()
currentBindings=idleConf.GetCurrentKeySet()
- if currentKeySetName in self.changedItems['keys'].keys(): #unsaved changes
+ if currentKeySetName in self.changedItems['keys']: #unsaved changes
keySetChanges=self.changedItems['keys'][currentKeySetName]
- for event in keySetChanges.keys():
+ for event in keySetChanges:
currentBindings[event]=keySetChanges[event].split()
currentKeySequences=currentBindings.values()
newKeys=GetKeysDialog(self,'Get New Keys',bindName,
@@ -668,14 +667,14 @@ class ConfigDialog(Toplevel):
prevKeySetName=self.customKeys.get()
prevKeys=idleConf.GetCoreKeys(prevKeySetName)
newKeys={}
- for event in prevKeys.keys(): #add key set to changed items
+ for event in prevKeys: #add key set to changed items
eventName=event[2:-2] #trim off the angle brackets
- binding=string.join(prevKeys[event])
+ binding=' '.join(prevKeys[event])
newKeys[eventName]=binding
#handle any unsaved changes to prev key set
- if prevKeySetName in self.changedItems['keys'].keys():
+ if prevKeySetName in self.changedItems['keys']:
keySetChanges=self.changedItems['keys'][prevKeySetName]
- for event in keySetChanges.keys():
+ for event in keySetChanges:
newKeys[event]=keySetChanges[event]
#save the new theme
self.SaveNewKeySet(newKeySetName,newKeys)
@@ -697,11 +696,11 @@ class ConfigDialog(Toplevel):
bindNames.sort()
self.listBindings.delete(0,END)
for bindName in bindNames:
- key=string.join(keySet[bindName]) #make key(s) into a string
+ key=' '.join(keySet[bindName]) #make key(s) into a string
bindName=bindName[2:-2] #trim off the angle brackets
- if keySetName in self.changedItems['keys'].keys():
+ if keySetName in self.changedItems['keys']:
#handle any unsaved changes to this key set
- if bindName in self.changedItems['keys'][keySetName].keys():
+ if bindName in self.changedItems['keys'][keySetName]:
key=self.changedItems['keys'][keySetName][bindName]
self.listBindings.insert(END, bindName+' - '+key)
if reselect:
@@ -816,9 +815,9 @@ class ConfigDialog(Toplevel):
themeName=self.customTheme.get()
newTheme=idleConf.GetThemeDict(themeType,themeName)
#apply any of the old theme's unsaved changes to the new theme
- if themeName in self.changedItems['highlight'].keys():
+ if themeName in self.changedItems['highlight']:
themeChanges=self.changedItems['highlight'][themeName]
- for element in themeChanges.keys():
+ for element in themeChanges:
newTheme[element]=themeChanges[element]
#save the new theme
self.SaveNewTheme(newThemeName,newTheme)
@@ -871,14 +870,14 @@ class ConfigDialog(Toplevel):
theme=self.builtinTheme.get()
else: #a user theme
theme=self.customTheme.get()
- for elementTitle in self.themeElements.keys():
+ for elementTitle in self.themeElements:
element=self.themeElements[elementTitle][0]
colours=idleConf.GetHighlight(theme,element)
if element=='cursor': #cursor sample needs special painting
colours['background']=idleConf.GetHighlight(theme,
'normal', fgBg='bg')
#handle any unsaved changes to this theme
- if theme in self.changedItems['highlight'].keys():
+ if theme in self.changedItems['highlight']:
themeDict=self.changedItems['highlight'][theme]
if element+'-foreground' in themeDict:
colours['foreground']=themeDict[element+'-foreground']
@@ -935,7 +934,7 @@ class ConfigDialog(Toplevel):
self.changedItems['main']['HelpFiles'] = {}
for num in range(1,len(self.userHelpList)+1):
self.AddChangedItem('main','HelpFiles',str(num),
- string.join(self.userHelpList[num-1][:2],';'))
+ ';'.join(self.userHelpList[num-1][:2]))
def LoadFontCfg(self):
##base editor font selection list
@@ -944,7 +943,7 @@ class ConfigDialog(Toplevel):
for font in fonts:
self.listFontName.insert(END,font)
configuredFont=idleConf.GetOption('main','EditorWindow','font',
- default='courier')
+ default='courier')
lc_configuredFont = configuredFont.lower()
self.fontName.set(lc_configuredFont)
lc_fonts = [s.lower() for s in fonts]
@@ -954,13 +953,13 @@ class ConfigDialog(Toplevel):
self.listFontName.select_set(currentFontIndex)
self.listFontName.select_anchor(currentFontIndex)
##font size dropdown
- fontSize=idleConf.GetOption('main','EditorWindow','font-size',
- type='int', default='10')
+ fontSize=idleConf.GetOption('main', 'EditorWindow', 'font-size',
+ type='int', default='10')
self.optMenuFontSize.SetMenu(('7','8','9','10','11','12','13','14',
- '16','18','20','22'),fontSize )
+ '16','18','20','22'), fontSize )
##fontWeight
self.fontBold.set(idleConf.GetOption('main','EditorWindow',
- 'font-bold',default=0,type='bool'))
+ 'font-bold',default=0,type='bool'))
##font sample
self.SetFontSample()
@@ -1080,7 +1079,7 @@ class ConfigDialog(Toplevel):
"""
if not idleConf.userCfg['keys'].has_section(keySetName):
idleConf.userCfg['keys'].add_section(keySetName)
- for event in keySet.keys():
+ for event in keySet:
value=keySet[event]
idleConf.userCfg['keys'].SetOption(keySetName,event,value)
@@ -1092,7 +1091,7 @@ class ConfigDialog(Toplevel):
"""
if not idleConf.userCfg['highlight'].has_section(themeName):
idleConf.userCfg['highlight'].add_section(themeName)
- for element in theme.keys():
+ for element in theme:
value=theme[element]
idleConf.userCfg['highlight'].SetOption(themeName,element,value)
@@ -1107,14 +1106,14 @@ class ConfigDialog(Toplevel):
def SaveAllChangedConfigs(self):
"Save configuration changes to the user config file."
idleConf.userCfg['main'].Save()
- for configType in self.changedItems.keys():
+ for configType in self.changedItems:
cfgTypeHasChanges = False
- for section in self.changedItems[configType].keys():
+ for section in self.changedItems[configType]:
if section == 'HelpFiles':
#this section gets completely replaced
idleConf.userCfg['main'].remove_section('HelpFiles')
cfgTypeHasChanges = True
- for item in self.changedItems[configType][section].keys():
+ for item in self.changedItems[configType][section]:
value = self.changedItems[configType][section][item]
if self.SetUserValue(configType,section,item,value):
cfgTypeHasChanges = True
@@ -1128,13 +1127,13 @@ class ConfigDialog(Toplevel):
def DeactivateCurrentConfig(self):
#Before a config is saved, some cleanup of current
#config must be done - remove the previous keybindings
- winInstances=self.parent.instance_dict.keys()
+ winInstances=self.parent.instance_dict
for instance in winInstances:
instance.RemoveKeybindings()
def ActivateConfigChanges(self):
"Dynamically apply configuration changes"
- winInstances=self.parent.instance_dict.keys()
+ winInstances = self.parent.instance_dict.keys()
for instance in winInstances:
instance.ResetColorizer()
instance.ResetFont()