def append_new_editor(self, font=None, content=None, filename=None): """ Appends a new editor the tabbed widget :param font: A reference to the font to be used by the editor. If None is given then self.default_font is used :param content: An optional string containing content to be placed into the editor on opening. If None then self.default_content is used :param filename: An optional string containing the filename of the editor if applicable. :return: """ if content is None: content = self.default_content if font is None: font = self.default_font interpreter = PythonFileInterpreter(font, content, filename=filename, parent=self) if self.whitespace_visible: interpreter.set_whitespace_visible() # monitor future modifications interpreter.sig_editor_modified.connect(self.mark_current_tab_modified) interpreter.sig_filename_modified.connect(self.on_filename_modified) tab_title, tab_tooltip = _tab_title_and_toolip(filename) tab_idx = self._tabs.addTab(interpreter, tab_title) self._tabs.setTabToolTip(tab_idx, tab_tooltip) self._tabs.setCurrentIndex(tab_idx) return tab_idx
def append_new_editor(self, font=None, content=None, filename=None): """ Appends a new editor the tabbed widget :param font: A reference to the font to be used by the editor. If None is given then self.default_font is used :param content: An optional string containing content to be placed into the editor on opening. If None then self.default_content is used :param filename: An optional string containing the filename of the editor if applicable. :return: """ if content is None: content = self.default_content if font is None: font = self.default_font if self.editor_count > 0: # If there are other tabs open the same zoom level # as these is used. current_zoom = self._tabs.widget(0).editor.getZoom() else: # Otherwise the zoom level of the last tab closed is used # Or the default (0) if this is the very first tab current_zoom = self.zoom_level interpreter = PythonFileInterpreter( font, content, filename=filename, parent=self, completion_enabled=self.completion_enabled) interpreter.editor.zoomTo(current_zoom) if self.whitespace_visible: interpreter.set_whitespace_visible() # monitor future modifications interpreter.sig_editor_modified.connect(self.mark_current_tab_modified) interpreter.sig_filename_modified.connect(self.on_filename_modified) interpreter.editor.textZoomedIn.connect(self.zoom_in_all_tabs) interpreter.editor.textZoomedOut.connect(self.zoom_out_all_tabs) tab_title, tab_tooltip = self._tab_title_and_tooltip(filename) tab_idx = self._tabs.addTab(interpreter, tab_title) self._tabs.setTabToolTip(tab_idx, tab_tooltip) self._tabs.setCurrentIndex(tab_idx) # set the cursor to the last line and give the new editor focus interpreter.editor.setFocus() if content is not None: line_count = content.count(linesep) interpreter.editor.setCursorPosition(line_count, 0) return tab_idx
def append_new_editor(self, content=None, filename=None): if content is None: content = self.default_content interpreter = PythonFileInterpreter(content, filename=filename, parent=self._tabs) if self.whitespace_visible: interpreter.set_whitespace_visible() # monitor future modifications interpreter.sig_editor_modified.connect(self.mark_current_tab_modified) interpreter.sig_filename_modified.connect(self.on_filename_modified) tab_title, tab_tooltip = _tab_title_and_toolip(filename) tab_idx = self._tabs.addTab(interpreter, tab_title) self._tabs.setTabToolTip(tab_idx, tab_tooltip) self._tabs.setCurrentIndex(tab_idx) return tab_idx