summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/configDialog.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/idlelib/configDialog.py')
-rw-r--r--Lib/idlelib/configDialog.py105
1 files changed, 47 insertions, 58 deletions
diff --git a/Lib/idlelib/configDialog.py b/Lib/idlelib/configDialog.py
index b707fc3..1f4a3a5 100644
--- a/Lib/idlelib/configDialog.py
+++ b/Lib/idlelib/configDialog.py
@@ -9,9 +9,11 @@ Note that tab width in IDLE is currently fixed at eight due to Tk issues.
Refer to comments in EditorWindow autoindent code for details.
"""
-from Tkinter import *
-import tkMessageBox, tkColorChooser, tkFont
-import string
+from tkinter import *
+import tkinter.messagebox as tkMessageBox
+import tkinter.colorchooser as tkColorChooser
+import tkinter.font as tkFont
+import copy
from idlelib.configHandler import idleConf
from idlelib.dynOptionMenuWidget import DynOptionMenu
@@ -71,25 +73,27 @@ class ConfigDialog(Toplevel):
page_names=['Fonts/Tabs','Highlighting','Keys','General'])
frameActionButtons = Frame(self,pady=2)
#action buttons
+
if macosxSupport.runningAsOSXApp():
- # Changing the default padding on OSX results in unreadable
- # text in the buttons
- paddingArgs={}
+ # Surpress the padx and pady arguments when
+ # running as IDLE.app, otherwise the text
+ # on these buttons will not be readable.
+ extraKwds={}
else:
- paddingArgs={'padx':6, 'pady':3}
+ extraKwds=dict(padx=6, pady=3)
self.buttonHelp = Button(frameActionButtons,text='Help',
command=self.Help,takefocus=FALSE,
- **paddingArgs)
+ **extraKwds)
self.buttonOk = Button(frameActionButtons,text='Ok',
command=self.Ok,takefocus=FALSE,
- **paddingArgs)
+ **extraKwds)
self.buttonApply = Button(frameActionButtons,text='Apply',
command=self.Apply,takefocus=FALSE,
- **paddingArgs)
+ **extraKwds)
self.buttonCancel = Button(frameActionButtons,text='Cancel',
command=self.Cancel,takefocus=FALSE,
- **paddingArgs)
+ **extraKwds)
self.CreatePageFontTab()
self.CreatePageHighlight()
self.CreatePageKeys()
@@ -195,13 +199,13 @@ class ConfigDialog(Toplevel):
("'string'",'string'),('\n var1 = ','normal'),("'selected'",'hilite'),
('\n var2 = ','normal'),("'found'",'hit'),
('\n var3 = ','normal'),('list', 'builtin'), ('(','normal'),
- ('None', 'builtin'),(')\n\n','normal'),
+ ('None', 'keyword'),(')\n\n','normal'),
(' error ','error'),(' ','normal'),('cursor |','cursor'),
('\n ','normal'),('shell','console'),(' ','normal'),('stdout','stdout'),
(' ','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))
@@ -343,7 +347,6 @@ class ConfigDialog(Toplevel):
text=' Autosave Preferences ')
frameWinSize=Frame(frame,borderwidth=2,relief=GROOVE)
frameParaSize=Frame(frame,borderwidth=2,relief=GROOVE)
- frameEncoding=Frame(frame,borderwidth=2,relief=GROOVE)
frameHelp=LabelFrame(frame,borderwidth=2,relief=GROOVE,
text=' Additional Help Sources ')
#frameRun
@@ -372,14 +375,6 @@ class ConfigDialog(Toplevel):
' width (in characters)')
entryParaWidth=Entry(frameParaSize,textvariable=self.paraWidth,
width=3)
- #frameEncoding
- labelEncodingTitle=Label(frameEncoding,text="Default Source Encoding")
- radioEncLocale=Radiobutton(frameEncoding,variable=self.encoding,
- value="locale",text="Locale-defined")
- radioEncUTF8=Radiobutton(frameEncoding,variable=self.encoding,
- value="utf-8",text="UTF-8")
- radioEncNone=Radiobutton(frameEncoding,variable=self.encoding,
- value="none",text="None")
#frameHelp
frameHelpList=Frame(frameHelp)
frameHelpListButtons=Frame(frameHelpList)
@@ -401,7 +396,6 @@ class ConfigDialog(Toplevel):
frameSave.pack(side=TOP,padx=5,pady=5,fill=X)
frameWinSize.pack(side=TOP,padx=5,pady=5,fill=X)
frameParaSize.pack(side=TOP,padx=5,pady=5,fill=X)
- frameEncoding.pack(side=TOP,padx=5,pady=5,fill=X)
frameHelp.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=BOTH)
#frameRun
labelRunChoiceTitle.pack(side=LEFT,anchor=W,padx=5,pady=5)
@@ -420,11 +414,6 @@ class ConfigDialog(Toplevel):
#paragraphFormatWidth
labelParaWidthTitle.pack(side=LEFT,anchor=W,padx=5,pady=5)
entryParaWidth.pack(side=RIGHT,anchor=E,padx=10,pady=5)
- #frameEncoding
- labelEncodingTitle.pack(side=LEFT,anchor=W,padx=5,pady=5)
- radioEncNone.pack(side=RIGHT,anchor=E,pady=5)
- radioEncUTF8.pack(side=RIGHT,anchor=E,pady=5)
- radioEncLocale.pack(side=RIGHT,anchor=E,pady=5)
#frameHelp
frameHelpListButtons.pack(side=RIGHT,padx=5,pady=5,fill=Y)
frameHelpList.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=BOTH)
@@ -568,7 +557,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]={}
@@ -609,11 +598,11 @@ 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()
+ currentKeySequences = list(currentBindings.values())
newKeys=GetKeysDialog(self,'Get New Keys',bindName,
currentKeySequences).result
if newKeys: #new keys were specified
@@ -660,14 +649,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)
@@ -685,15 +674,15 @@ class ConfigDialog(Toplevel):
reselect=1
listIndex=self.listBindings.index(ANCHOR)
keySet=idleConf.GetKeySet(keySetName)
- bindNames=keySet.keys()
+ bindNames = list(keySet.keys())
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:
@@ -808,9 +797,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)
@@ -863,14 +852,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']
@@ -927,7 +916,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
@@ -936,7 +925,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]
@@ -946,13 +935,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()
@@ -989,7 +978,7 @@ class ConfigDialog(Toplevel):
self.optMenuThemeBuiltin.SetMenu(itemList,itemList[0])
self.SetThemeType()
##load theme element option menu
- themeNames=self.themeElements.keys()
+ themeNames = list(self.themeElements.keys())
themeNames.sort(key=lambda x: self.themeElements[x][1])
self.optMenuHighlightTarget.SetMenu(themeNames,themeNames[0])
self.PaintThemeSample()
@@ -1072,7 +1061,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)
@@ -1084,7 +1073,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)
@@ -1099,14 +1088,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
@@ -1120,13 +1109,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.keys()
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()