本文整理匯總了Python中PySide.QtGui.QButtonGroup.setId方法的典型用法代碼示例。如果您正苦於以下問題:Python QButtonGroup.setId方法的具體用法?Python QButtonGroup.setId怎麽用?Python QButtonGroup.setId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PySide.QtGui.QButtonGroup
的用法示例。
在下文中一共展示了QButtonGroup.setId方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ColorChoiceWidget
# 需要導入模塊: from PySide.QtGui import QButtonGroup [as 別名]
# 或者: from PySide.QtGui.QButtonGroup import setId [as 別名]
class ColorChoiceWidget(ColorWidget):
def __init__(self):
super(ColorChoiceWidget, self).__init__()
self.buttons = []
self.buttonGroup = QButtonGroup()
self.buttonGroup.setExclusive(True)
self.buttonGroup.buttonClicked.connect(self.selectColor)
def setColors(self, colors):
layout = self.buttonWidget.layout()
id = 0
for color in colors:
button = ColorButton()
button.setColor(color)
button.setCheckable(True)
layout.addWidget(button)
self.buttonGroup.addButton(button)
self.buttonGroup.setId(button, id)
id += 1
layout.addStretch(10)
def setColor(self, color):
self.color = color
for button in self.buttonGroup.buttons():
diffs = map(lambda x, y: abs(x - y), button.color, color)
if sum(diffs) < 0.0001:
button.setChecked(True)
break
def selectColor(self, button):
self.color = button.color
self.valueChanged.emit(self.color)