def _text_format(self, foreground=Qt.black, weight=QFont.Normal): fmt = QTextCharFormat() fmt.setForeground(QBrush(foreground)) fmt.setFontWeight(weight) return fmt