Esempio n. 1
0
def make_color(color):
    if isinstance(color, tuple):
        return QColor(*color)
    elif isinstance(color, str):
        return QColor(color)
    else:
        raise ValueError('Unknown color %r', color)
Esempio n. 2
0
 def get_pen_color(self, key):
     if self._plot_colors is None:
         self._plot_colors = self._make_plot_cycle()
     color = self._plot_colors[key]
     if not isinstance(color, str):
         return QColor(*color)
     else:
         return QColor(color)
Esempio n. 3
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. 4
0
 def _default_plot(self):
     symbol_code = self.SYMBOL_MAP[self.symbol]
     color = QColor(self.pen_color)
     pen = pg.mkPen(color, width=self.pen_width)
     brush = pg.mkBrush(color)
     return pg.PlotDataItem(pen=pen,
                            antialias=self.antialias,
                            symbol=symbol_code,
                            symbolSize=self.symbol_size,
                            symbolPen=pen,
                            symbolBrush=brush,
                            pxMode=self.symbol_size_unit == 'screen')
Esempio n. 5
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.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
 def apply_validator(self, item, label):
     if self.validator and not self.validator(label):
         item.setTextColor(QColor(255, 0, 0))
     else:
         item.setTextColor(QColor(0, 0, 0))