def SetHelpMenuOtherHelp(mainMenu):
"""Modifies the main Help Menu to handle all registered help files.
mainMenu -- The main menu to modify - usually from docTemplate.GetSharedMenu()
"""
# Load all help files from the registry.
global helpIDMap
if helpIDMap is None:
helpIDMap = {}
cmdID = win32ui.ID_HELP_OTHER
excludeList = ['Main Python Documentation', 'Pythonwin Reference']
firstList = ListAllHelpFiles()
# We actually want to not only exclude these entries, but
# their help file names (as many entries may share the same name)
excludeFnames = []
for desc, fname in firstList:
if desc in excludeList:
excludeFnames.append(fname)
helpDescs = []
for desc, fname in firstList:
if fname not in excludeFnames:
helpIDMap[cmdID] = (desc, fname)
win32ui.GetMainFrame().HookCommand(HandleHelpOtherCommand, cmdID)
cmdID = cmdID + 1
helpMenu = mainMenu.GetSubMenu(mainMenu.GetMenuItemCount()-1) # Help menu always last.
otherHelpMenuPos = 2 # cant search for ID, as sub-menu has no ID.
otherMenu = helpMenu.GetSubMenu(otherHelpMenuPos)
while otherMenu.GetMenuItemCount():
otherMenu.DeleteMenu(0, win32con.MF_BYPOSITION)
if helpIDMap:
for id, (desc, fname) in helpIDMap.items():
otherMenu.AppendMenu(win32con.MF_ENABLED|win32con.MF_STRING,id, desc)
else:
helpMenu.EnableMenuItem(otherHelpMenuPos, win32con.MF_BYPOSITION | win32con.MF_GRAYED)
评论列表
文章目录