further work on new config system;

user defined help items
This commit is contained in:
Steven M. Gava 2002-03-27 02:25:44 +00:00
parent cedd30b030
commit 0c5bc8c951
5 changed files with 56 additions and 26 deletions

View File

@ -98,13 +98,13 @@ class EditorWindow:
self.flist = flist
root = root or flist.root
self.root = root
if flist:
self.vars = flist.vars
self.menubar = Menu(root)
self.top = top = self.Toplevel(root, menu=self.menubar)
#self.top.instanceDict makes flist.inversedict avalable to
#configDialog.py so it can access all EditorWindow instaces
self.top.instanceDict=flist.inversedict
if flist:
self.vars = flist.vars
#self.top.instanceDict makes flist.inversedict avalable to
#configDialog.py so it can access all EditorWindow instaces
self.top.instanceDict=flist.inversedict
self.vbar = vbar = Scrollbar(top, name='vbar')
self.text_frame = text_frame = Frame(top)
self.text = text = Text(text_frame, name='text', padx=5, wrap=None,
@ -213,7 +213,7 @@ class EditorWindow:
if self.extensions.has_key('AutoIndent'):
self.extensions['AutoIndent'].set_indentation_params(
self.ispythonsource(filename))
def set_status_bar(self):
self.status_bar = self.MultiStatusBar(self.top)
self.status_bar.set_label('column', 'Col: ?', side=RIGHT)
@ -253,6 +253,7 @@ class EditorWindow:
menudict[name] = menu = Menu(mbar, name=name)
mbar.add_cascade(label=label, menu=menu, underline=underline)
self.fill_menus()
self.ResetExtraHelpMenu()
def postwindowsmenu(self):
# Only called when Windows menu exists
@ -323,7 +324,10 @@ class EditorWindow:
del fn
def python_docs(self, event=None):
webbrowser.open(self.help_url)
self.display_docs(self.help_url)
def display_docs(self, url):
webbrowser.open(url)
def select_all(self, event=None):
self.text.tag_add("sel", "1.0", "end-1c")
@ -525,6 +529,25 @@ class EditorWindow:
menu.entryconfig(index,accelerator=accel)
#print 'accel now:',accel,'\n'
def ResetExtraHelpMenu(self):
#load or update the Extra Help menu if required
menuList=idleConf.GetAllExtraHelpSourcesList()
helpMenu=self.menudict['help']
cascadeIndex=helpMenu.index(END)-1
if menuList:
if not hasattr(self,'menuExtraHelp'):
self.menuExtraHelp=Menu(self.menubar)
helpMenu.insert_cascade(cascadeIndex,label='Extra Help',
underline=1,menu=self.menuExtraHelp)
self.menuExtraHelp.delete(1,END)
for menuItem in menuList:
self.menuExtraHelp.add_command(label=menuItem[0],
command=lambda:self.display_docs(menuItem[1]))
else: #no extra help items
if hasattr(self,'menuExtraHelp'):
helpMenu.delete(cascadeIndex-1)
del(self.menuExtraHelp)
def saved_change_hook(self):
short = self.short_title()
long = self.long_title()

View File

@ -29,7 +29,7 @@ plain-newline-and-indent=<Control-Key-j>
redo=<Control-Shift-Key-z>
remove-selection=<Key-Escape>
save-copy-of-window-as-file=<Alt-Shift-Key-s>
save-window-as-file=<Alt-Key-s>
save-window-as-file=<Control-Shift-Key-s>
save-window=<Control-Key-s>
select-all=<Alt-Key-a>
toggle-auto-coloring=<Control-Key-slash>

View File

@ -28,8 +28,6 @@
[General]
editor-on-startup= 1
user-help-browser= 0
user-help-browser-command=
[EditorWindow]
width= 80

View File

@ -367,11 +367,13 @@ class ConfigDialog(Toplevel):
width=8,command=self.HelpListItemAdd)
self.buttonHelpListRemove=Button(frameHelpListButtons,text='Remove',
state=DISABLED,width=8,command=self.HelpListItemRemove)
checkHelpBrowser=Checkbutton(frameHelp,variable=self.userHelpBrowser,
onvalue=1,offvalue=0,text='user specified (html) help browser:',
command=self.OnCheckUserHelpBrowser)
self.entryHelpBrowser=Entry(frameHelp,textvariable=self.helpBrowser,
width=40)
# the following is better handled by the BROWSER environment
# variable under unix/linux
#checkHelpBrowser=Checkbutton(frameHelp,variable=self.userHelpBrowser,
# onvalue=1,offvalue=0,text='user specified (html) help browser:',
# command=self.OnCheckUserHelpBrowser)
#self.entryHelpBrowser=Entry(frameHelp,textvariable=self.helpBrowser,
# width=40)
#widget packing
#body
frameRun.pack(side=TOP,padx=5,pady=5,fill=X)
@ -398,8 +400,8 @@ class ConfigDialog(Toplevel):
self.buttonHelpListEdit.pack(side=TOP,anchor=W,pady=5)
self.buttonHelpListAdd.pack(side=TOP,anchor=W)
self.buttonHelpListRemove.pack(side=TOP,anchor=W,pady=5)
checkHelpBrowser.pack(side=TOP,anchor=W,padx=5)
self.entryHelpBrowser.pack(side=TOP,anchor=W,padx=5,pady=5)
#checkHelpBrowser.pack(side=TOP,anchor=W,padx=5)
#self.entryHelpBrowser.pack(side=TOP,anchor=W,padx=5,pady=5)
return frame
def AttachVarCallbacks(self):
@ -870,7 +872,7 @@ class ConfigDialog(Toplevel):
def HelpListItemEdit(self):
itemIndex=self.listHelp.index(ANCHOR)
helpSource=self.userHelpList[itemIndex]
newHelpSource=GetHelpSourceDialog(self,'New Help Source',
newHelpSource=GetHelpSourceDialog(self,'Edit Help Source',
menuItem=helpSource[0],filePath=helpSource[1]).result
if (not newHelpSource) or (newHelpSource==helpSource):
return #no changes
@ -1013,11 +1015,11 @@ class ConfigDialog(Toplevel):
for helpItem in self.userHelpList:
self.listHelp.insert(END,helpItem[0]+' '+helpItem[1])
self.SetHelpListButtonStates()
self.userHelpBrowser.set(idleConf.GetOption('main','General',
'user-help-browser',default=0,type='bool'))
self.helpBrowser.set(idleConf.GetOption('main','General',
'user-help-browser-command',default=''))
self.OnCheckUserHelpBrowser()
#self.userHelpBrowser.set(idleConf.GetOption('main','General',
# 'user-help-browser',default=0,type='bool'))
#self.helpBrowser.set(idleConf.GetOption('main','General',
# 'user-help-browser-command',default=''))
#self.OnCheckUserHelpBrowser()
def LoadConfigs(self):
"""
@ -1070,9 +1072,12 @@ class ConfigDialog(Toplevel):
"""
save all configuration changes to user config files.
"""
if self.changedItems['main'].has_key('HelpFiles'):
#this section gets completely replaced
idleConf.userCfg['main'].remove_section('HelpFiles')
#if self.changedItems['main'].has_key('HelpFiles'):
#this section gets completely replaced
print idleConf.GetAllExtraHelpSourcesList()
idleConf.userCfg['main'].remove_section('HelpFiles')
idleConf.userCfg['main'].Save()
print idleConf.GetAllExtraHelpSourcesList()
for configType in self.changedItems.keys():
cfgTypeHasChanges=0
for section in self.changedItems[configType].keys():
@ -1081,6 +1086,7 @@ class ConfigDialog(Toplevel):
if self.SetUserValue(configType,section,item,value):
cfgTypeHasChanges=1
if cfgTypeHasChanges:
print configType,'- changed'
idleConf.userCfg[configType].Save()
self.ResetChangedItems() #clear the changed items dict
@ -1097,6 +1103,7 @@ class ConfigDialog(Toplevel):
instance.ResetColorizer()
instance.ResetFont()
instance.ResetKeybindings()
instance.ResetExtraHelpMenu()
def Cancel(self):
self.destroy()

View File

@ -22,6 +22,8 @@ class GetHelpSourceDialog(Toplevel):
self.parent = parent
self.result=None
self.CreateWidgets()
self.menu.set(menuItem)
self.path.set(filePath)
self.withdraw() #hide while setting geometry
self.update_idletasks()
#needs to be done here so that the winfo_reqwidth is valid