Esempio n. 1
0
 def cellColor(self, index):
     r = index.row()
     c = index.column()
     color_name = self.interface.get_cell_color(r, c)
     color = QColor()
     color.setNamedColor(color_name)
     return color
Esempio n. 2
0
 def data(self, index, role):
     if not index.isValid():
         return
     if role == Qt.BackgroundRole:
         r = index.row()
         c = index.column()
         color_name = self.interface.get_cell_color(r, c)
         color = QColor()
         color.setNamedColor(color_name)
         return color
     elif role in (Qt.DisplayRole, Qt.EditRole):
         r = index.row()
         c = index.column()
         return self.interface._get_data(r, c)
    def data(self, index, role=Qt.DisplayRole):
        # Do nothing if the dataframe is empty
        if not index.isValid() or not (0 <= index.row() < len(self._data)):
            return None

        if role == Qt.DisplayRole:
            r = index.row()
            c = self._columns[index.column()]
            v = self._data.at[r, c]
            return str(v)
        elif role == Qt.TextAlignmentRole:
            return int(Qt.AlignRight | Qt.AlignVCenter)
        elif role == Qt.BackgroundRole:
            if self._cell_color is not None:
                r = index.row()
                c = self._columns[index.column()]
                name = self._cell_color(r, c)
                color = QColor()
                color.setNamedColor(name)
                return color
    def data(self, index, role=Qt.DisplayRole):
        # Do nothing if the dataframe is empty
        if not index.isValid() or not (0 <= index.row() < len(self._data)):
            return None

        if role == Qt.DisplayRole:
            r = index.row()
            c = self._columns[index.column()]
            v = self._data.at[r, c]
            return str(v)
        elif role == Qt.TextAlignmentRole:
            return int(Qt.AlignRight | Qt.AlignVCenter)
        elif role == Qt.FontRole:
            font = QFont()
            font.setPointSize(font.pointSize()-2)
            return font
        elif role == Qt.BackgroundRole:
            if self._cell_color is not None:
                r = index.row()
                c = self._columns[index.column()]
                name = self._cell_color(r, c)
                color = QColor()
                color.setNamedColor(name)
                return color