Skip to content

Commit 955ec62

Browse files
committed
owdistancematrix: Specify foreground when overriding background
1 parent 18658e7 commit 955ec62

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Orange/widgets/unsupervised/owdistancematrix.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def dimension(self, parent=None):
6868

6969
def color_for_label(self, ind, light=100):
7070
if self.label_colors is None:
71-
return Qt.lightGray
71+
return None
7272
return QBrush(self.label_colors[ind].lighter(light))
7373

7474
def color_for_cell(self, row, col):
@@ -92,6 +92,8 @@ def data(self, index, role=Qt.DisplayRole):
9292
return float(self.distances[row, col])
9393
if role == Qt.BackgroundColorRole:
9494
return self.color_for_cell(row, col)
95+
if role == Qt.ForegroundRole:
96+
return QColor(Qt.black) # the background is light-ish
9597

9698
def headerData(self, ind, orientation, role):
9799
if not self.labels:
@@ -101,6 +103,8 @@ def headerData(self, ind, orientation, role):
101103
# On some systems, Qt doesn't respect the following role in the header
102104
if role == Qt.BackgroundRole:
103105
return self.color_for_label(ind, 150)
106+
if role == Qt.ForegroundRole and self.label_colors is not None:
107+
return QColor(Qt.black)
104108

105109

106110
class TableBorderItem(FixedFormatNumericColumnDelegate):
@@ -193,7 +197,7 @@ def __init__(self):
193197
view.setWordWrap(False)
194198
view.setTextElideMode(Qt.ElideNone)
195199
view.setEditTriggers(QTableView.NoEditTriggers)
196-
view.setItemDelegate(TableBorderItem(roles=(Qt.DisplayRole, Qt.BackgroundRole)))
200+
view.setItemDelegate(TableBorderItem(roles=(Qt.DisplayRole, Qt.BackgroundRole, Qt.ForegroundRole)))
197201
view.setModel(self.tablemodel)
198202
view.setShowGrid(False)
199203
for header in (view.horizontalHeader(), view.verticalHeader()):

0 commit comments

Comments
 (0)