本文整理汇总了Python中PyQt5.QtCore.QPropertyAnimation.setKeyValueAt方法的典型用法代码示例。如果您正苦于以下问题:Python QPropertyAnimation.setKeyValueAt方法的具体用法?Python QPropertyAnimation.setKeyValueAt怎么用?Python QPropertyAnimation.setKeyValueAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QPropertyAnimation
的用法示例。
在下文中一共展示了QPropertyAnimation.setKeyValueAt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: NotifyWidget
# 需要导入模块: from PyQt5.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt5.QtCore.QPropertyAnimation import setKeyValueAt [as 别名]
class NotifyWidget(QWidget):
def __init__(self):
super().__init__()
self.layout = QVBoxLayout(self)
self.sub_widget = _NotifySubWidget(self)
self.layout.addWidget(self.sub_widget)
self.layout.setContentsMargins(0, 0, 0, 0)
self._exit_shortcut = QShortcut(QKeySequence(Qt.Key_Escape), self)
self._exit_shortcut.activated.connect(self.close)
self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.Tool)
self.setAttribute(Qt.WA_TranslucentBackground)
self.setAttribute(Qt.WA_MacAlwaysShowToolWindow)
self.resize(width, height)
self.move(QApplication.desktop().width() - self.width() - 20, 40)
self.setLayout(self.layout)
self._animation = QPropertyAnimation(self, b'windowOpacity')
self._animation.setStartValue(0.8)
self._animation.setKeyValueAt(0.4, 1)
self._animation.setEndValue(0)
self._animation.setDuration(5000)
self._animation.finished.connect(self.close)
def show(self):
super().show()
self._animation.start()
def show_message(self, title, content, pixmap=None):
if not self.isVisible():
self.show()
self._animation.stop()
self._animation.setCurrentTime(0)
self._animation.start()
self.sub_widget.set_title(title)
self.sub_widget.set_content(content)
pixmap = pixmap if pixmap else QPixmap(WINDOW_ICON)
self.sub_widget.set_pixmap(pixmap)
def enterEvent(self, event):
self._animation.setCurrentTime(0)
示例2: __init__
# 需要导入模块: from PyQt5.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt5.QtCore.QPropertyAnimation import setKeyValueAt [as 别名]
def __init__(self, size, parent=None):
super(PadNavigator, self).__init__(parent)
self.form = Ui_Form()
splash = SplashItem()
splash.setZValue(1)
pad = FlippablePad(size)
flipRotation = QGraphicsRotation(pad)
xRotation = QGraphicsRotation(pad)
yRotation = QGraphicsRotation(pad)
flipRotation.setAxis(Qt.YAxis)
xRotation.setAxis(Qt.YAxis)
yRotation.setAxis(Qt.XAxis)
pad.setTransformations([flipRotation, xRotation, yRotation])
backItem = QGraphicsProxyWidget(pad)
widget = QWidget()
self.form.setupUi(widget)
self.form.hostName.setFocus()
backItem.setWidget(widget)
backItem.setVisible(False)
backItem.setFocus()
backItem.setCacheMode(QGraphicsItem.ItemCoordinateCache)
r = backItem.rect()
backItem.setTransform(QTransform().rotate(180, Qt.YAxis).translate(-r.width()/2, -r.height()/2))
selectionItem = RoundRectItem(QRectF(-60, -60, 120, 120),
QColor(Qt.gray), pad)
selectionItem.setZValue(0.5)
smoothSplashMove = QPropertyAnimation(splash, b'y')
smoothSplashOpacity = QPropertyAnimation(splash, b'opacity')
smoothSplashMove.setEasingCurve(QEasingCurve.InQuad)
smoothSplashMove.setDuration(250)
smoothSplashOpacity.setDuration(250)
smoothXSelection = QPropertyAnimation(selectionItem, b'x')
smoothYSelection = QPropertyAnimation(selectionItem, b'y')
smoothXRotation = QPropertyAnimation(xRotation, b'angle')
smoothYRotation = QPropertyAnimation(yRotation, b'angle')
smoothXSelection.setDuration(125)
smoothYSelection.setDuration(125)
smoothXRotation.setDuration(125)
smoothYRotation.setDuration(125)
smoothXSelection.setEasingCurve(QEasingCurve.InOutQuad)
smoothYSelection.setEasingCurve(QEasingCurve.InOutQuad)
smoothXRotation.setEasingCurve(QEasingCurve.InOutQuad)
smoothYRotation.setEasingCurve(QEasingCurve.InOutQuad)
smoothFlipRotation = QPropertyAnimation(flipRotation, b'angle')
smoothFlipScale = QPropertyAnimation(pad, b'scale')
smoothFlipXRotation = QPropertyAnimation(xRotation, b'angle')
smoothFlipYRotation = QPropertyAnimation(yRotation, b'angle')
flipAnimation = QParallelAnimationGroup(self)
smoothFlipScale.setDuration(500)
smoothFlipRotation.setDuration(500)
smoothFlipXRotation.setDuration(500)
smoothFlipYRotation.setDuration(500)
smoothFlipScale.setEasingCurve(QEasingCurve.InOutQuad)
smoothFlipRotation.setEasingCurve(QEasingCurve.InOutQuad)
smoothFlipXRotation.setEasingCurve(QEasingCurve.InOutQuad)
smoothFlipYRotation.setEasingCurve(QEasingCurve.InOutQuad)
smoothFlipScale.setKeyValueAt(0, 1.0)
smoothFlipScale.setKeyValueAt(0.5, 0.7)
smoothFlipScale.setKeyValueAt(1, 1.0)
flipAnimation.addAnimation(smoothFlipRotation)
flipAnimation.addAnimation(smoothFlipScale)
flipAnimation.addAnimation(smoothFlipXRotation)
flipAnimation.addAnimation(smoothFlipYRotation)
setVariablesSequence = QSequentialAnimationGroup()
setFillAnimation = QPropertyAnimation(pad, b'fill')
setBackItemVisibleAnimation = QPropertyAnimation(backItem, b'visible')
setSelectionItemVisibleAnimation = QPropertyAnimation(selectionItem, b'visible')
setFillAnimation.setDuration(0)
setBackItemVisibleAnimation.setDuration(0)
setSelectionItemVisibleAnimation.setDuration(0)
setVariablesSequence.addPause(250)
setVariablesSequence.addAnimation(setBackItemVisibleAnimation)
setVariablesSequence.addAnimation(setSelectionItemVisibleAnimation)
setVariablesSequence.addAnimation(setFillAnimation)
flipAnimation.addAnimation(setVariablesSequence)
stateMachine = QStateMachine(self)
splashState = QState(stateMachine)
frontState = QState(stateMachine)
historyState = QHistoryState(frontState)
backState = QState(stateMachine)
frontState.assignProperty(pad, "fill", False)
frontState.assignProperty(splash, "opacity", 0.0)
frontState.assignProperty(backItem, "visible", False)
frontState.assignProperty(flipRotation, "angle", 0.0)
frontState.assignProperty(selectionItem, "visible", True)
backState.assignProperty(pad, "fill", True)
backState.assignProperty(backItem, "visible", True)
backState.assignProperty(xRotation, "angle", 0.0)
#.........这里部分代码省略.........