def sizeHint(self, option, index): item = self.parent().item(index.row()) doc = QTextDocument() # highlight = syntax.PythonHighlighter(doc, is_dark = not item.has_script) font = QFont("Courier") font.setFamily("Courier"); font.setStyleHint(QFont.Monospace); font.setFixedPitch(True); font.setPointSize(self.parent().font().pointSize()); doc.setDefaultFont(font) # tab_stop = 4; # 4 characters # metrics = QFontMetrics(font) text = index.data(Qt.EditRole) text = text.replace("\t", ''.join([' '] * 4)) # print ":".join("{:02x}".format(ord(c)) for c in text) doc.setPlainText(text) doc.setDefaultStyleSheet("background-color: red;") return QSize(doc.size().width(), doc.size().height())
def sizeHint(self, option, index): item = self.parent().item(index.row()) doc = QTextDocument() font = QFont("Courier") font.setFamily("Courier"); font.setStyleHint(QFont.Monospace); font.setFixedPitch(True); font.setPointSize(self.parent().font().pointSize()); doc.setDefaultFont(font) text = index.data(Qt.EditRole) text = text.replace("\t", ''.join([' '] * 4)) doc.setPlainText(text) doc.setDefaultStyleSheet("background-color: red;") return QSize(doc.size().width(), doc.size().height())
def paint(self, painter, option, index): is_dark = True item = self.parent().item(index.row()) if item.faulty: pen = QPen(QColor(255, 117, 117), 3) painter.setPen(pen) painter.drawRect(option.rect) elif item == self.parent().currentItem(): pen = QPen(Qt.white, 3) painter.setPen(pen) painter.drawRect(option.rect) if not item.has_script: painter.fillRect(option.rect, QColor(153, 153, 153)) else: painter.fillRect(option.rect, Qt.white) is_dark = False doc = QTextDocument() highlight = syntax.PythonHighlighter(doc, is_dark = is_dark) font = QFont("Courier") font.setFamily("Courier"); font.setStyleHint(QFont.Monospace); font.setFixedPitch(True); font.setPointSize(self.parent().font().pointSize()) doc.setDefaultFont(font) text = index.data(Qt.EditRole) text = text.replace("\t", ''.join([' '] * 4)) doc.setPlainText(text) doc.setDefaultStyleSheet("background-color: red;") painter.translate(option.rect.topLeft()) doc.drawContents(painter) painter.resetTransform()
def paint(self, painter, option, index): item = self.parent().item(index.row()) # print option.backgroundBrush.color().name() is_dark = True if item.faulty: pen = QPen(QColor(255, 117, 117), 3) painter.setPen(pen) painter.drawRect(option.rect) elif item == self.parent().currentItem(): pen = QPen(Qt.white, 3) painter.setPen(pen) painter.drawRect(option.rect) if not item.has_script: painter.fillRect(option.rect, QColor(153, 153, 153)) else: painter.fillRect(option.rect, Qt.white) is_dark = False # color = item.background().color() # painter.fillRect(option.rect, color) # print dir(option) # return doc = QTextDocument() highlight = syntax.PythonHighlighter(doc, is_dark = is_dark) font = QFont("Courier") font.setFamily("Courier"); font.setStyleHint(QFont.Monospace); font.setFixedPitch(True); font.setPointSize(self.parent().font().pointSize()) doc.setDefaultFont(font) # tab_stop = 4; # 4 characters # metrics = QFontMetrics(font) text = index.data(Qt.EditRole) text = text.replace("\t", ''.join([' '] * 4)) # print ":".join("{:02x}".format(ord(c)) for c in text) doc.setPlainText(text) doc.setDefaultStyleSheet("background-color: red;") painter.translate(option.rect.topLeft()) doc.drawContents(painter) painter.resetTransform() pass