Ejemplo n.º 1
0
 def get_bgcolor(self, index):
     """Background color depending on value"""
     column = index.column()
     if column == 0:
         color = QColor(Qt.lightGray)
         color.setAlphaF(.8)
         return color
     if not self.bgcolor_enabled:
         return
     value = self.get_value(index.row(), column - 1)
     if isinstance(value, _sup_com):
         color_func = abs
     else:
         color_func = float
     if isinstance(value, _sup_nr + _sup_com) and self.bgcolor_enabled:
         vmax, vmin = self.return_max(self.max_min_col, column - 1)
         hue = self.hue0 + self.dhue * (vmax - color_func(value)) / (vmax -
                                                                     vmin)
         hue = float(abs(hue))
         color = QColor.fromHsvF(hue, self.sat, self.val, self.alp)
     elif is_text_string(value):
         color = QColor(Qt.lightGray)
         color.setAlphaF(.05)
     else:
         color = QColor(Qt.lightGray)
         color.setAlphaF(.3)
     return color
Ejemplo n.º 2
0
 def data(self, index, role=Qt.DisplayRole):
     """Cell content"""
     if not index.isValid():
         return to_qvariant()
     value = self.get_value(index)
     if is_binary_string(value):
         try:
             value = to_text_string(value, 'utf8')
         except:
             pass
     if role == Qt.DisplayRole:
         if value is np.ma.masked:
             return ''
         else:
             return to_qvariant(self._format % value)
     elif role == Qt.TextAlignmentRole:
         return to_qvariant(int(Qt.AlignCenter|Qt.AlignVCenter))
     elif role == Qt.BackgroundColorRole and self.bgcolor_enabled \
       and value is not np.ma.masked:
         hue = self.hue0+\
               self.dhue*(self.vmax-self.color_func(value)) \
               /(self.vmax-self.vmin)
         hue = float(np.abs(hue))
         color = QColor.fromHsvF(hue, self.sat, self.val, self.alp)
         return to_qvariant(color)
     elif role == Qt.FontRole:
         return to_qvariant(get_font('arrayeditor'))
     return to_qvariant()
Ejemplo n.º 3
0
 def get_bgcolor(self, index):
     """Background color depending on value"""
     column = index.column()
     if column == 0:
         color = QColor(Qt.lightGray)
         color.setAlphaF(.8)
         return color
     if not self.bgcolor_enabled:
         return
     value = self.get_value(index.row(), column-1)
     if isinstance(value, _sup_com):
         color_func = abs
     else:
         color_func = float
     if isinstance(value, _sup_nr+_sup_com) and self.bgcolor_enabled:
         vmax, vmin = self.return_max(self.max_min_col, column-1)
         hue = self.hue0 + self.dhue*(vmax-color_func(value)) / (vmax-vmin)
         hue = float(abs(hue))
         color = QColor.fromHsvF(hue, self.sat, self.val, self.alp)
     elif is_text_string(value):
         color = QColor(Qt.lightGray)
         color.setAlphaF(.05)
     else:
         color = QColor(Qt.lightGray)
         color.setAlphaF(.3)
     return color
Ejemplo n.º 4
0
 def data(self, index, role=Qt.DisplayRole):
     """Cell content"""
     if not index.isValid():
         return to_qvariant()
     value = self.get_value(index)
     if is_binary_string(value):
         try:
             value = to_text_string(value, 'utf8')
         except:
             pass
     if role == Qt.DisplayRole:
         if value is np.ma.masked:
             return ''
         else:
             return to_qvariant(self._format % value)
     elif role == Qt.TextAlignmentRole:
         return to_qvariant(int(Qt.AlignCenter|Qt.AlignVCenter))
     elif role == Qt.BackgroundColorRole and self.bgcolor_enabled \
       and value is not np.ma.masked:
         hue = self.hue0+\
               self.dhue*(self.vmax-self.color_func(value)) \
               /(self.vmax-self.vmin)
         hue = float(np.abs(hue))
         color = QColor.fromHsvF(hue, self.sat, self.val, self.alp)
         return to_qvariant(color)
     elif role == Qt.FontRole:
         return to_qvariant(get_font('arrayeditor'))
     return to_qvariant()