diff --git a/Orange/widgets/unsupervised/owdistancematrix.py b/Orange/widgets/unsupervised/owdistancematrix.py index b2ef89beca2..7032c2631e1 100644 --- a/Orange/widgets/unsupervised/owdistancematrix.py +++ b/Orange/widgets/unsupervised/owdistancematrix.py @@ -68,7 +68,7 @@ def dimension(self, parent=None): def color_for_label(self, ind, light=100): if self.label_colors is None: - return Qt.lightGray + return None return QBrush(self.label_colors[ind].lighter(light)) def color_for_cell(self, row, col): @@ -79,7 +79,7 @@ def data(self, index, role=Qt.DisplayRole): return Qt.AlignRight | Qt.AlignVCenter row, col = index.row(), index.column() if self.distances is None: - return + return None if role == TableBorderItem.BorderColorRole: return self.color_for_label(col), self.color_for_label(row) if role == FixedFormatNumericColumnDelegate.ColumnDataSpanRole: @@ -92,15 +92,21 @@ def data(self, index, role=Qt.DisplayRole): return float(self.distances[row, col]) if role == Qt.BackgroundColorRole: return self.color_for_cell(row, col) + if role == Qt.ForegroundRole: + return QColor(Qt.black) # the background is light-ish + return None def headerData(self, ind, orientation, role): if not self.labels: - return + return None if role == Qt.DisplayRole and ind < len(self.labels): return self.labels[ind] # On some systems, Qt doesn't respect the following role in the header if role == Qt.BackgroundRole: return self.color_for_label(ind, 150) + if role == Qt.ForegroundRole and self.label_colors is not None: + return QColor(Qt.black) + return None class TableBorderItem(FixedFormatNumericColumnDelegate): @@ -193,7 +199,9 @@ def __init__(self): view.setWordWrap(False) view.setTextElideMode(Qt.ElideNone) view.setEditTriggers(QTableView.NoEditTriggers) - view.setItemDelegate(TableBorderItem(roles=(Qt.DisplayRole, Qt.BackgroundRole))) + view.setItemDelegate( + TableBorderItem( + roles=(Qt.DisplayRole, Qt.BackgroundRole, Qt.ForegroundRole))) view.setModel(self.tablemodel) view.setShowGrid(False) for header in (view.horizontalHeader(), view.verticalHeader()):