本文整理汇总了Python中qt.QLabel.setBuddy方法的典型用法代码示例。如果您正苦于以下问题:Python QLabel.setBuddy方法的具体用法?Python QLabel.setBuddy怎么用?Python QLabel.setBuddy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qt.QLabel
的用法示例。
在下文中一共展示了QLabel.setBuddy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from qt import QLabel [as 别名]
# 或者: from qt.QLabel import setBuddy [as 别名]
def __init__(self, game):
"""selection for this player, tiles are the still available tiles"""
QDialog.__init__(self, None)
decorateWindow(self, m18n("Penalty"))
self.game = game
grid = QGridLayout(self)
lblOffense = QLabel(m18n("Offense:"))
crimes = list([x for x in game.ruleset.penaltyRules if not ("absolute" in x.options and game.winner)])
self.cbCrime = ListComboBox(crimes)
lblOffense.setBuddy(self.cbCrime)
grid.addWidget(lblOffense, 0, 0)
grid.addWidget(self.cbCrime, 0, 1, 1, 4)
lblPenalty = QLabel(m18n("Total Penalty"))
self.spPenalty = PenaltyBox(2)
self.spPenalty.setRange(0, 9999)
lblPenalty.setBuddy(self.spPenalty)
self.lblUnits = QLabel(m18n("points"))
grid.addWidget(lblPenalty, 1, 0)
grid.addWidget(self.spPenalty, 1, 1)
grid.addWidget(self.lblUnits, 1, 2)
self.payers = []
self.payees = []
# a penalty can never involve the winner, neither as payer nor as payee
for idx in range(3):
self.payers.append(ListComboBox(game.losers()))
self.payees.append(ListComboBox(game.losers()))
for idx, payer in enumerate(self.payers):
grid.addWidget(payer, 3 + idx, 0)
payer.lblPayment = QLabel()
grid.addWidget(payer.lblPayment, 3 + idx, 1)
for idx, payee in enumerate(self.payees):
grid.addWidget(payee, 3 + idx, 3)
payee.lblPayment = QLabel()
grid.addWidget(payee.lblPayment, 3 + idx, 4)
grid.addWidget(QLabel(""), 6, 0)
grid.setRowStretch(6, 10)
for player in self.payers + self.payees:
player.currentIndexChanged.connect(self.playerChanged)
self.spPenalty.valueChanged.connect(self.penaltyChanged)
self.cbCrime.currentIndexChanged.connect(self.crimeChanged)
buttonBox = KDialogButtonBox(self)
grid.addWidget(buttonBox, 7, 0, 1, 5)
buttonBox.setStandardButtons(QDialogButtonBox.Cancel)
buttonBox.rejected.connect(self.reject)
if not usingKDE:
self.btnExecute = buttonBox.addButton(m18n("&Execute"), QDialogButtonBox.AcceptRole)
self.btnExecute.clicked.connect(self.accept)
else:
self.btnExecute = buttonBox.addButton(m18n("&Execute"), QDialogButtonBox.AcceptRole, self, SLOT("accept()"))
self.crimeChanged()
StateSaver(self)
示例2: setupUi
# 需要导入模块: from qt import QLabel [as 别名]
# 或者: from qt.QLabel import setBuddy [as 别名]
def setupUi(self):
"""layout the window"""
self.setContentsMargins(0, 0, 0, 0)
vlayout = QVBoxLayout(self)
vlayout.setContentsMargins(0, 0, 0, 0)
sliderLayout = QHBoxLayout()
self.kcfg_showShadows = QCheckBox(m18n('Show tile shadows'), self)
self.kcfg_showShadows.setObjectName('kcfg_showShadows')
self.kcfg_rearrangeMelds = QCheckBox(
m18n('Rearrange undisclosed tiles to melds'), self)
self.kcfg_rearrangeMelds.setObjectName('kcfg_rearrangeMelds')
self.kcfg_showOnlyPossibleActions = QCheckBox(m18n(
'Show only possible actions'))
self.kcfg_showOnlyPossibleActions.setObjectName(
'kcfg_showOnlyPossibleActions')
self.kcfg_propose = QCheckBox(m18n('Propose what to do'))
self.kcfg_propose.setObjectName('kcfg_propose')
self.kcfg_animationSpeed = QSlider(self)
self.kcfg_animationSpeed.setObjectName('kcfg_animationSpeed')
self.kcfg_animationSpeed.setOrientation(Qt.Horizontal)
self.kcfg_animationSpeed.setSingleStep(1)
lblSpeed = QLabel(m18n('Animation speed:'))
lblSpeed.setBuddy(self.kcfg_animationSpeed)
sliderLayout.addWidget(lblSpeed)
sliderLayout.addWidget(self.kcfg_animationSpeed)
self.kcfg_useSounds = QCheckBox(m18n('Use sounds if available'), self)
self.kcfg_useSounds.setObjectName('kcfg_useSounds')
self.kcfg_uploadVoice = QCheckBox(m18n(
'Let others hear my voice'), self)
self.kcfg_uploadVoice.setObjectName('kcfg_uploadVoice')
pol = QSizePolicy()
pol.setHorizontalPolicy(QSizePolicy.Expanding)
pol.setVerticalPolicy(QSizePolicy.Expanding)
spacerItem = QSpacerItem(
20, 20, QSizePolicy.Minimum, QSizePolicy.Expanding)
vlayout.addWidget(self.kcfg_showShadows)
vlayout.addWidget(self.kcfg_rearrangeMelds)
vlayout.addWidget(self.kcfg_showOnlyPossibleActions)
vlayout.addWidget(self.kcfg_propose)
vlayout.addWidget(self.kcfg_useSounds)
vlayout.addWidget(self.kcfg_uploadVoice)
vlayout.addLayout(sliderLayout)
vlayout.addItem(spacerItem)
self.setSizePolicy(pol)
self.retranslateUi()
示例3: ScoringDialog
# 需要导入模块: from qt import QLabel [as 别名]
# 或者: from qt.QLabel import setBuddy [as 别名]
class ScoringDialog(QWidget):
"""a dialog for entering the scores"""
# pylint: disable=too-many-instance-attributes
def __init__(self, scene):
QWidget.__init__(self)
self.scene = scene
decorateWindow(self, m18n("Scoring for this Hand"))
self.nameLabels = [None] * 4
self.spValues = [None] * 4
self.windLabels = [None] * 4
self.wonBoxes = [None] * 4
self.detailsLayout = [None] * 4
self.details = [None] * 4
self.__tilePixMaps = []
self.__meldPixMaps = []
grid = QGridLayout(self)
pGrid = QGridLayout()
grid.addLayout(pGrid, 0, 0, 2, 1)
pGrid.addWidget(QLabel(m18nc("kajongg", "Player")), 0, 0)
pGrid.addWidget(QLabel(m18nc("kajongg", "Wind")), 0, 1)
pGrid.addWidget(QLabel(m18nc("kajongg", "Score")), 0, 2)
pGrid.addWidget(QLabel(m18n("Winner")), 0, 3)
self.detailTabs = QTabWidget()
self.detailTabs.setDocumentMode(True)
pGrid.addWidget(self.detailTabs, 0, 4, 8, 1)
for idx in range(4):
self.setupUiForPlayer(pGrid, idx)
self.draw = QCheckBox(m18nc("kajongg", "Draw"))
self.draw.clicked.connect(self.wonChanged)
btnPenalties = QPushButton(m18n("&Penalties"))
btnPenalties.clicked.connect(self.penalty)
self.btnSave = QPushButton(m18n("&Save Hand"))
self.btnSave.clicked.connect(self.game.nextScoringHand)
self.btnSave.setEnabled(False)
self.setupUILastTileMeld(pGrid)
pGrid.setRowStretch(87, 10)
pGrid.addWidget(self.draw, 7, 3)
self.cbLastTile.currentIndexChanged.connect(self.slotLastTile)
self.cbLastMeld.currentIndexChanged.connect(self.slotInputChanged)
btnBox = QHBoxLayout()
btnBox.addWidget(btnPenalties)
btnBox.addWidget(self.btnSave)
pGrid.addLayout(btnBox, 8, 4)
StateSaver(self)
self.refresh()
@property
def game(self):
"""proxy"""
return self.scene.game
def setupUILastTileMeld(self, pGrid):
"""setup UI elements for last tile and last meld"""
self.lblLastTile = QLabel(m18n("&Last Tile:"))
self.cbLastTile = QComboBox()
self.cbLastTile.setMinimumContentsLength(1)
vpol = QSizePolicy()
vpol.setHorizontalPolicy(QSizePolicy.Fixed)
self.cbLastTile.setSizePolicy(vpol)
self.cbLastTile.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon)
self.lblLastTile.setBuddy(self.cbLastTile)
self.lblLastMeld = QLabel(m18n("L&ast Meld:"))
self.prevLastTile = None
self.cbLastMeld = QComboBox()
self.cbLastMeld.setMinimumContentsLength(1)
self.cbLastMeld.setSizePolicy(vpol)
self.cbLastMeld.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon)
self.lblLastMeld.setBuddy(self.cbLastMeld)
self.comboTilePairs = set()
pGrid.setRowStretch(6, 5)
pGrid.addWidget(self.lblLastTile, 7, 0, 1, 2)
pGrid.addWidget(self.cbLastTile, 7, 2, 1, 1)
pGrid.addWidget(self.lblLastMeld, 8, 0, 1, 2)
pGrid.addWidget(self.cbLastMeld, 8, 2, 1, 2)
def setupUiForPlayer(self, pGrid, idx):
"""setup UI elements for a player"""
self.spValues[idx] = QSpinBox()
self.nameLabels[idx] = QLabel()
self.nameLabels[idx].setBuddy(self.spValues[idx])
self.windLabels[idx] = WindLabel()
pGrid.addWidget(self.nameLabels[idx], idx + 2, 0)
pGrid.addWidget(self.windLabels[idx], idx + 2, 1)
pGrid.addWidget(self.spValues[idx], idx + 2, 2)
self.wonBoxes[idx] = QCheckBox("")
pGrid.addWidget(self.wonBoxes[idx], idx + 2, 3)
self.wonBoxes[idx].clicked.connect(self.wonChanged)
self.spValues[idx].valueChanged.connect(self.slotInputChanged)
detailTab = QWidget()
self.detailTabs.addTab(detailTab, "")
self.details[idx] = QWidget()
detailTabLayout = QVBoxLayout(detailTab)
detailTabLayout.addWidget(self.details[idx])
detailTabLayout.addStretch()
self.detailsLayout[idx] = QVBoxLayout(self.details[idx])
def refresh(self):
#.........这里部分代码省略.........