Next / Previous / Contents / TCC Help System / NM Tech homepage

14.3. PickList.lookupName(): Convert a color name to a color value

This method uses the internal self.__colorMap dictionary to lookup color names and, if found, return the corresponding color value as a Color instance.

huey
# - - -   P i c k L i s t . l o o k u p N a m e

    def lookupName ( self, colorName ):
        """Look up a color name.
        """
        #-- 1 --
        # [ colorKey  :=  colorName, uppercased ]
        colorKey  =  colorName.upper()

        #-- 2 --
        # [ if  colorKey is a key in self.__colorMap ->
        #     return the corresponding value
        #   else ->
        #     return None ]
        try:
            index, color, name  =  self.__colorMap[colorKey]
            return  color
        except KeyError:
            return None