[Idle-dev] CVS: idle config-main.def,1.1,1.2 configDialog.py,1.10,1.11 configHandler.py,1.1,1.2

Stephen M. Gava elguavas@users.sourceforge.net
Tue, 23 Oct 2001 03:42:14 -0700


Update of /cvsroot/idlefork/idle
In directory usw-pr-cvs1:/tmp/cvs-serv29303

Modified Files:
	config-main.def configDialog.py configHandler.py 
Log Message:
font/tabs  config dialog page now reads its data from the config file


Index: config-main.def
===================================================================
RCS file: /cvsroot/idlefork/idle/config-main.def,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** config-main.def	2001/09/24 09:43:17	1.1
--- config-main.def	2001/10/23 10:42:12	1.2
***************
*** 18,22 ****
  #     ~/.idlerc/idle-highlight.cfg       the user highlighting config file
  #     ~/.idlerc/idle-keys.cfg            the user keybinding config file
- # XXX what about Windows?
  #
  # Any options the user saves through the config dialog will be saved to
--- 18,21 ----
***************
*** 30,35 ****
--- 29,51 ----
  [General]
  run-in-separate-process= 1
+ help-browser= ""
  
+ [HelpFiles]
+ idle="IDLE _Help",""
+ python="_Python Documentation",""
+ #additional help sources
+ 1=
+ 2=
+ 3=
+ 4=
+ 5=
+ 6=
+ 7=
+ 8=
+ 9=
+ 10=
+ 
  [EditorWindow]
+ editor-on-startup= 0
  width= 80
  height= 24

Index: configDialog.py
===================================================================
RCS file: /cvsroot/idlefork/idle/configDialog.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** configDialog.py	2001/09/24 09:43:17	1.10
--- configDialog.py	2001/10/23 10:42:12	1.11
***************
*** 44,47 ****
--- 44,50 ----
          self.bind('<Alt-g>',self.ChangePageBinding)
          #self.LoadOptMenuHighlightTarget()
+         
+         self.LoadConfigs()
+         
          self.wait_window()
          
***************
*** 122,127 ****
              self.labelTestSample.update()
  
!     def SetFontSample(self,event):
!         self.newFont.config(size=self.fontSize.get(),weight=NORMAL,
              family=self.listFontName.get(self.listFontName.curselection()[0]))
      
--- 125,133 ----
              self.labelTestSample.update()
  
!     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]))
      
***************
*** 180,184 ****
          self.tabCols=IntVar()
          self.indentType=IntVar() 
!         self.newFont=tkFont.Font(self,('courier',12,'normal'))
          ##widget creation
          #body frame
--- 186,190 ----
          self.tabCols=IntVar()
          self.indentType=IntVar() 
!         self.editFont=tkFont.Font(self,('courier',12,'normal'))
          ##widget creation
          #body frame
***************
*** 195,201 ****
          self.listFontName=Listbox(frameFontName,height=5,takefocus=FALSE,
                  exportselection=FALSE)
!         self.listFontName.bind('<<ListboxSelect>>',self.SetFontSample)
          scrollFont=Scrollbar(frameFontName)
!         self.LoadFontList()
          scrollFont.config(command=self.listFontName.yview)
          self.listFontName.config(yscrollcommand=scrollFont.set)
--- 201,207 ----
          self.listFontName=Listbox(frameFontName,height=5,takefocus=FALSE,
                  exportselection=FALSE)
!         self.listFontName.bind('<<ListboxSelect>>',self.SetFontSampleBinding)
          scrollFont=Scrollbar(frameFontName)
!         #self.LoadFontList()
          scrollFont.config(command=self.listFontName.yview)
          self.listFontName.config(yscrollcommand=scrollFont.set)
***************
*** 203,207 ****
          sizes=('10','11','12','13','14','16','18','20','22')
          args=(frameFontSize,self.fontSize)+sizes
!         keyArgs={'command':self.SetFontSample}
          optFontSize=apply(OptionMenu,args,keyArgs)
          #optFontSize.bind('<<MenuSelect>>',self.SetFontSample)
--- 209,213 ----
          sizes=('10','11','12','13','14','16','18','20','22')
          args=(frameFontSize,self.fontSize)+sizes
!         keyArgs={'command':self.SetFontSampleBinding}
          optFontSize=apply(OptionMenu,args,keyArgs)
          #optFontSize.bind('<<MenuSelect>>',self.SetFontSample)
***************
*** 209,213 ****
          self.labelFontSample=Label(frameFontSample,
                  text='AaBbCcDdEe\nFfGgHhIiJjK\n1234567890\n#:+=(){}[]',
!                 justify=LEFT,font=self.newFont)
          #frameIndent
          labelIndentTitle=Label(frameIndent,text='Set Indentation Defaults')
--- 215,219 ----
          self.labelFontSample=Label(frameFontSample,
                  text='AaBbCcDdEe\nFfGgHhIiJjK\n1234567890\n#:+=(){}[]',
!                 justify=LEFT,font=self.editFont)
          #frameIndent
          labelIndentTitle=Label(frameIndent,text='Set Indentation Defaults')
***************
*** 217,223 ****
                  text='Choose indentation type :')
          radioUseSpaces=Radiobutton(frameIndentType,variable=self.indentType,
!             value=0,text='Tab key inserts spaces')
          radioUseTabs=Radiobutton(frameIndentType,variable=self.indentType,
!             value=1,text='Tab key inserts tabs')
          labelIndentSizeTitle=Label(frameIndentSize,
                  text='Choose indentation size :')
