def open(self, event=None): """ Creates a new tab with the editor containing the code from a file selected by the user. """ filters = 'Python files (*.py);;Lua files (*.lua);;Lisp files (*.lisp);;JSON files (*.json);;All files (*.*)' path, filter = QtWidgets.QFileDialog.getOpenFileName( self, directory=self.last_dir, filter=filters, initialFilter=self.last_selected_filter) if not path: return self.last_selected_filter = filter self.last_dir = dirname(path) try: self.add(HtmlEditor.from_file(path)) except Exception as e: print(traceback.format_exc()) title = 'Error opening {}'.format(path) text = 'Exception encountered while opening {}:\n\n{}.\n\nThe full traceback has been printed to stdout.'.format( path, e) QtWidgets.QMessageBox.critical(self, title, text)
def open(self, event=None): """ Creates a new tab with the editor containing the code from a file selected by the user. """ filters = 'Python files (*.py);;Lua files (*.lua);;Lisp files (*.lisp);;JSON files (*.json);;All files (*.*)'; path, filter = QtWidgets.QFileDialog.getOpenFileName(self, directory=self.last_dir, filter=filters, initialFilter=self.last_selected_filter) if not path: return self.last_selected_filter = filter self.last_dir = dirname(path) try: self.add(HtmlEditor.from_file(path)) except Exception as e: print(traceback.format_exc()) title = 'Error opening {}'.format(path) text = 'Exception encountered while opening {}:\n\n{}.\n\nThe full traceback has been printed to stdout.'.format(path, e) QtWidgets.QMessageBox.critical(self, title, text)