'Background color depending on value'

def get_bgcolor(self, index):

    column = index.column()
    if (column == 0):
        color = QColor(BACKGROUND_NONNUMBER_COLOR)
        color.setAlphaF(BACKGROUND_INDEX_ALPHA)
        return color
    if (not self.bgcolor_enabled):
        return
    value = self.get_value(index.row(), (column - 1))
    if (self.max_min_col[(column - 1)] is None):
        color = QColor(BACKGROUND_NONNUMBER_COLOR)
        if is_text_string(value):
            color.setAlphaF(BACKGROUND_STRING_ALPHA)
        else:
            color.setAlphaF(BACKGROUND_MISC_ALPHA)
    else:
        if isinstance(value, COMPLEX_NUMBER_TYPES):
            color_func = abs
        else:
            color_func = float
        (vmax, vmin) = self.return_max(self.max_min_col, (column - 1))
        hue = (BACKGROUND_NUMBER_MINHUE + ((BACKGROUND_NUMBER_HUERANGE * (vmax - color_func(value))) / (vmax - vmin)))
        hue = float(abs(hue))
        if (hue > 1):
            hue = 1
        color = QColor.fromHsvF(hue, BACKGROUND_NUMBER_SATURATION, BACKGROUND_NUMBER_VALUE, BACKGROUND_NUMBER_ALPHA)
    return color