--- 223,229 ----
                  text='Choose indentation type :')
          radioUseSpaces=Radiobutton(frameIndentType,variable=self.indentType,
!             value=1,text='Tab key inserts spaces')
          radioUseTabs=Radiobutton(frameIndentType,variable=self.indentType,
!             value=0,text='Tab key inserts tabs')
          labelIndentSizeTitle=Label(frameIndentSize,
                  text='Choose indentation size :')
***************
*** 504,517 ****
          return frame
  
!     def LoadFontList(self):
          fonts=list(tkFont.families(self))
          fonts.sort()
          for font in fonts:
              self.listFontName.insert(END,font)
!         currentFontIndex=fonts.index('courier')
!         self.listFontName.see(currentFontIndex)
!         self.listFontName.select_set(currentFontIndex)
!         self.fontSize.set('12')
      
      #def LoadOptionMenu(self, optMenu, optList, optVar, optVal=None, 
      #            command=None):
--- 510,544 ----
          return frame
  
!     def LoadFontCfg(self):
!         ##base editor font selection list
          fonts=list(tkFont.families(self))
          fonts.sort()
          for font in fonts:
              self.listFontName.insert(END,font)
!         configuredFont=idleConf.GetDefault('main','EditorWindow','font',
!                 default='courier')
!         if configuredFont in fonts:
!             currentFontIndex=fonts.index(configuredFont)
!             self.listFontName.see(currentFontIndex)
!             self.listFontName.select_set(currentFontIndex)
!         ##font size dropdown
!         fontSize=idleConf.GetDefault('main','EditorWindow','font-size',default='12')
!         self.fontSize.set(fontSize)
!         ##font sample 
!         self.SetFontSample()
      
+     def LoadTabCfg(self):
+         ##indent type radibuttons
+         spaceIndent=idleConf.GetDefault('main','Indent','use-spaces',
+                 default=1,type='bool')
+         self.indentType.set(spaceIndent)
+         ##indent sizes
+         spaceNum=idleConf.GetDefault('main','Indent','num-spaces',
+                 default=4,type='int')
+         tabCols=idleConf.GetDefault('main','Indent','tab-cols',
+                 default=4,type='int')
+         self.spaceNum.set(spaceNum)
+         self.tabCols.set(tabCols)
+     
      #def LoadOptionMenu(self, optMenu, optList, optVar, optVal=None, 
      #            command=None):
***************
*** 563,567 ****
--- 590,610 ----
              optVar.set(optList[0])
  
+     def LoadConfigs(self):
+         """
+         load configuration from default and user config files and populate
+         the widgets on the config dialog pages.
+         """
+         ### fonts / tabs page
+         self.LoadFontCfg()        
+         self.LoadTabCfg()        
+         ### highlighting page
+         ### keys page
+         ### help page
+         ### general page
+         
      def SaveConfigs(self):
+         """
+         save configuration changes to user config files.
+         """
          pass
  

Index: configHandler.py
===================================================================
RCS file: /cvsroot/idlefork/idle/configHandler.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** configHandler.py	2001/09/24 09:43:17	1.1
--- configHandler.py	2001/10/23 10:42:12	1.2
***************
*** 22,48 ****
          ConfigParser.__init__(self,defaults=cfgDefaults)
      
!     def GetInt(self, section, option):
!         """
!         Get an option value as an integer
!         """
!         return self.Get(section, option, type='int')
! 
!     def GetBool(self, section, option):
!         """
!         Get an option value as a boolean
!         """
!         return self.Get(section, option, type='bool')
          
!     def Get(self, section, option, raw=0, vars=None, default=None, 
!             type=None):
          """
          Get an option value for given section/option or return default.
          If type is specified, return as type.
          """
!         if type=='bool': getVal=self.getbool
          elif type=='int': getVal=self.getint
          else: getVal=self.get
          if self.has_option(section,option):
!             return getVal(section, option, raw, vars)
          else:
              return default
--- 22,50 ----
          ConfigParser.__init__(self,defaults=cfgDefaults)
      
! #     def GetInt(self, section, option, *kw):
! #         """
! #         Get an option value as an integer
! #         """
! #         return self.Get(section, option, type='int', *kw)
! # 
! #     def GetBool(self, section, option, **kw):
! #         """
! #         Get an option value as a boolean
! #         """
! #         return self.Get(section, option, type='bool', *kw)
          
! #    def Get(self, section, option, raw=0, vars=None, default=None, 
! #            type=None):
!     def Get(self, section, option, default=None, type=None):
          """
          Get an option value for given section/option or return default.
          If type is specified, return as type.
          """
!         if type=='bool': getVal=self.getboolean
          elif type=='int': getVal=self.getint
          else: getVal=self.get
          if self.has_option(section,option):
!             #return getVal(section, option, raw, vars)
!             return getVal(section, option)
          else:
              return default
***************
*** 136,139 ****
--- 138,158 ----
              self.defaultCfg[cfgType]=IdleConfParser(defCfgFiles[cfgType])
              self.userCfg[cfgType]=IdleUserConfParser(usrCfgFiles[cfgType])
+     
+     def GetDefault(self, configType, section, option, default=None, type=None):
+         """
+         Get an option value for given config type and given general 
+         configuration section/option or return a default. If type is specified,
+         return as type. Firstly the user configuration is checked, with a 
+         fallback to the default configuration, and a final 'catch all' 
+         fallback to a useable passed-in default if the option isn't present in 
+         either the user or the default configuration.
+         configType must be one of ('main','extensions','highlight','keys')
+         """
+         if self.userCfg[configType].has_option(section,option):
+             return self.userCfg[configType].Get(section, option, type=type)
+         elif self.defaultCfg[configType].has_option(section,option):
+             return self.defaultCfg[configType].Get(section, option, type=type)
+         else:
+             return default
      
      def LoadCfgFiles(self):