Пример #1
0
    def getWidget(self):
        val = getattr(self.edw, self.attr)
        max = getattr(self.edw, self.attr_max)
        min = getattr(self.edw, self.attr_min)
        if isinstance(val, int) and isinstance(max, int) and isinstance(min, int) and min >= 0:
            col_min = QColor(self.col_min)
            col_max = QColor(self.col_max)

            if min != max:
                r_min, g_min, b_min, a_min = col_min.getRgb()
                r_max, g_max, b_max, a_max = col_max.getRgb()
                c_r = ((val - min) * (r_max - r_min) / (max - min)) + r_min
                c_g = ((val - min) * (g_max - g_min) / (max - min)) + g_min
                c_b = ((val - min) * (b_max - b_min) / (max - min)) + b_min

                # If the min / max values has not yet been refreshed, then we could get weird colors
                if c_r < 0:
                    c_r = 0
                if c_g < 0:
                    c_g = 0
                if c_b < 0:
                    c_b = 0
                if c_r > 255:
                    c_r = 255
                if c_g > 255:
                    c_g = 255
                if c_b > 255:
                    c_b = 255

                color = "#%02x%02x%02x" % (c_r, c_g, c_b)
            else:
                color = col_min

            return EdwProgressBarCell(val, max, color, self.format)
        return EdwBlankCell()
Пример #2
0
 def calc_colors(self,nColors,HSVsubset=(0,360),HSVoffset=0):
     h = sp.linspace(HSVsubset[0],HSVsubset[1],nColors,endpoint=False).astype('int')
     h = self.add_circular_offset(h,HSVoffset,HSVsubset[1]).tolist()
     s = [255] * nColors
     v = [255] * nColors
     colors = []
     for n in range(nColors):
         Color = QColor()
         Color.setHsv(h[n],s[n],v[n])
         colors.append(Color.getRgb())
     return colors
Пример #3
0
 def calc_colors(self, nColors, HSVsubset=(0, 360), HSVoffset=0):
     h = sp.linspace(HSVsubset[0], HSVsubset[1], nColors,
                     endpoint=False).astype('int')
     h = self.add_circular_offset(h, HSVoffset, HSVsubset[1]).tolist()
     s = [255] * nColors
     v = [255] * nColors
     colors = []
     for n in range(nColors):
         Color = QColor()
         Color.setHsv(h[n], s[n], v[n])
         colors.append(Color.getRgb())
     return colors