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


Python DemoItemAnimation.play方法代码示例

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


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

示例1: TextButton

# 需要导入模块: from demoitemanimation import DemoItemAnimation [as 别名]
# 或者: from demoitemanimation.DemoItemAnimation import play [as 别名]

#.........这里部分代码省略.........

    def setupHoverText(self):
        if not self.buttonLabel:
            return

        textItem = DemoTextItem(self.buttonLabel, Colors.buttonFont(),
                Colors.buttonText, -1, self)
        textItem.setZValue(self.zValue() + 2)
        textItem.setPos(16, 0)

    def setupScanItem(self):
        if Colors.useButtonBalls:
            scanItem = ScanItem(self)
            scanItem.setZValue(self.zValue() + 1)

            self.scanAnim = DemoItemAnimation(scanItem)

            x = 1.0
            y = 1.5
            stop = TextButton.BUTTON_WIDTH - scanItem.boundingRect().width() - x
            if self.alignment == TextButton.LEFT:
                self.scanAnim.setDuration(2500)
                self.scanAnim.setKeyValueAt(0.0, QPointF(x, y))
                self.scanAnim.setKeyValueAt(0.5, QPointF(x, y))
                self.scanAnim.setKeyValueAt(0.7, QPointF(stop, y))
                self.scanAnim.setKeyValueAt(1.0, QPointF(x, y))
                scanItem.setPos(QPointF(x, y))
            else:
                self.scanAnim.setKeyValueAt(0.0, QPointF(stop, y))
                self.scanAnim.setKeyValueAt(0.5, QPointF(x, y))
                self.scanAnim.setKeyValueAt(1.0, QPointF(stop, y))
                scanItem.setPos(QPointF(stop, y))

    def setState(self, state):
        self.state = state
        self.bgOn.setRecursiveVisible(state == TextButton.ON)
        self.bgOff.setRecursiveVisible(state == TextButton.OFF)
        self.bgHighlight.setRecursiveVisible(state == TextButton.HIGHLIGHT)
        self.bgDisabled.setRecursiveVisible(state == TextButton.DISABLED)
        if state == TextButton.DISABLED:
            self.setCursor(Qt.ArrowCursor)
        else:
            self.setCursor(Qt.PointingHandCursor)

    def setupButtonBg(self):
        self.bgOn = ButtonBackground(self.buttonType, True, True,
                self.logicalSize, self)
        self.bgOff = ButtonBackground(self.buttonType, False, False,
                self.logicalSize, self)
        self.bgHighlight = ButtonBackground(self.buttonType, True, False,
                self.logicalSize, self)
        self.bgDisabled = ButtonBackground(self.buttonType, True, True,
                self.logicalSize, self)
        self.setState(TextButton.OFF)

    def hoverEnterEvent(self, event):
        if not self.isEnabled() or self.state == TextButton.DISABLED:
            return

        if self.state == TextButton.OFF:
            self.setState(TextButton.HIGHLIGHT)

            if Colors.noAnimations and Colors.useButtonBalls:
                # Wait a bit in the beginning to enhance the effect.  We have
                # to do this here so that the adaption can be dynamic.
                self.scanAnim.setDuration(1000)
                self.scanAnim.setKeyValueAt(0.2, self.scanAnim.posAt(0))

            if (self._menu_manager.window.fpsMedian > 10 or Colors.noAdapt or
                    Colors.noTimerUpdate):
                if Colors.useButtonBalls:
                    self.scanAnim.play(True, True)

    def hoverLeaveEvent(self, event):
        if self.state == TextButton.DISABLED:
            return

        self.setState(TextButton.OFF)

        if Colors.noAnimations and Colors.useButtonBalls:
            self.scanAnim.stop()

    def mousePressEvent(self, event):
        if self.state == TextButton.DISABLED:
            return

        if self.state == TextButton.HIGHLIGHT or self.state == TextButton.OFF:
            self.setState(TextButton.ON)

    def mouseReleaseEvent(self, event):
        if self.state == TextButton.ON:
            self.setState(TextButton.OFF)
            if self.isEnabled() and self.boundingRect().contains(event.pos()):
                self._menu_manager.itemSelected(self.userCode, self.menuString)

    def animationStarted(self, _):
        if self.state == TextButton.DISABLED:
            return

        self.setState(TextButton.OFF)
开发者ID:death-finger,项目名称:Scripts,代码行数:104,代码来源:textbutton.py


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