def OpenHelpFile(fileName, helpCmd=None, helpArg=None): "Open a help file, given a full path" # default help arg. win32ui.DoWaitCursor(1) try: if helpCmd is None: helpCmd = win32con.HELP_CONTENTS ext = os.path.splitext(fileName)[1].lower() if ext == ".hlp": win32api.WinHelp(win32ui.GetMainFrame().GetSafeHwnd(), fileName, helpCmd, helpArg) # XXX - using the htmlhelp API wreaks havoc with keyboard shortcuts # so we disable it, forcing ShellExecute, which works fine (but # doesn't close the help file when Pythonwin is closed. # Tom Heller also points out http://www.microsoft.com/mind/0499/faq/faq0499.asp, # which may or may not be related. elif 0 and ext == ".chm": import win32help global htmlhelp_handle helpCmd = html_help_command_translators.get(helpCmd, helpCmd) #frame = win32ui.GetMainFrame().GetSafeHwnd() frame = 0 # Dont want it overlapping ours! if htmlhelp_handle is None: htmlhelp_hwnd, htmlhelp_handle = win32help.HtmlHelp( frame, None, win32help.HH_INITIALIZE) win32help.HtmlHelp(frame, fileName, helpCmd, helpArg) else: # Hope that the extension is registered, and we know what to do! win32api.ShellExecute(0, "open", fileName, None, "", win32con.SW_SHOW) return fileName finally: win32ui.DoWaitCursor(-1)
def Launch_CHM(CHM, keyword=''): if sys.platform == 'win32': import win32help Win32_Viewer = 0 win32help.HtmlHelp(Win32_Viewer, str(CHM), win32help.HH_DISPLAY_INDEX, str(keyword)) else: import subprocess subprocess.Popen("gnome-open " + CHM, shell=True)
def FinalizeHelp(): global htmlhelp_handle if htmlhelp_handle is not None: import win32help try: #frame = win32ui.GetMainFrame().GetSafeHwnd() frame = 0 win32help.HtmlHelp(frame, None, win32help.HH_UNINITIALIZE, htmlhelp_handle) except win32help.error: print "Failed to finalize htmlhelp!" htmlhelp_handle = None