def __init__(
        self,
        parentWidget,
        label='Color:',
        labelColumn=0,
        colorList=[],
        colorNames=[],
        color=white,
        setAsDefault=True,
        spanWidth=False,
    ):
        """
        Appends a color chooser widget to <parentWidget>, a property manager 
        group box.
        
        @param parentWidget: the parent group box containing this widget.
        @type  parentWidget: PM_GroupBox
        
        @param label: The label that appears to the left or right of the 
                      color frame (and "Browse" button). 
                      
                      If spanWidth is True, the label will be displayed on
                      its own row directly above the lineedit (and button).
                      
                      To suppress the label, set I{label} to an 
                      empty string.
        @type  label: str
        
        @param labelColumn: The column number of the label in the group box
                            grid layout. The only valid values are 0 (left 
                            column) and 1 (right column). The default is 0 
                            (left column).
        @type  labelColumn: int
        
        @param colorList: List of colors.
        @type  colorList: List where each item contains 3 floats (r, g, b)
        
        @param colorNames: List of color names.
        @type  colorNames: List of strings
        
        @param color: The initial color. White is the default. If I{color}
                      is not in I{colorList}, then the initial color will be
                      set to the last color item (i.e. "Other color...").
        @type  color: tuple of 3 floats (r, g, b)
        
        @param setAsDefault: if True, will restore L{color} when the
                    "Restore Defaults" button is clicked.
        @type  setAsDefault: boolean
        
        @param spanWidth: if True, the widget and its label will span the width
                      of the group box. Its label will appear directly above
                      the widget (unless the label is empty) and is left
                      justified.
        @type  spanWidth: boolean
        """

        if len(colorNames) and len(colorList):
            assert len(colorNames) == len(colorList)
            self.colorNames = colorNames
            self.colorList = colorList

        self.colorDict = dict(zip(self.colorNames, self.colorList))

        PM_ComboBox.__init__(
            self,
            parentWidget,
            label=label,
            labelColumn=labelColumn,
            choices=self.colorNames,
            index=0,  # Gets (re)set by setColor()
            setAsDefault=setAsDefault,
            spanWidth=spanWidth)

        # Load QComboBox widget choices and set initial choice (index).
        idx = 0
        for colorName in self.colorNames:
            pixmap = QPixmap(12, 12)
            qcolor = RGBf_to_QColor(self.colorDict[str(colorName)])
            pixmap.fill(qcolor)
            self.setItemIcon(idx, QIcon(pixmap))
            idx += 1

        self.setIconSize(QSize(12, 12))  # Default is 16x16.
        self.setColor(color)  # Sets current index.

        self.connect(self, SIGNAL("activated(QString)"),
                     self._setColorFromIndex)

        return
 def __init__(self, 
              parentWidget, 
              label        = 'Color:', 
              labelColumn  = 0,
              colorList    = [],
              colorNames   = [],
              color        = white, 
              setAsDefault = True,
              spanWidth    = False,
              ):
     """
     Appends a color chooser widget to <parentWidget>, a property manager 
     group box.
     
     @param parentWidget: the parent group box containing this widget.
     @type  parentWidget: PM_GroupBox
     
     @param label: The label that appears to the left or right of the 
                   color frame (and "Browse" button). 
                   
                   If spanWidth is True, the label will be displayed on
                   its own row directly above the lineedit (and button).
                   
                   To suppress the label, set I{label} to an 
                   empty string.
     @type  label: str
     
     @param labelColumn: The column number of the label in the group box
                         grid layout. The only valid values are 0 (left 
                         column) and 1 (right column). The default is 0 
                         (left column).
     @type  labelColumn: int
     
     @param colorList: List of colors.
     @type  colorList: List where each item contains 3 floats (r, g, b)
     
     @param colorNames: List of color names.
     @type  colorNames: List of strings
     
     @param color: The initial color. White is the default. If I{color}
                   is not in I{colorList}, then the initial color will be
                   set to the last color item (i.e. "Other color...").
     @type  color: tuple of 3 floats (r, g, b)
     
     @param setAsDefault: if True, will restore L{color} when the
                 "Restore Defaults" button is clicked.
     @type  setAsDefault: boolean
     
     @param spanWidth: if True, the widget and its label will span the width
                   of the group box. Its label will appear directly above
                   the widget (unless the label is empty) and is left
                   justified.
     @type  spanWidth: boolean
     """
     
     if len(colorNames) and len(colorList):
         assert len(colorNames) == len(colorList)
         self.colorNames = colorNames
         self.colorList  = colorList
     
     self.colorDict = dict(zip(self.colorNames, self.colorList))
     
     PM_ComboBox.__init__(self, 
              parentWidget, 
              label        = label, 
              labelColumn  = labelColumn,
              choices      = self.colorNames,
              index        = 0, # Gets (re)set by setColor()
              setAsDefault = setAsDefault,
              spanWidth    = spanWidth
              )
     
     # Load QComboBox widget choices and set initial choice (index).
     idx = 0
     for colorName in self.colorNames:
         pixmap = QPixmap(12, 12)
         qcolor = RGBf_to_QColor(self.colorDict[str(colorName)])
         pixmap.fill(qcolor)
         self.setItemIcon(idx, QIcon(pixmap))
         idx += 1
         
     self.setIconSize(QSize(12, 12)) # Default is 16x16.
     self.setColor(color) # Sets current index.
     
     self.connect(self, SIGNAL("activated(QString)"), self._setColorFromName)
     
     return