本文整理汇总了Python中PyQt5.QtCore.QPropertyAnimation方法的典型用法代码示例。如果您正苦于以下问题:Python QtCore.QPropertyAnimation方法的具体用法?Python QtCore.QPropertyAnimation怎么用?Python QtCore.QPropertyAnimation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore
的用法示例。
在下文中一共展示了QtCore.QPropertyAnimation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getDetailInfo
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QPropertyAnimation [as 别名]
def getDetailInfo(self):
"""点击后进行动画效果的: 显示某歌曲的详细信息。"""
self.shortInfo.hide()
self.detailInfo.show()
self.showDetail = QPropertyAnimation(self, b"geometry")
x = self.pos().x()
y = self.pos().y()
self.showDetail.setStartValue(QRect(x, y, self.width(), self.height()))
# 获取顶层父窗口的长度。
self.showDetail.setEndValue(QRect(0, self.grandparent.header.height()+3, self.grandparent.width(), self.grandparent.mainContent.height()))
self.showDetail.setDuration(300)
self.showDetail.setEasingCurve(QEasingCurve.InBack)
self.showDetail.start(QAbstractAnimation.DeleteWhenStopped)
# 将该组件显示在最前,默认会嵌入到父组件里面。
self.raise_()
self.setDetailInfo()
示例2: getShortInfo
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QPropertyAnimation [as 别名]
def getShortInfo(self):
"""返回到原来的缩略图信息。"""
self.detailInfo.hide()
self.showShort = QPropertyAnimation(self, b"geometry")
x = self.pos().x()
y = self.pos().y()
self.showShort.setStartValue(QRect(0, self.grandparent.header.height(), self.grandparent.width(), self.grandparent.mainContent.height()))
self.showShort.setEndValue(QRect(0, self.grandparent.height()-64-self.parent.height(), self.grandparent.navigation.width(), 64))
self.showShort.setDuration(300)
self.showShort.setEasingCurve(QEasingCurve.InBack)
self.showShort.start(QAbstractAnimation.DeleteWhenStopped)
self.shortInfo.show()
self.raise_()
示例3: __init__
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QPropertyAnimation [as 别名]
def __init__(self, parent):
"""
Create property animations, sets the opacity to zero initially.
:param parent:
"""
super().__init__()
if isinstance(parent, QtWidgets.QGraphicsItem):
# create opacity effect
self.effect = QtWidgets.QGraphicsOpacityEffect()
self.effect.setOpacity(0)
parent.setGraphicsEffect(self.effect)
self.fade = QtCore.QPropertyAnimation(self.effect, 'opacity'.encode()) # encode is utf-8 by default
elif isinstance(parent, QtWidgets.QWidget):
parent.setWindowOpacity(0)
self.fade = QtCore.QPropertyAnimation(parent, 'windowOpacity'.encode()) # encode is utf-8 by default
else:
raise RuntimeError('Type of parameter must be QtWidgets.QGraphicsItem or QtWidgets.QWidget.')
# set start and stop value
self.fade.setStartValue(0)
self.fade.setEndValue(1)
self.fade.finished.connect(self.finished)
self.forward = True
示例4: __init__
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QPropertyAnimation [as 别名]
def __init__(self, *args, stretch=1 / 3, direction=0, widget=None, **kwargs):
super(CDrawer, self).__init__(*args, **kwargs)
self.setWindowFlags(self.windowFlags(
) | Qt.FramelessWindowHint | Qt.Popup | Qt.NoDropShadowWindowHint)
self.setAttribute(Qt.WA_StyledBackground, True)
self.setAttribute(Qt.WA_TranslucentBackground, True)
# 进入动画
self.animIn = QPropertyAnimation(
self, duration=500, easingCurve=QEasingCurve.OutCubic)
self.animIn.setPropertyName(b'pos')
# 离开动画
self.animOut = QPropertyAnimation(
self, duration=500, finished=self.onAnimOutEnd,
easingCurve=QEasingCurve.OutCubic)
self.animOut.setPropertyName(b'pos')
self.animOut.setDuration(500)
self.setStretch(stretch) # 占比
self.direction = direction # 方向
# 半透明背景
self.alphaWidget = QWidget(
self, objectName='CDrawer_alphaWidget',
styleSheet='#CDrawer_alphaWidget{background:rgba(55,55,55,100);}')
self.alphaWidget.setAttribute(Qt.WA_TransparentForMouseEvents, True)
self.setWidget(widget) # 子控件
示例5: __init__
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QPropertyAnimation [as 别名]
def __init__(self, y_pos, up=True):
super().__init__()
self.up = up
self.y_pos = y_pos
# For fun, let's blur the object
blur = qtw.QGraphicsBlurEffect()
blur.setBlurRadius(10)
blur.setBlurHints(
qtw.QGraphicsBlurEffect.AnimationHint)
self.setGraphicsEffect(blur)
# Animate the object
self.animation = qtc.QPropertyAnimation(self, b'y')
self.animation.setStartValue(y_pos)
end = 0 if up else SCREEN_HEIGHT
self.animation.setEndValue(end)
self.animation.setDuration(1000)
self.yChanged.connect(self.check_collision)
开发者ID:PacktPublishing,项目名称:Mastering-GUI-Programming-with-Python,代码行数:21,代码来源:tankity_tank_tank_tank.py
示例6: decrypt_content
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QPropertyAnimation [as 别名]
def decrypt_content(self, data, password):
self.progress = QProgressDialog("Trying to decrypt...", None, 0, 100)
self.progress.show()
self.animation = QPropertyAnimation(self.progress, b"value")
self.animation.setDuration(5000) # XXX
self.animation.setStartValue(0)
self.animation.setEndValue(99)
self.animation.start()
self.crypter = Crypter(data, password.encode())
self.crypter_thread = QThread()
self.crypter.moveToThread(self.crypter_thread)
self.crypter.succeeded.connect(self.animation.stop)
self.crypter.succeeded.connect(self.progress.close)
self.crypter.succeeded.connect(self.on_decryption_succeeded)
self.crypter.failed.connect(self.animation.stop)
self.crypter.failed.connect(self.progress.close)
self.crypter.failed.connect(self.on_decryption_failed)
self.crypter_thread.started.connect(self.crypter.decrypt)
self.crypter_thread.start()
示例7: setFadeIn
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QPropertyAnimation [as 别名]
def setFadeIn(self, v):
"""
Set the screen to use a fade-in animation.
Args:
v (bool): If True, run the fade-in animation when its trigger is
received. False will disable the animation.
"""
if not v:
self.animations.pop(FADE_IN_ANIMATION, None)
return
effect = QtWidgets.QGraphicsOpacityEffect(self)
self.animations[FADE_IN_ANIMATION] = a = QtCore.QPropertyAnimation(
effect, b"opacity"
)
a.setDuration(550)
a.setStartValue(0)
a.setEndValue(1)
a.setEasingCurve(QtCore.QEasingCurve.OutQuad)
self.setGraphicsEffect(effect)
示例8: animategroup
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QPropertyAnimation [as 别名]
def animategroup(self, widgets, color):
self.changeanimationgroup = QParallelAnimationGroup()
for widget in widgets:
effect = QtWidgets.QGraphicsColorizeEffect(widget)
widget.setGraphicsEffect(effect)
anim = QtCore.QPropertyAnimation(effect, b"color")
anim.setDuration(500)
anim.setStartValue(QtGui.QColor(0, 0, 0))
anim.setKeyValueAt(0.25, color)
anim.setEndValue(QtGui.QColor(0, 0, 0))
self.changeanimationgroup.addAnimation(anim)
self.changeanimationgroup.start()
开发者ID:HA6Bots,项目名称:Automatic-Youtube-Reddit-Text-To-Speech-Video-Generator-and-Uploader,代码行数:14,代码来源:scripteditor.py
示例9: _perform_move
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QPropertyAnimation [as 别名]
def _perform_move(self, a, pos):
from PyQt5.QtCore import QPropertyAnimation
# create animation for this move operation
anim = QPropertyAnimation(a, b'pos')
anim.setDuration(200)
anim.setEndValue(pos)
anim.start()
# the QPropertyAnimation object must outlive this method, so we attach it to this instance
# TODO we should really collect it afterwards, perhaps with a handler for the finished() signal...
self.animations.append(anim)
示例10: _perform_swap
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QPropertyAnimation [as 别名]
def _perform_swap(self, a, b):
from PyQt5.QtCore import QPointF, QPropertyAnimation
elt_a = self.elements[a]
elt_b = self.elements[b]
# update positions
pos_a = elt_a.pos
pos_b = elt_b.pos
# animate the exchange: move in an arc above/below a point halfway between
pos_between = (pos_a + pos_b) / 2
pos_above = QPointF(pos_between.x(), -10)
pos_below = QPointF(pos_between.x(), 50)
anim_a = QPropertyAnimation(self.elements[a], b'pos')
anim_b = QPropertyAnimation(self.elements[b], b'pos')
anim_a.setDuration(400)
anim_b.setDuration(400)
anim_a.setKeyValueAt(0.5, pos_above)
anim_b.setKeyValueAt(0.5, pos_below)
anim_a.setKeyValueAt(1, pos_b)
anim_b.setKeyValueAt(1, pos_a)
anim_a.start()
anim_b.start()
self.animations.append(anim_a)
self.animations.append(anim_b)
# update elements list
self.elements[a] = elt_b
self.elements[b] = elt_a
示例11: __init__
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QPropertyAnimation [as 别名]
def __init__(self, main_window, notes_only, contentView, parent=None):
super(PliantDockWidget, self).__init__(parent)
self.main_window = main_window
self.notes_only = notes_only
self.contentView = contentView
self.current_annotation = None
self.parent = parent
# Models
# The following models belong to the sideDock
# bookmarkModel, bookmarkProxyModel
# annotationModel
# searchResultsModel
self.bookmarkModel = None
self.bookmarkProxyModel = None
self.annotationModel = None
self.searchResultsModel = None
# References
# All widgets belong to these
self.bookmarks = None
self.annotations = None
self.search = None
# Widgets
# Except this one
self.sideDockTabWidget = None
# Animate appearance
self.animation = QtCore.QPropertyAnimation(self, b'windowOpacity')
self.animation.setStartValue(0)
self.animation.setEndValue(1)
self.animation.setDuration(200)
示例12: showTip
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QPropertyAnimation [as 别名]
def showTip(self, text, color='#20c3ff'):
if self.tipLabel is not None:
self.tipLabel.show()
self.tipLabel.setStyleSheet(
"QLabel{background: %s;border:3px; color: #FFFFFF; border-radius: 5px}" % color)
self.tipLabel.setText(text)
eff = QGraphicsOpacityEffect(self)
self.tipLabel.setGraphicsEffect(eff)
self.animate = QPropertyAnimation(eff, "opacity")
self.animate.setDuration(2000)
self.animate.setStartValue(0.8)
self.animate.setEndValue(0)
self.animate.setEasingCurve(QEasingCurve.InCubic)
self.animate.finished.connect(lambda: self.tipLabel.hide())
self.animate.start()
示例13: mouseReleaseEvent
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QPropertyAnimation [as 别名]
def mouseReleaseEvent(self, event): # pylint: disable=invalid-name
super().mouseReleaseEvent(event)
if event.button() == Qt.LeftButton:
anim = QPropertyAnimation(self, b"offset", self)
anim.setDuration(120)
anim.setStartValue(self.offset)
anim.setEndValue(self._end_offset[self.isChecked()]())
anim.start()
示例14: change_show_input_cookie
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QPropertyAnimation [as 别名]
def change_show_input_cookie(self):
row_c = 4 if is_windows else 3
if self.form.rowCount() < row_c:
self.org_height = self.height()
self.form.addRow(self.cookie_lb, self.cookie_ed)
self.show_input_cookie_btn.setText("隐藏Cookie输入框")
self.change_height = None
self.adjustSize()
else:
if not self.change_height:
self.change_height = self.height()
if self.cookie_ed.isVisible():
self.cookie_lb.setVisible(False)
self.cookie_ed.setVisible(False)
self.show_input_cookie_btn.setText("显示Cookie输入框")
start_height, end_height = self.change_height, self.org_height
else:
self.cookie_lb.setVisible(True)
self.cookie_ed.setVisible(True)
self.show_input_cookie_btn.setText("隐藏Cookie输入框")
start_height, end_height = self.org_height, self.change_height
gm = self.geometry()
x, y = gm.x(), gm.y()
wd = self.width()
self.animation = QPropertyAnimation(self, b'geometry')
self.animation.setDuration(400)
self.animation.setStartValue(QRect(x, y, wd, start_height))
self.animation.setEndValue(QRect(x, y, wd, end_height))
self.animation.start()
示例15: mousePressEvent
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QPropertyAnimation [as 别名]
def mousePressEvent(self, event):
if event.button() == Qt.LeftButton:
self.mover.setY(1)
if event.pos().x() < Frame.VALOR / 2:
self.mover.setX(Frame.MIN_VALOR)
elif event.pos().x() > Frame.VALOR / 2:
self.mover.setX(Frame.MAX_VALOR - self.parent.button.width())
self.animacion = QPropertyAnimation(self.parent.button, b"pos")
self.animacion.setDuration(150)
self.animacion.setEndValue(self.mover)
self.animacion.valueChanged.connect(self.actualizarEstado)
self.animacion.finished.connect(self.emitirEstado)
self.animacion.start(QAbstractAnimation.DeleteWhenStopped)