def launch_help(self, helpname, filename): """Generic help launcher Launches HTMLWindow that shows content of filename or the Internet page with the filename url Parameters ---------- filename: String \thtml file or url """ # Set up window position = config["help_window_position"] size = config["help_window_size"] self.help_window = wx.Frame(self.main_window, -1, helpname, position, size) self.help_htmlwindow = wx.html.HtmlWindow(self.help_window, -1, (0, 0), size) self.help_window.Bind(wx.EVT_MOVE, self.OnHelpMove) self.help_window.Bind(wx.EVT_SIZE, self.OnHelpSize) self.help_htmlwindow.Bind(wx.EVT_RIGHT_DOWN, self.OnHelpBack) self.help_htmlwindow.Bind(wx.html.EVT_HTML_LINK_CLICKED, lambda e: self.open_external_links(e)) self.help_htmlwindow.Bind(wx.EVT_MOUSEWHEEL, lambda e: self.zoom_html(e)) # Get help data current_path = os.getcwd() os.chdir(get_help_path()) try: if os.path.isfile(filename): self.help_htmlwindow.LoadFile(filename) else: self.help_htmlwindow.LoadPage(filename) except IOError: self.help_htmlwindow.LoadPage(filename) # Show tutorial window self.help_window.Show() os.chdir(current_path)
def launch_help(self, helpname, filename): """Generic help launcher Launches HTMLWindow that shows content of filename or the Internet page with the filename url Parameters ---------- filename: String \thtml file or url """ # Set up window position = config["help_window_position"] size = config["help_window_size"] help_window = wx.Frame(self.main_window, -1, helpname, position, size) help_htmlwindow = wx.html.HtmlWindow(help_window, -1, (0, 0), size) help_window.Bind(wx.EVT_MOVE, self.OnHelpMove) help_window.Bind(wx.EVT_SIZE, self.OnHelpSize) # Get help data current_path = os.getcwd() os.chdir(get_help_path()) try: help_file = open(filename, "r") help_html = help_file.read() help_file.close() help_htmlwindow.SetPage(help_html) except IOError: help_htmlwindow.LoadPage(filename) # Show tutorial window help_window.Show() os.chdir(current_path)