@@ -68,7 +68,7 @@ def dimension(self, parent=None):
68
68
69
69
def color_for_label (self , ind , light = 100 ):
70
70
if self .label_colors is None :
71
- return Qt . lightGray
71
+ return None
72
72
return QBrush (self .label_colors [ind ].lighter (light ))
73
73
74
74
def color_for_cell (self , row , col ):
@@ -92,6 +92,8 @@ def data(self, index, role=Qt.DisplayRole):
92
92
return float (self .distances [row , col ])
93
93
if role == Qt .BackgroundColorRole :
94
94
return self .color_for_cell (row , col )
95
+ if role == Qt .ForegroundRole :
96
+ return QColor (Qt .black ) # the background is light-ish
95
97
96
98
def headerData (self , ind , orientation , role ):
97
99
if not self .labels :
@@ -101,6 +103,8 @@ def headerData(self, ind, orientation, role):
101
103
# On some systems, Qt doesn't respect the following role in the header
102
104
if role == Qt .BackgroundRole :
103
105
return self .color_for_label (ind , 150 )
106
+ if role == Qt .ForegroundRole and self .label_colors is not None :
107
+ return QColor (Qt .black )
104
108
105
109
106
110
class TableBorderItem (FixedFormatNumericColumnDelegate ):
@@ -193,7 +197,7 @@ def __init__(self):
193
197
view .setWordWrap (False )
194
198
view .setTextElideMode (Qt .ElideNone )
195
199
view .setEditTriggers (QTableView .NoEditTriggers )
196
- view .setItemDelegate (TableBorderItem (roles = (Qt .DisplayRole , Qt .BackgroundRole )))
200
+ view .setItemDelegate (TableBorderItem (roles = (Qt .DisplayRole , Qt .BackgroundRole , Qt . ForegroundRole )))
197
201
view .setModel (self .tablemodel )
198
202
view .setShowGrid (False )
199
203
for header in (view .horizontalHeader (), view .verticalHeader ()):
0 commit comments