def RGBStringToTuple(rgb_str, make7bit = True):
    """Takes a color string of format #ffffff and returns an RGB tuple. 
    By default the values of the tuple are converted to 7-bits. 
    Pass False as the second parameter for 8-bits."""
    rgb_tuple = (0, 0, 0)
    if (len(rgb_str) >= 7) and (rgb_str[0] == "#"):
        red = int(rgb_str[1:3], 16)
        green = int(rgb_str[3:5], 16)
        blue = int(rgb_str[5:7], 16)
        if make7bit:
            red = red // 2
            green = green // 2
            blue = blue // 2
        rgb_tuple = (red, green, blue)
    return rgb_tuple