def data(self, index, role): if not index.isValid(): return None elif role == QtCore.Qt.ToolTipRole: row, col = index.row(), index.column() peak = self.peak_list[row][0] return str(self.parent.rings[self.parent.refine.rp[peak]]) elif role == QtCore.Qt.DisplayRole: row, col = index.row(), index.column() value = self.peak_list[row][col] if col < 4: return str(value) elif col == 6: return "%5.3g" % value elif col == 10: return "%.3f" % value else: return "%.2f" % value elif role == QtCore.Qt.TextAlignmentRole: return int(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) elif role == QtCore.Qt.BackgroundRole: row, col = index.row(), index.column() peak = self.peak_list[row][0] if peak == self.parent.refine.primary or \ peak == self.parent.refine.secondary: return QtGui.QColor(QtCore.Qt.lightGray) elif self.peak_list[row][10] > self.parent.refine.hkl_tolerance: return QtGui.QColor(QtCore.Qt.red) else: return None return None
def hex2QColor(c): r=int(c[0:2],16) g=int(c[2:4],16) b=int(c[4:6],16) return QtGui.QColor(r,g,b)