本文整理汇总了Python中PyQt5.QtCore.QPropertyAnimation.setCurrentTime方法的典型用法代码示例。如果您正苦于以下问题:Python QPropertyAnimation.setCurrentTime方法的具体用法?Python QPropertyAnimation.setCurrentTime怎么用?Python QPropertyAnimation.setCurrentTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QPropertyAnimation
的用法示例。
在下文中一共展示了QPropertyAnimation.setCurrentTime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: NotifyWidget
# 需要导入模块: from PyQt5.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt5.QtCore.QPropertyAnimation import setCurrentTime [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)