def _highlight(line_no, color): block = self.document().findBlockByLineNumber(line_no) highlight = QTextEdit.ExtraSelection() highlight.cursor = QTextCursor(block) highlight.format.setProperty(QTextFormat.FullWidthSelection, True) highlight.format.setBackground(color) return highlight
def highlightCurrentLine(self): extraSelections = [] if not self.isReadOnly(): selection = QTextEdit.ExtraSelection() lineColor = QColor(Qt.blue).lighter(190) selection.format.setBackground(lineColor) selection.format.setProperty(QTextFormat.FullWidthSelection, True) selection.cursor = self.textCursor() selection.cursor.clearSelection() extraSelections.append(selection) self.setExtraSelections(extraSelections)