Example #1
0
 def _get(self, key):
     if not key in self.config: return
     if key in self.dict: return self.dict[key]
     dvals = self.config[key]
     dname, vals = dvals
     #theme_dir = themes[name]
     v0 = vals[0]
     if v0[0] == '#':
         v = parse_color(v0)
         #if (len(v0) == 7):
         #    # Due to a bug in pygame 1.8 (?) we need to explicitly
         #    # specify the alpha value (otherwise it defaults to zero)
         #    v0 += "FF"
         #v = pygame.color.Color(v0)
     elif v0.endswith(".ttf") or v0.endswith(".TTF"):
         v = pygame.font.Font(os.path.join(dname, v0), int(vals[1]))
     elif self.is_image.search(v0) is not None:
         v = pygame.image.load(os.path.join(dname, v0))
     else:
         try:
             v = int(v0)
         except:
             v = pygame.font.SysFont(v0, int(vals[1]))
     self.dict[key] = v
     return v
Example #2
0
    def _get(self, cls, pcls, attr):
        key = (cls, pcls, attr)
        if not key in self.config:
            return

        if key in self.cache:
            # This property is already in the cache
            return self.cache[key]

        (dname, value) = self.config[key]

        if (os.path.splitext(str(value).lower())[1] in self.image_extensions):
            # This is an image attribute
            v = pygame.image.load(os.path.join(dname, value))

        elif (attr == "color" or attr == "background"):
            # This is a color value
            v = parse_color(value)

        elif (attr == "font"):
            # This is a font value
            args = value.split()
            name = args[0]
            size = int(args[1])
            try:
                v = self.fontCache[name, size]
            except KeyError:
                if (name.lower().endswith(".ttf")):
                    # Load the font from a file
                    v = pygame.font.Font(os.path.join(dname, name), size)
                else:
                    # Must be a system font
                    v = pygame.font.SysFont(name, size)
                # Cache the font for later
                self.fontCache[name, size] = v

        else:
            try:
                v = int(value)
            except:
                v = value
        self.cache[key] = v
        return v
Example #3
0
 def _get(self,key):
     if not key in self.config: return
     if key in self.dict: return self.dict[key]
     dvals = self.config[key]
     dname, vals = dvals
     #theme_dir = themes[name]
     v0 = vals[0]
     if v0[0] == '#':
         v = parse_color(v0)
         #if (len(v0) == 7):
         #    # Due to a bug in pygame 1.8 (?) we need to explicitly 
         #    # specify the alpha value (otherwise it defaults to zero)
         #    v0 += "FF"
         #v = pygame.color.Color(v0)
     elif v0.endswith(".ttf") or v0.endswith(".TTF"):
         v = pygame.font.Font(os.path.join(dname, v0),int(vals[1]))
     elif self.is_image.search(v0) is not None:
         v = pygame.image.load(os.path.join(dname, v0))
     else:
         try: v = int(v0)
         except: v = pygame.font.SysFont(v0, int(vals[1]))
     self.dict[key] = v
     return v    
Example #4
0
    def _get(self, cls, pcls, attr):
        key = (cls, pcls, attr)
        if not key in self.config:
            return

        if key in self.cache:
            # This property is already in the cache
            return self.cache[key]

        (dname, vals) = self.config[key]

        if (os.path.splitext(vals[0].lower())[1] in self.image_extensions):
            # This is an image attribute
            v = pygame.image.load(os.path.join(dname, vals[0]))

        elif (attr == "color" or attr == "background"):
            # This is a color value
            v = parse_color(vals[0])

        elif (attr == "font"):
            # This is a font value
            name = vals[0]
            size = int(vals[1])
            if (name.endswith(".ttf")):
                # Load the font from a file
                v = pygame.font.Font(os.path.join(dname, name), size)
            else:
                # Must be a system font
                v = pygame.font.SysFont(name, size)

        else:
            try:
                v = int(vals[0])
            except:
                v = vals[0]
        self.cache[key] = v
        return v
Example #5
0
def parse_basic_color(text):
    return basic.parse_color(text)