import os, sys, string
from ConfigParser import ConfigParser, NoOptionError, NoSectionError
+class InvalidConfigType(Exception): pass
+class InvalidConfigSet(Exception): pass
+class InvalidFgBg(Exception): pass
+class InvalidTheme(Exception): pass
+
class IdleConfParser(ConfigParser):
"""
A ConfigParser specialised for idle configuration file handling
configType must be one of ('main','extensions','highlight','keys')
"""
if not (configType in ('main','extensions','highlight','keys')):
- raise 'Invalid configType specified'
+ raise InvalidConfigType, 'Invalid configType specified'
if configSet == 'user':
cfgParser=self.userCfg[configType]
elif configSet == 'default':
cfgParser=self.defaultCfg[configType]
else:
- raise 'Invalid configSet specified'
+ raise InvalidConfigSet, 'Invalid configSet specified'
return cfgParser.sections()
def GetHighlight(self, theme, element, fgBg=None):
if fgBg == 'bg':
return highlight["background"]
else:
- raise 'Invalid fgBg specified'
+ raise InvalidFgBg, 'Invalid fgBg specified'
def GetThemeDict(self,type,themeName):
"""
elif type == 'default':
cfgParser=self.defaultCfg['highlight']
else:
- raise 'Invalid theme type specified'
+ raise InvalidTheme, 'Invalid theme type specified'
#foreground and background values are provded for each theme element
#(apart from cursor) even though all these values are not yet used
#by idle, to allow for their use in the future. Default values are
elif configSet=='default':
cfgParser=self.defaultCfg['main']
else:
- raise 'Invalid configSet specified'
+ raise InvalidConfigSet, 'Invalid configSet specified'
options=cfgParser.GetOptionList('HelpFiles')
for option in options:
value=cfgParser.Get('HelpFiles',option,default=';')
from Tkinter import *
+class InvalidTabPage(Exception): pass
+class AlreadyExists(Exception): pass
+
class PageTab(Frame):
"""
a 'page tab' like framed button
if pageName in self.pages.keys():
self.activePage.set(pageName)
else:
- raise 'Invalid TabPage Name'
+ raise InvalidTabPage, 'Invalid TabPage Name'
## pop up the active 'tab' only
for page in self.pages.keys():
self.pages[page]['tab'].config(relief=RIDGE)
def AddPage(self,pageName):
if pageName in self.pages.keys():
- raise 'TabPage Name Already Exists'
+ raise AlreadyExists, 'TabPage Name Already Exists'
self.pages[pageName]={'tab':PageTab(self.tabBar),
'page':Frame(self,borderwidth=2,relief=RAISED)}
self.pages[pageName]['tab'].button.config(text=pageName,
def RemovePage(self,pageName):
if not pageName in self.pages.keys():
- raise 'Invalid TabPage Name'
+ raise InvalidTabPage, 'Invalid TabPage Name'
self.pages[pageName]['tab'].pack_forget()
self.pages[pageName]['page'].grid_forget()
self.pages[pageName]['tab'].destroy()