[Idle-dev] CVS: idle configDialog.py,1.25,1.26 configHandler.py,1.12,1.13 config-main.def,1.6,1.7
Stephen M. Gava
elguavas@users.sourceforge.net
Sun, 20 Jan 2002 22:38:23 -0800
Update of /cvsroot/idlefork/idle
In directory usw-pr-cvs1:/tmp/cvs-serv13988
Modified Files:
configDialog.py configHandler.py config-main.def
Log Message:
extension config reading by configDialog and
beginning of configuration saving
Index: configDialog.py
===================================================================
RCS file: /cvsroot/idlefork/idle/configDialog.py,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -r1.25 -r1.26
*** configDialog.py 2002/01/19 10:33:21 1.25
--- configDialog.py 2002/01/21 06:38:21 1.26
***************
*** 37,40 ****
--- 37,50 ----
'Shell Stdout Text':('stdout','10'),
'Shell Stderr Text':('stderr','11')}
+ #changedItems. When any config item is changed in this dialog, an entry
+ #should be made in the relevant section (config type) of this
+ #dictionary. The key should be the config file section name and the
+ #value a dictionary, whose key:value pairs are item=value pairs for
+ #that config file section.
+ self.changedItems={'main':{},'highlight':{},'keys':{},'extensions':{}}
+ #defaultItems. This dictionary is loaded with the values from the
+ #default config files. It is used for comparison with self.changedItems
+ #to decide which changed items actually need saving.
+ self.defaultItems=self.GetDefaultItems()
self.CreateWidgets()
self.resizable(height=FALSE,width=FALSE)
***************
*** 45,142 ****
self.tabPages.focus_set()
#key bindings for this dialog
! self.bind('<Escape>',self.CancelBinding) #dismiss dialog, no save
! self.bind('<Alt-a>',self.ApplyBinding) #apply changes, save
! self.bind('<F1>',self.HelpBinding) #context help
self.LoadConfigs()
self.wait_window()
- def Cancel(self):
- self.destroy()
-
- def Ok(self):
- pass
-
- def Apply(self):
- pass
-
- def Help(self):
- pass
-
- def CancelBinding(self,event):
- self.Cancel()
-
- def OkBinding(self,event):
- self.Ok()
-
- def ApplyBinding(self,event):
- self.Apply()
-
- def HelpBinding(self,event):
- self.Help()
-
- def SetThemeType(self):
- if self.themeIsBuiltin.get():
- self.optMenuThemeBuiltin.config(state=NORMAL)
- self.optMenuThemeCustom.config(state=DISABLED)
- self.buttonDeleteCustomTheme.config(state=DISABLED)
- else:
- self.optMenuThemeBuiltin.config(state=DISABLED)
- self.optMenuThemeCustom.config(state=NORMAL)
- self.buttonDeleteCustomTheme.config(state=NORMAL)
-
- def SetKeysType(self):
- if self.keysAreDefault.get():
- self.optMenuKeysBuiltin.config(state=NORMAL)
- self.optMenuKeysCustom.config(state=DISABLED)
- self.buttonDeleteCustomKeys.config(state=DISABLED)
- else:
- self.optMenuKeysBuiltin.config(state=DISABLED)
- self.optMenuKeysCustom.config(state=NORMAL)
- self.buttonDeleteCustomKeys.config(state=NORMAL)
-
- def GetColour(self):
- target=self.highlightTarget.get()
- rgbTuplet, colourString = tkColorChooser.askcolor(parent=self,
- title='Pick new colour for : '+target,
- initialcolor=self.frameColourSet.cget('bg'))
- if colourString: #user didn't cancel
- self.frameColourSet.config(bg=colourString)#set sample
- if self.fgHilite.get(): plane='foreground'
- else: plane='background'
- apply(self.textHighlightSample.tag_config,
- (self.themeElements[target][0],),{plane:colourString})
-
- def SetFontSampleBinding(self,event):
- self.SetFontSample()
-
- def SetFontSample(self):
- self.editFont.config(size=self.fontSize.get(),weight=NORMAL,
- family=self.listFontName.get(self.listFontName.curselection()[0]))
-
- def SetHighlightTargetBinding(self,*args):
- self.SetHighlightTarget()
-
- def SetHighlightTarget(self):
- if self.highlightTarget.get()=='Cursor': #bg not possible
- self.radioFg.config(state=DISABLED)
- self.radioBg.config(state=DISABLED)
- self.fgHilite.set(1)
- else: #both fg and bg can be set
- self.radioFg.config(state=NORMAL)
- self.radioBg.config(state=NORMAL)
- self.fgHilite.set(1)
- self.SetColourSample()
-
- def SetColourSampleBinding(self,*args):
- self.SetColourSample()
-
- def SetColourSample(self):
- #set the colour smaple area
- tag=self.themeElements[self.highlightTarget.get()][0]
- if self.fgHilite.get(): plane='foreground'
- else: plane='background'
- colour=self.textHighlightSample.tag_cget(tag,plane)
- self.frameColourSet.config(bg=colour)
-
def CreateWidgets(self):
self.tabPages = TabPageSet(self,
--- 55,64 ----
self.tabPages.focus_set()
#key bindings for this dialog
! #self.bind('<Escape>',self.Cancel) #dismiss dialog, no save
! #self.bind('<Alt-a>',self.Apply) #apply changes, save
! #self.bind('<F1>',self.Help) #context help
self.LoadConfigs()
self.wait_window()
def CreateWidgets(self):
self.tabPages = TabPageSet(self,
***************
*** 150,154 ****
command=self.Ok,takefocus=FALSE)
self.buttonApply = Button(frameActionButtons,text='Apply',
! command=self.Apply,underline=0,takefocus=FALSE)
self.buttonCancel = Button(frameActionButtons,text='Cancel',
command=self.Cancel,takefocus=FALSE)
--- 72,76 ----
command=self.Ok,takefocus=FALSE)
self.buttonApply = Button(frameActionButtons,text='Apply',
! command=self.Apply,takefocus=FALSE)
self.buttonCancel = Button(frameActionButtons,text='Cancel',
command=self.Cancel,takefocus=FALSE)
***************
*** 163,168 ****
frameActionButtons.pack(side=BOTTOM)
self.tabPages.pack(side=TOP,expand=TRUE,fill=BOTH)
!
!
def CreatePageFontTab(self):
#tkVars
--- 85,89 ----
frameActionButtons.pack(side=BOTTOM)
self.tabPages.pack(side=TOP,expand=TRUE,fill=BOTH)
!
def CreatePageFontTab(self):
#tkVars
***************
*** 362,371 ****
scrollTargetX=Scrollbar(frameTarget,orient=HORIZONTAL)
self.listBindings=Listbox(frameTarget)
scrollTargetY.config(command=self.listBindings.yview)
scrollTargetX.config(command=self.listBindings.xview)
self.listBindings.config(yscrollcommand=scrollTargetY.set)
self.listBindings.config(xscrollcommand=scrollTargetX.set)
! buttonNewKeys=Button(frameCustom,text='Get New Keys for Selection',
! command=self.GetNewKeys)
buttonSaveCustomKeys=Button(frameCustom,text='Save as a Custom Key Set')
#frameKeySets
--- 283,293 ----
scrollTargetX=Scrollbar(frameTarget,orient=HORIZONTAL)
self.listBindings=Listbox(frameTarget)
+ self.listBindings.bind('<ButtonRelease-1>',self.KeyBindingSelected)
scrollTargetY.config(command=self.listBindings.yview)
scrollTargetX.config(command=self.listBindings.xview)
self.listBindings.config(yscrollcommand=scrollTargetY.set)
self.listBindings.config(xscrollcommand=scrollTargetX.set)
! self.buttonNewKeys=Button(frameCustom,text='Get New Keys for Selection',
! command=self.GetNewKeys,state=DISABLED)
buttonSaveCustomKeys=Button(frameCustom,text='Save as a Custom Key Set')
#frameKeySets
***************
*** 388,392 ****
labelCustomTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
buttonSaveCustomKeys.pack(side=BOTTOM,fill=X,padx=5,pady=5)
! buttonNewKeys.pack(side=BOTTOM,fill=X,padx=5,pady=5)
frameTarget.pack(side=LEFT,padx=5,pady=5,expand=TRUE,fill=BOTH)
#frame target
--- 310,314 ----
labelCustomTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
buttonSaveCustomKeys.pack(side=BOTTOM,fill=X,padx=5,pady=5)
! self.buttonNewKeys.pack(side=BOTTOM,fill=X,padx=5,pady=5)
frameTarget.pack(side=LEFT,padx=5,pady=5,expand=TRUE,fill=BOTH)
#frame target
***************
*** 412,416 ****
self.winWidth=StringVar(self)
self.winHeight=StringVar(self)
! self.extState=IntVar(self)
#widget creation
#body
--- 334,338 ----
self.winWidth=StringVar(self)
self.winHeight=StringVar(self)
! self.startupEdit=IntVar(self)
#widget creation
#body
***************
*** 421,432 ****
frameExt=Frame(frame,borderwidth=2,relief=GROOVE)
#frameRun
! labelRunTitle=Label(frameRun,text='Run Preferences')
! labelRunChoiceTitle=Label(frameRun,text='Run code : ')
! radioRunInternal=Radiobutton(frameRun,variable=self.runType,
! value=0,command=self.SetKeysType,text="in IDLE's Process")
! radioRunSeparate=Radiobutton(frameRun,variable=self.runType,
! value=1,command=self.SetKeysType,text='in a Separate Process')
#frameWinSize
! labelWinSizeTitle=Label(frameWinSize,text='Initial Window Size')
labelWinWidthTitle=Label(frameWinSize,text='Width')
entryWinWidth=Entry(frameWinSize,textvariable=self.winWidth,
--- 343,355 ----
frameExt=Frame(frame,borderwidth=2,relief=GROOVE)
#frameRun
! labelRunTitle=Label(frameRun,text='Startup Preferences')
! labelRunChoiceTitle=Label(frameRun,text='On startup : ')
! radioStartupEdit=Radiobutton(frameRun,variable=self.startupEdit,
! value=1,command=self.SetKeysType,text="open Edit Window")
! radioStartupShell=Radiobutton(frameRun,variable=self.startupEdit,
! value=0,command=self.SetKeysType,text='open Shell Window')
#frameWinSize
! labelWinSizeTitle=Label(frameWinSize,text='Initial Window Size'+
! ' (in characters)')
labelWinWidthTitle=Label(frameWinSize,text='Width')
entryWinWidth=Entry(frameWinSize,textvariable=self.winWidth,
***************
*** 441,455 ****
labelExtListTitle=Label(frameExtList,text='Extension')
scrollExtList=Scrollbar(frameExtList)
! listExt=Listbox(frameExtList,height=5)
! scrollExtList.config(command=listExt.yview)
! listExt.config(yscrollcommand=scrollExtList.set)
labelExtSetTitle=Label(frameExtSet,text='Settings')
! radioEnableExt=Radiobutton(frameExtSet,variable=self.extState,
! value=1,text="enable")
! radioDisableExt=Radiobutton(frameExtSet,variable=self.extState,
! value=0,text="disable")
! self.extState.set(1)
! buttonExtConfig=Button(frameExtSet,text='Configure')
!
#widget packing
#body
--- 364,377 ----
labelExtListTitle=Label(frameExtList,text='Extension')
scrollExtList=Scrollbar(frameExtList)
! self.listExt=Listbox(frameExtList,height=5)
! scrollExtList.config(command=self.listExt.yview)
! self.listExt.config(yscrollcommand=scrollExtList.set)
! self.listExt.bind('<ButtonRelease-1>',self.ExtensionSelected)
labelExtSetTitle=Label(frameExtSet,text='Settings')
! self.radioEnableExt=Radiobutton(frameExtSet,variable=self.startupEdit,
! value=1,text="enabled",state=DISABLED)
! self.radioDisableExt=Radiobutton(frameExtSet,variable=self.startupEdit,
! value=0,text="disabled",state=DISABLED)
! self.buttonExtConfig=Button(frameExtSet,text='Configure',state=DISABLED)
#widget packing
#body
***************
*** 460,465 ****
labelRunTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
labelRunChoiceTitle.pack(side=LEFT,anchor=W,padx=5,pady=5)
! radioRunInternal.pack(side=LEFT,anchor=W,padx=5,pady=5)
! radioRunSeparate.pack(side=LEFT,anchor=W,padx=5,pady=5)
#frameWinSize
labelWinSizeTitle.pack(side=LEFT,anchor=W,padx=5,pady=5)
--- 382,387 ----
labelRunTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
labelRunChoiceTitle.pack(side=LEFT,anchor=W,padx=5,pady=5)
! radioStartupEdit.pack(side=LEFT,anchor=W,padx=5,pady=5)
! radioStartupShell.pack(side=LEFT,anchor=W,padx=5,pady=5)
#frameWinSize
labelWinSizeTitle.pack(side=LEFT,anchor=W,padx=5,pady=5)
***************
*** 474,485 ****
labelExtListTitle.pack(side=TOP,anchor=W)
scrollExtList.pack(side=RIGHT,anchor=W,fill=Y)
! listExt.pack(side=LEFT,anchor=E,expand=TRUE,fill=BOTH)
labelExtSetTitle.pack(side=TOP,anchor=W)
! radioEnableExt.pack(side=TOP,anchor=W)
! radioDisableExt.pack(side=TOP,anchor=W)
! buttonExtConfig.pack(side=TOP,anchor=W,pady=5)
!
return frame
def PaintThemeSample(self):
if self.themeIsBuiltin.get(): #a default theme
--- 396,482 ----
labelExtListTitle.pack(side=TOP,anchor=W)
scrollExtList.pack(side=RIGHT,anchor=W,fill=Y)
! self.listExt.pack(side=LEFT,anchor=E,expand=TRUE,fill=BOTH)
labelExtSetTitle.pack(side=TOP,anchor=W)
! self.radioEnableExt.pack(side=TOP,anchor=W)
! self.radioDisableExt.pack(side=TOP,anchor=W)
! self.buttonExtConfig.pack(side=TOP,anchor=W,pady=5)
return frame
+ def GetDefaultItems(self):
+ dItems={'main':{},'highlight':{},'keys':{},'extensions':{}}
+ for configType in dItems.keys():
+ sections=idleConf.GetSectionList('default',configType)
+ for section in sections:
+ dItems[configType][section]={}
+ options=idleConf.defaultCfg[configType].GetOptionList(section)
+ for option in options:
+ dItems[configType][section][option]=(
+ idleConf.defaultCfg[configType].Get(section,option))
+ return dItems
+
+ def SetThemeType(self):
+ if self.themeIsBuiltin.get():
+ self.optMenuThemeBuiltin.config(state=NORMAL)
+ self.optMenuThemeCustom.config(state=DISABLED)
+ self.buttonDeleteCustomTheme.config(state=DISABLED)
+ else:
+ self.optMenuThemeBuiltin.config(state=DISABLED)
+ self.optMenuThemeCustom.config(state=NORMAL)
+ self.buttonDeleteCustomTheme.config(state=NORMAL)
+
+ def SetKeysType(self):
+ if self.keysAreDefault.get():
+ self.optMenuKeysBuiltin.config(state=NORMAL)
+ self.optMenuKeysCustom.config(state=DISABLED)
+ self.buttonDeleteCustomKeys.config(state=DISABLED)
+ else:
+ self.optMenuKeysBuiltin.config(state=DISABLED)
+ self.optMenuKeysCustom.config(state=NORMAL)
+ self.buttonDeleteCustomKeys.config(state=NORMAL)
+
+ def GetColour(self):
+ target=self.highlightTarget.get()
+ rgbTuplet, colourString = tkColorChooser.askcolor(parent=self,
+ title='Pick new colour for : '+target,
+ initialcolor=self.frameColourSet.cget('bg'))
+ if colourString: #user didn't cancel
+ self.frameColourSet.config(bg=colourString)#set sample
+ if self.fgHilite.get(): plane='foreground'
+ else: plane='background'
+ apply(self.textHighlightSample.tag_config,
+ (self.themeElements[target][0],),{plane:colourString})
+
+ def SetFontSampleBinding(self,event):
+ self.SetFontSample()
+
+ def SetFontSample(self):
+ self.editFont.config(size=self.fontSize.get(),weight=NORMAL,
+ family=self.listFontName.get(self.listFontName.curselection()[0]))
+
+ def SetHighlightTargetBinding(self,*args):
+ self.SetHighlightTarget()
+
+ def SetHighlightTarget(self):
+ if self.highlightTarget.get()=='Cursor': #bg not possible
+ self.radioFg.config(state=DISABLED)
+ self.radioBg.config(state=DISABLED)
+ self.fgHilite.set(1)
+ else: #both fg and bg can be set
+ self.radioFg.config(state=NORMAL)
+ self.radioBg.config(state=NORMAL)
+ self.fgHilite.set(1)
+ self.SetColourSample()
+
+ def SetColourSampleBinding(self,*args):
+ self.SetColourSample()
+
+ def SetColourSample(self):
+ #set the colour smaple area
+ tag=self.themeElements[self.highlightTarget.get()][0]
+ if self.fgHilite.get(): plane='foreground'
+ else: plane='background'
+ colour=self.textHighlightSample.tag_cget(tag,plane)
+ self.frameColourSet.config(bg=colour)
+
def PaintThemeSample(self):
if self.themeIsBuiltin.get(): #a default theme
***************
*** 602,612 ****
self.listBindings.insert(listIndex,bindName+' - '+newKeys.result)
self.listBindings.select_set(listIndex)
!
def LoadGeneralCfg(self):
#initial window size
self.winWidth.set(idleConf.GetOption('main','EditorWindow','width'))
self.winHeight.set(idleConf.GetOption('main','EditorWindow','height'))
!
!
def LoadConfigs(self):
"""
--- 599,625 ----
self.listBindings.insert(listIndex,bindName+' - '+newKeys.result)
self.listBindings.select_set(listIndex)
!
! def KeyBindingSelected(self,event):
! self.buttonNewKeys.config(state=NORMAL)
!
def LoadGeneralCfg(self):
+ #startup state
+ self.startupEdit.set(idleConf.GetOption('main','General',
+ 'editor-on-startup',default=1,type='bool'))
#initial window size
self.winWidth.set(idleConf.GetOption('main','EditorWindow','width'))
self.winHeight.set(idleConf.GetOption('main','EditorWindow','height'))
! #extensions
! extns=idleConf.GetExtensions(activeOnly=0)
! apply(self.listExt.insert,(END,)+tuple(extns))
!
! def ExtensionSelected(self,event):
! self.radioEnableExt.config(state=NORMAL)
! self.radioDisableExt.config(state=NORMAL)
! self.buttonExtConfig.config(state=NORMAL)
! extn=self.listExt.get(ANCHOR)
! self.extState.set(idleConf.GetOption('extensions',extn,'enable',
! default=1,type='bool'))
!
def LoadConfigs(self):
"""
***************
*** 629,632 ****
--- 642,670 ----
save configuration changes to user config files.
"""
+ #DEBUG
+ print self.defaultItems
+ print self.changedItems
+ for configType in self.changedItems.keys():
+ for section in self.changedItems[configType].keys():
+ for item in self.changedItems[configType][section].keys():
+ #DEBUG
+ value=self.changedItems[configType][section][item]
+ print configType, section, item, value
+ print self.changedItems
+
+ def AddChangedItem(self,type,section,item,value):
+ self.changedItems[type][section][item]=value
+
+ def Cancel(self):
+ self.destroy()
+
+ def Ok(self):
+ self.Apply()
+ self.destroy()
+
+ def Apply(self):
+ self.SaveConfigs()
+
+ def Help(self):
pass
Index: configHandler.py
===================================================================
RCS file: /cvsroot/idlefork/idle/configHandler.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -r1.12 -r1.13
*** configHandler.py 2002/01/19 10:32:13 1.12
--- configHandler.py 2002/01/21 06:38:21 1.13
***************
*** 24,28 ****
ConfigParser.__init__(self,defaults=cfgDefaults)
! def Get(self, section, option, type=None): #,default=None)
"""
Get an option value for given section/option or return default.
--- 24,28 ----
ConfigParser.__init__(self,defaults=cfgDefaults)
! def Get(self, section, option, type=None):
"""
Get an option value for given section/option or return default.
***************
*** 144,150 ****
the given config type.
configSet must be either 'user' or 'default'
! configType must be one of ('extensions','highlight','keys')
"""
! if not (configType in ('extensions','highlight','keys')):
raise 'Invalid configType specified'
if configSet == 'user':
--- 144,150 ----
the given config type.
configSet must be either 'user' or 'default'
! configType must be one of ('main','extensions','highlight','keys')
"""
! if not (configType in ('main','extensions','highlight','keys')):
raise 'Invalid configType specified'
if configSet == 'user':
***************
*** 225,229 ****
activeExtns=[]
for extn in extns:
! if self.GetOption('extensions',extn,'enable',default=1,type='bool'):
#the extension is enabled
activeExtns.append(extn)
--- 225,230 ----
activeExtns=[]
for extn in extns:
! if self.GetOption('extensions',extn,'enable',default=1,
! type='bool'):
#the extension is enabled
activeExtns.append(extn)
Index: config-main.def
===================================================================
RCS file: /cvsroot/idlefork/idle/config-main.def,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** config-main.def 2002/01/04 07:53:06 1.6
--- config-main.def 2002/01/21 06:38:21 1.7
***************
*** 28,37 ****
[General]
! run-in-separate-process= 1
! help-browser= ""
[HelpFiles]
! idle="IDLE _Help",""
! python="_Python Documentation",""
#additional help sources
1=
--- 28,38 ----
[General]
! editor-on-startup= 1
! #run-in-separate-process= 1
! #help-browser= ""
[HelpFiles]
! #idle="IDLE _Help",""
! #python="_Python Documentation",""
#additional help sources
1=
***************
*** 47,51 ****
[EditorWindow]
- editor-on-startup= 0
width= 80
height= 30
--- 48,51 ----