1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
NUMMOIS, TOTALCREDITMOIS, TOTALDEBITMOIS, SOLDEMOIS = range(4)
ListeMois = ("janvier", "février","mars", "avril", "mai", "juin", "juillet", "aout", "septembre", "octobre", "novembre", "décembre")
class BilanDelegate(QStyledItemDelegate):
def __init__(self, parent=None):
super(BilanDelegate, self).__init__(parent)
def paint(self, painter, option, index):
painter.save() #sauve le contexte
#afficher " " dans les colonnes credit debit et solde
if index.column() == TOTALCREDITMOIS or index.column() == TOTALDEBITMOIS or index.column() == SOLDEMOIS:
montant = index.model().data(index) #string représentant la somme brute
montant = "{} ".format(montant)
painter.drawText(option.rect, Qt.AlignRight|Qt.AlignVCenter, montant)
elif index.column() == NUMMOIS:
nummois = index.model().data(index)
if nummois >= 1 and nummois <= 12:
mois = ListeMois[nummois - 1]
painter.drawText(option.rect,Qt.AlignVCenter, mois)
painter.restore()
else:
QStyledItemDelegate.paint(self, painter, option, index) |
Partager