当前位置: 首页>>代码示例>>Python>>正文


Python PM_ComboBox.__init__方法代码示例

本文整理汇总了Python中PM.PM_ComboBox.PM_ComboBox.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python PM_ComboBox.__init__方法的具体用法?Python PM_ComboBox.__init__怎么用?Python PM_ComboBox.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PM.PM_ComboBox.PM_ComboBox的用法示例。


在下文中一共展示了PM_ComboBox.__init__方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from PM.PM_ComboBox import PM_ComboBox [as 别名]
# 或者: from PM.PM_ComboBox.PM_ComboBox import __init__ [as 别名]
 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
开发者ID:elfion,项目名称:nanoengineer,代码行数:89,代码来源:PM_ColorComboBox.py


注:本文中的PM.PM_ComboBox.PM_ComboBox.__init__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。