當前位置: 首頁>>代碼示例>>Python>>正文


Python Background.setPalette方法代碼示例

本文整理匯總了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
開發者ID:ospalh,項目名稱:kajongg-fork,代碼行數:70,代碼來源:playfield.py

示例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):
開發者ID:KDE,項目名稱:kajongg,代碼行數:70,代碼來源:mainwindow.py


注:本文中的background.Background.setPalette方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。