Esempio n. 1
0
 def paint(self, painter, option, index):
     value = index.model().data(index, Qt.EditRole)
     try:
         number = float(value)        
         painter.drawText(option.rect, Qt.AlignCenter, "{:.{}f}".format(number, self.nDecimals))
     except :
         QItemDelegate.paint(self, painter, option, index)            
Esempio n. 2
0
 def paint(self, painter, option, index):
     value = index.data(QtCore.Qt.DisplayRole)
     style = QApplication.style()
     opt = QStyleOptionComboBox()
     opt.text = str(value)
     opt.rect = option.rect
     style.drawComplexControl(QStyle.CC_ComboBox, opt, painter)
     QItemDelegate.paint(self, painter, option, index)
Esempio n. 3
0
    def paint(self, painter, option, index):

        if index.column() != 0:
            QItemDelegate.paint(self, painter, option, index)
            return

        painter.fillRect(option.rect, option.palette.brush(QPalette.Base))
        painter.setPen(QPen(option.palette.color(QPalette.Text)))
        painter.drawText(option.rect.adjusted(4, 4, -4, -4),
                         Qt.TextShowMnemonic | Qt.AlignLeft | Qt.AlignVCenter,
                         str(index.data()))
Esempio n. 4
0
 def paint(self, painter, option, index):
     option.palette.setColor(
         QPalette.Highlight,
         QColor(index.data(Qt.BackgroundRole)).darker(107))
     option.palette.setColor(
         QPalette.HighlightedText,
         QColor(index.data(Qt.ForegroundRole)).darker(115))
     QItemDelegate.paint(self, painter, option, index)
     if option.showDecorationSelected and \
             (option.state & QStyle.State_Selected):
         painter.drawRect(option.rect)
Esempio n. 5
0
 def paint(self, painter, option, index):
     # Only run the standard delegate if flag is true.
     # else don't paint anything.
     flag = True
     # Only shade the deltas which are in col 0.
     if index.column() == 0:
         # Grab the delta value.
         delta = index.model().data(index, Qt.EditRole)
         if delta == ".":
             flag = True
         elif self.style == 2:
             # mark up - shade negative, or if goes past max mark
             if int(delta
                    ) < 0 or int(delta) + self.currentMark > self.maxMark:
                 flag = False
         elif self.style == 3:
             # mark down - shade positive, or if goes below 0
             if int(delta) > 0 or int(delta) + self.currentMark < 0:
                 flag = False
         elif self.style == 1:
             # mark-total - do not show deltas.
             flag = False
     if flag:
         QItemDelegate.paint(self, painter, option, index)
Esempio n. 6
0
 def paint(self, *args, **kwargs):
     column = args[2].column()
     value = args[2].data()
     if column == 2:
         progressBarOption = QStyleOptionProgressBar()
         progressBarOption.rect = args[1].rect
         progressBarOption.minimum = 0
         progressBarOption.maximum = 100
         if isinstance(value, int):
             progressBarOption.progress = int(value)
             progressBarOption.text = "{0}%".format(int(value))
         progressBarOption.textVisible = True
         QtWidgets.QApplication.style().drawControl(QStyle.CE_ProgressBar,
                                                    progressBarOption,
                                                    args[0], None)
         return
     return QItemDelegate.paint(self, *args, **kwargs)
Esempio n. 7
0
 def paint(self, painter, option, index):
     option.displayAlignment = Qt.AlignCenter
     QItemDelegate.paint(self, painter, option, index)