本文整理汇总了Python中background.Background.setPalette方法的典型用法代码示例。如果您正苦于以下问题:Python Background.setPalette方法的具体用法?Python Background.setPalette怎么用?Python Background.setPalette使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类background.Background
的用法示例。
在下文中一共展示了Background.setPalette方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PlayField
# 需要导入模块: from background import Background [as 别名]
# 或者: from background.Background import setPalette [as 别名]
#.........这里部分代码省略.........
view.fitInView(scene.itemsBoundingRect(), Qt.KeepAspectRatio)
@property
def startingGame(self):
"""are we trying to start a game?"""
return self.__startingGame
@startingGame.setter
def startingGame(self, value):
"""are we trying to start a game?"""
if value != self.__startingGame:
self.__startingGame = value
self.updateGUI()
@property
def tilesetName(self):
"""the name of the current tileset"""
return self.tileset.desktopFileName
@tilesetName.setter
def tilesetName(self, name):
"""the name of the current tileset"""
self.tileset = Tileset(name)
@property
def backgroundName(self):
"""setting this also actually changes the background"""
return self.background.desktopFileName if self.background else ''
@backgroundName.setter
def backgroundName(self, name):
"""setter for backgroundName"""
self.background = Background(name)
self.background.setPalette(self.centralWidget())
self.centralWidget().setAutoFillBackground(True)
def applySettings(self):
"""apply preferences"""
# pylint: disable=R0912
# too many branches
self.actionAngle.setEnabled(bool(self.game) and Preferences.showShadows)
animate() # drain the queue
afterCurrentAnimationDo(self.__applySettings2)
def __applySettings2(self, dummyResults):
"""now no animation is running"""
with Animated(False):
if self.tilesetName != Preferences.tilesetName:
self.tilesetName = Preferences.tilesetName
if self.game:
self.game.wall.tileset = self.tileset
for item in self.centralScene.nonTiles():
try:
item.tileset = self.tileset
except AttributeError:
continue
# change players last because we need the wall already to be repositioned
self.adjustView() # the new tiles might be larger
if self.game:
for player in self.game.players:
if player.handBoard:
player.handBoard.rearrangeMelds = Preferences.rearrangeMelds
if self.backgroundName != Preferences.backgroundName:
self.backgroundName = Preferences.backgroundName
if self.showShadows is None or self.showShadows != Preferences.showShadows:
self.showShadows = Preferences.showShadows
示例2: MainWindow
# 需要导入模块: from background import Background [as 别名]
# 或者: from background.Background import setPalette [as 别名]
#.........这里部分代码省略.........
def slotPlayers(self):
"""show the player list"""
if not self.playerWindow:
self.playerWindow = PlayerList(self)
self.playerWindow.show()
def slotRulesets(self):
"""show the player list"""
if not self.rulesetWindow:
self.rulesetWindow = RulesetSelector()
self.rulesetWindow.show()
def adjustView(self):
"""adjust the view such that exactly the wanted things are displayed
without having to scroll"""
if not Internal.scaleScene or not isAlive(self):
return
view, scene = self.centralView, self.scene
if scene:
scene.adjustView()
oldRect = view.sceneRect()
view.setSceneRect(scene.itemsBoundingRect())
newRect = view.sceneRect()
if oldRect != newRect:
view.fitInView(scene.itemsBoundingRect(), Qt.KeepAspectRatio)
@afterQueuedAnimations
def backgroundChanged(self, dummyDeferredResult, dummyOldName, newName):
"""if the wanted background changed, apply the change now"""
centralWidget = self.centralWidget()
if centralWidget:
self.background = Background(newName)
self.background.setPalette(centralWidget)
centralWidget.setAutoFillBackground(True)
@afterQueuedAnimations
def tilesetNameChanged(
self, dummyDeferredResult, dummyOldValue=None, dummyNewValue=None, *dummyArgs):
"""if the wanted tileset changed, apply the change now"""
if self.centralView:
with MoveImmediate():
if self.scene:
self.scene.applySettings()
self.adjustView()
@afterQueuedAnimations
def showSettings(self, dummyDeferredResult, dummyChecked=None):
"""show preferences dialog. If it already is visible, do nothing"""
# This is called by the triggered() signal. So why does KDE
# not return the bool checked?
if ConfigDialog.showDialog("settings"):
return
# if an animation is running, Qt segfaults somewhere deep
# in the SVG renderer rendering the wind tiles for the tile
# preview
self.confDialog = ConfigDialog(self, "settings")
self.confDialog.show()
def _toggleWidget(self, checked):
"""user has toggled widget visibility with an action"""
assert self.scene
action = self.sender()
actionData = variantValue(action.data())
if checked:
if isinstance(actionData, type):