summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven M. Gava <elguavas@python.net>2002-03-27 02:25:44 (GMT)
committerSteven M. Gava <elguavas@python.net>2002-03-27 02:25:44 (GMT)
commit0c5bc8c9518fd18d41aedede536c4a9aa8dfa619 (patch)
treeecf20b73397fa392cedc107c0c0b2c25b1379e9f
parentcedd30b030d8424e5f4de9f5fa2fdf14a3a702b7 (diff)
downloadcpython-0c5bc8c9518fd18d41aedede536c4a9aa8dfa619.zip
cpython-0c5bc8c9518fd18d41aedede536c4a9aa8dfa619.tar.gz
cpython-0c5bc8c9518fd18d41aedede536c4a9aa8dfa619.tar.bz2
further work on new config system;
user defined help items
-rw-r--r--Lib/idlelib/EditorWindow.py37
-rw-r--r--Lib/idlelib/config-keys.def2
-rw-r--r--Lib/idlelib/config-main.def2
-rw-r--r--Lib/idlelib/configDialog.py39
-rw-r--r--Lib/idlelib/configHelpSourceEdit.py2
5 files changed, 56 insertions, 26 deletions
diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py
index 49f9869..c2ee115b 100644
--- a/Lib/idlelib/EditorWindow.py
+++ b/Lib/idlelib/EditorWindow.py
@@ -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()
diff --git a/Lib/idlelib/config-keys.def b/Lib/idlelib/config-keys.def
index 4fd2322..8b38827 100644
--- a/Lib/idlelib/config-keys.def
+++ b/Lib/idlelib/config-keys.def
@@ -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>
diff --git a/Lib/idlelib/config-main.def b/Lib/idlelib/config-main.def
index 9cd58fb..01f0662 100644
--- a/Lib/idlelib/config-main.def
+++ b/Lib/idlelib/config-main.def
@@ -28,8 +28,6 @@
[General]
editor-on-startup= 1
-user-help-browser= 0
-user-help-browser-command=
[EditorWindow]
width= 80
diff --git a/Lib/idlelib/configDialog.py b/Lib/idlelib/configDialog.py
index bff86d9..978cbf1 100644
--- a/Lib/idlelib/configDialog.py
+++ b/Lib/idlelib/configDialog.py
@@ -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()
diff --git a/Lib/idlelib/configHelpSourceEdit.py b/Lib/idlelib/configHelpSourceEdit.py
index f593214..6ad7d51 100644
--- a/Lib/idlelib/configHelpSourceEdit.py
+++ b/Lib/idlelib/configHelpSourceEdit.py
@@ -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