summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven M. Gava <elguavas@python.net>2002-02-18 01:43:11 (GMT)
committerSteven M. Gava <elguavas@python.net>2002-02-18 01:43:11 (GMT)
commit4974575609ebee40c08d81e98493750b7199b1e6 (patch)
treeebf9154ccab4771f50ad090c29d35b26f7403879
parent6354386d6568e83e0c81c745e79223b570673fe7 (diff)
downloadcpython-4974575609ebee40c08d81e98493750b7199b1e6.zip
cpython-4974575609ebee40c08d81e98493750b7199b1e6.tar.gz
cpython-4974575609ebee40c08d81e98493750b7199b1e6.tar.bz2
handle user theme and key set deletion
-rw-r--r--Lib/idlelib/config-keys.def2
-rw-r--r--Lib/idlelib/configDialog.py86
-rw-r--r--Lib/idlelib/configHandler.py10
3 files changed, 87 insertions, 11 deletions
diff --git a/Lib/idlelib/config-keys.def b/Lib/idlelib/config-keys.def
index 6e3b8f3..4fd2322 100644
--- a/Lib/idlelib/config-keys.def
+++ b/Lib/idlelib/config-keys.def
@@ -10,7 +10,7 @@
[IDLE Classic Windows]
copy=<Control-Key-c>
cut=<Control-Key-x>
-paste=<Control-Key-v>
+paste=<Control-Key-m>
beginning-of-line= <Key-Home>
center-insert=<Control-Key-l>
close-all-windows=<Control-Key-q>
diff --git a/Lib/idlelib/configDialog.py b/Lib/idlelib/configDialog.py
index 025bf81..aaec2f7 100644
--- a/Lib/idlelib/configDialog.py
+++ b/Lib/idlelib/configDialog.py
@@ -226,7 +226,8 @@ class ConfigDialog(Toplevel):
self.builtinTheme,None,command=None)
self.optMenuThemeCustom=DynOptionMenu(frameTheme,
self.customTheme,None,command=None)
- self.buttonDeleteCustomTheme=Button(frameTheme,text='Delete Custom Theme')
+ self.buttonDeleteCustomTheme=Button(frameTheme,text='Delete Custom Theme',
+ command=self.DeleteCustomTheme)
##widget packing
#body
frameCustom.pack(side=LEFT,padx=5,pady=10,expand=TRUE,fill=BOTH)
@@ -293,7 +294,8 @@ class ConfigDialog(Toplevel):
self.builtinKeys,None,command=None)
self.optMenuKeysCustom=DynOptionMenu(frameKeySets,
self.customKeys,None,command=None)
- self.buttonDeleteCustomKeys=Button(frameKeySets,text='Delete Custom Key Set')
+ self.buttonDeleteCustomKeys=Button(frameKeySets,text='Delete Custom Key Set',
+ command=self.DeleteCustomKeys)
##widget packing
#body
frameCustom.pack(side=LEFT,padx=5,pady=5,expand=TRUE,fill=BOTH)
@@ -456,8 +458,9 @@ class ConfigDialog(Toplevel):
def VarChanged_customTheme(self,*params):
value=self.customTheme.get()
- self.AddChangedItem('main','Theme','name',value)
- self.PaintThemeSample()
+ if value != '- no custom themes -':
+ self.AddChangedItem('main','Theme','name',value)
+ self.PaintThemeSample()
def VarChanged_themeIsBuiltin(self,*params):
value=self.themeIsBuiltin.get()
@@ -486,8 +489,9 @@ class ConfigDialog(Toplevel):
def VarChanged_customKeys(self,*params):
value=self.customKeys.get()
- self.AddChangedItem('main','Keys','name',value)
- self.LoadKeysList(value)
+ if value != '- no custom keys -':
+ self.AddChangedItem('main','Keys','name',value)
+ self.LoadKeysList(value)
def VarChanged_keysAreBuiltin(self,*params):
value=self.keysAreBuiltin.get()
@@ -594,7 +598,8 @@ class ConfigDialog(Toplevel):
self.listBindings.select_anchor(listIndex)
def GetNewKeysName(self,message):
- usedNames=idleConf.GetSectionList('user','keys')
+ usedNames=(idleConf.GetSectionList('user','keys')+
+ idleConf.GetSectionList('default','keys'))
newKeySet=GetCfgSectionNameDialog(self,'New Custom Key Set',
message,usedNames).result
return newKeySet
@@ -657,6 +662,58 @@ class ConfigDialog(Toplevel):
self.listBindings.select_set(listIndex)
self.listBindings.select_anchor(listIndex)
+ def DeleteCustomKeys(self):
+ keySetName=self.customKeys.get()
+ if not tkMessageBox.askyesno('Delete Key Set','Are you sure you wish '+
+ 'to delete the key set '+`keySetName`+' ?'):
+ return
+ #remove key set from config
+ idleConf.userCfg['keys'].remove_section(keySetName)
+ if self.changedItems['keys'].has_key(keySetName):
+ del(self.changedItems['keys'][keySetName])
+ #write changes
+ idleConf.userCfg['keys'].Save()
+ #reload user key set list
+ itemList=idleConf.GetSectionList('user','keys')
+ itemList.sort()
+ if not itemList:
+ self.radioKeysCustom.config(state=DISABLED)
+ self.optMenuKeysCustom.SetMenu(itemList,'- no custom keys -')
+ else:
+ self.optMenuKeysCustom.SetMenu(itemList,itemList[0])
+ #revert to default key set
+ self.keysAreBuiltin.set(idleConf.defaultCfg['main'].Get('Keys','default'))
+ self.builtinKeys.set(idleConf.defaultCfg['main'].Get('Keys','name'))
+ #user can't back out of these changes, they must be applied now
+ self.Apply()
+ self.SetKeysType()
+
+ def DeleteCustomTheme(self):
+ themeName=self.customTheme.get()
+ if not tkMessageBox.askyesno('Delete Theme','Are you sure you wish '+
+ 'to delete the theme '+`themeName`+' ?'):
+ return
+ #remove theme from config
+ idleConf.userCfg['highlight'].remove_section(themeName)
+ if self.changedItems['highlight'].has_key(themeName):
+ del(self.changedItems['highlight'][themeName])
+ #write changes
+ idleConf.userCfg['highlight'].Save()
+ #reload user theme list
+ itemList=idleConf.GetSectionList('user','highlight')
+ itemList.sort()
+ if not itemList:
+ self.radioThemeCustom.config(state=DISABLED)
+ self.optMenuThemeCustom.SetMenu(itemList,'- no custom themes -')
+ else:
+ self.optMenuThemeCustom.SetMenu(itemList,itemList[0])
+ #revert to default theme
+ self.themeIsBuiltin.set(idleConf.defaultCfg['main'].Get('Theme','default'))
+ self.builtinTheme.set(idleConf.defaultCfg['main'].Get('Theme','name'))
+ #user can't back out of these changes, they must be applied now
+ self.Apply()
+ self.SetThemeType()
+
def GetColour(self):
target=self.highlightTarget.get()
prevColour=self.frameColourSet.cget('bg')
@@ -689,7 +746,8 @@ class ConfigDialog(Toplevel):
self.AddChangedItem('highlight',theme,themeElement,newColour)
def GetNewThemeName(self,message):
- usedNames=idleConf.GetSectionList('user','highlight')
+ usedNames=(idleConf.GetSectionList('user','highlight')+
+ idleConf.GetSectionList('default','highlight'))
newTheme=GetCfgSectionNameDialog(self,'New Custom Theme',
message,usedNames).result
return newTheme
@@ -1025,6 +1083,17 @@ class ConfigDialog(Toplevel):
idleConf.userCfg[configType].Save()
self.ResetChangedItems() #clear the changed items dict
+ def ActivateConfigChanges(self):
+ #things that need to be done to make
+ #applied config changes dynamic:
+ #
+ #update editor/shell font and repaint
+ #dynamically update indentation setttings
+ #update theme and repaint
+ #update keybindings and re-bind
+ #update user help sources menu
+ pass
+
def Cancel(self):
self.destroy()
@@ -1034,6 +1103,7 @@ class ConfigDialog(Toplevel):
def Apply(self):
self.SaveAllChangedConfigs()
+ self.ActivateConfigChanges()
def Help(self):
pass
diff --git a/Lib/idlelib/configHandler.py b/Lib/idlelib/configHandler.py
index 958ac83..9db7120 100644
--- a/Lib/idlelib/configHandler.py
+++ b/Lib/idlelib/configHandler.py
@@ -518,10 +518,16 @@ class IdleConf:
if keySetName:
for event in keyBindings.keys():
binding=self.GetKeyBinding(keySetName,event)
- if binding: #otherwise will keep default
+ if binding:
keyBindings[event]=binding
+ else: #we are going to return a default, print warning
+ warning=('\n Warning: configHandler.py - IdleConf.GetCoreKeys'+
+ ' -\n problem retrieving key binding for event '+
+ `event`+'\n from key set '+`keySetName`+'.\n'+
+ ' returning default value: '+`keyBindings[event]`+'\n')
+ sys.stderr.write(warning)
return keyBindings
-
+
def GetExtraHelpSourceList(self,configSet):
"""
Returns a list of tuples containing the details of any additional