def highlightCurrentLine(self): self.extraSelections[0] = [] if not self.isReadOnly(): selection = QTextEdit.ExtraSelection() # lineColor = QColor(38, 38, 38) selection.format.setBackground(lineColor) selection.format.setProperty(QTextFormat.FullWidthSelection, True) selection.cursor = self.textCursor() selection.cursor.clearSelection() self.extraSelections[0].append(selection) if self.errorPos is not None: errorSel = QPlainTextEdit.ExtraSelection() lineColor = QColor(Qt.red).lighter(160) errorSel.format.setBackground(lineColor) errorSel.format.setProperty(QTextFormat.FullWidthSelection, True) errorSel.cursor = QTextCursor(self.document()) errorSel.cursor.setPosition(self.errorPos) errorSel.cursor.clearSelection() self.extraSelections[0].append(errorSel) extra = self.extraSelections[0] + self.extraSelections[1] self.setExtraSelections(extra)