本文整理汇总了Python中PyQt5.QtCore.QPropertyAnimation.direction方法的典型用法代码示例。如果您正苦于以下问题:Python QPropertyAnimation.direction方法的具体用法?Python QPropertyAnimation.direction怎么用?Python QPropertyAnimation.direction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QPropertyAnimation
的用法示例。
在下文中一共展示了QPropertyAnimation.direction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ScreensharingToolbox
# 需要导入模块: from PyQt5.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt5.QtCore.QPropertyAnimation import direction [as 别名]
class ScreensharingToolbox(base_class, ui_class):
exposedPixels = 3
def __init__(self, parent):
super(ScreensharingToolbox, self).__init__(parent)
with Resources.directory:
self.setupUi()
parent.installEventFilter(self)
self.animation = QPropertyAnimation(self, 'pos')
self.animation.setDuration(250)
self.animation.setDirection(QPropertyAnimation.Forward)
self.animation.setEasingCurve(QEasingCurve.Linear) # or OutCirc with 300ms
self.retract_timer = QTimer(self)
self.retract_timer.setInterval(3000)
self.retract_timer.setSingleShot(True)
self.retract_timer.timeout.connect(self.retract)
self.resize(self.size().expandedTo(self.toolbox_layout.minimumSize()))
def setupUi(self):
super(ScreensharingToolbox, self).setupUi(self)
# fix the SVG icons, as the generated code loads them as pixmaps, losing their ability to scale -Dan
scale_icon = QIcon()
scale_icon.addFile(Resources.get('icons/scale.svg'), mode=QIcon.Normal, state=QIcon.Off)
viewonly_icon = QIcon()
viewonly_icon.addFile(Resources.get('icons/viewonly.svg'), mode=QIcon.Normal, state=QIcon.Off)
screenshot_icon = QIcon()
screenshot_icon.addFile(Resources.get('icons/screenshot.svg'), mode=QIcon.Normal, state=QIcon.Off)
fullscreen_icon = QIcon()
fullscreen_icon.addFile(Resources.get('icons/fullscreen.svg'), mode=QIcon.Normal, state=QIcon.Off)
fullscreen_icon.addFile(Resources.get('icons/fullscreen-exit.svg'), mode=QIcon.Normal, state=QIcon.On)
fullscreen_icon.addFile(Resources.get('icons/fullscreen-exit.svg'), mode=QIcon.Active, state=QIcon.On)
fullscreen_icon.addFile(Resources.get('icons/fullscreen-exit.svg'), mode=QIcon.Disabled, state=QIcon.On)
fullscreen_icon.addFile(Resources.get('icons/fullscreen-exit.svg'), mode=QIcon.Selected, state=QIcon.On)
minimize_icon = QIcon()
minimize_icon.addFile(Resources.get('icons/minimize.svg'), mode=QIcon.Normal, state=QIcon.Off)
minimize_icon.addFile(Resources.get('icons/minimize-active.svg'), mode=QIcon.Active, state=QIcon.Off)
close_icon = QIcon()
close_icon.addFile(Resources.get('icons/close.svg'), mode=QIcon.Normal, state=QIcon.Off)
close_icon.addFile(Resources.get('icons/close-active.svg'), mode=QIcon.Active, state=QIcon.Off)
self.scale_action.setIcon(scale_icon)
self.viewonly_action.setIcon(viewonly_icon)
self.screenshot_action.setIcon(screenshot_icon)
self.fullscreen_action.setIcon(fullscreen_icon)
self.minimize_action.setIcon(minimize_icon)
self.close_action.setIcon(close_icon)
self.scale_button.setIcon(scale_icon)
self.viewonly_button.setIcon(viewonly_icon)
self.screenshot_button.setIcon(screenshot_icon)
self.fullscreen_button.setIcon(fullscreen_icon)
self.minimize_button.setIcon(minimize_icon)
self.close_button.setIcon(close_icon)
self.scale_button.setDefaultAction(self.scale_action)
self.viewonly_button.setDefaultAction(self.viewonly_action)
self.screenshot_button.setDefaultAction(self.screenshot_action)
self.fullscreen_button.setDefaultAction(self.fullscreen_action)
self.minimize_button.setDefaultAction(self.minimize_action)
self.close_button.setDefaultAction(self.close_action)
self.color_depth_button.clear()
self.color_depth_button.addItem('Default Color Depth', ServerDefault)
self.color_depth_button.addItem('TrueColor (24 bits)', TrueColor)
self.color_depth_button.addItem('HighColor (16 bits)', HighColor)
self.color_depth_button.addItem('LowColor (8 bits)', LowColor)
def eventFilter(self, watched, event):
if watched is self.parent() and event.type() == QEvent.Resize:
new_x = (watched.width() - self.width()) / 2
self.move(new_x, self.y())
self.animation.setStartValue(QPoint(new_x, -self.height() + self.exposedPixels))
self.animation.setEndValue(QPoint(new_x, 0))
return False
def enterEvent(self, event):
super(ScreensharingToolbox, self).enterEvent(event)
self.retract_timer.stop()
self.expose()
def leaveEvent(self, event):
super(ScreensharingToolbox, self).leaveEvent(event)
self.retract_timer.start()
def paintEvent(self, event): # make the widget style aware
option = QStyleOption()
option.initFrom(self)
painter = QStylePainter(self)
painter.drawPrimitive(QStyle.PE_Widget, option)
def expose(self):
if self.animation.state() == QPropertyAnimation.Running and self.animation.direction() == QPropertyAnimation.Forward:
return
elif self.animation.state() == QPropertyAnimation.Stopped and self.pos() == self.animation.endValue():
return
self.animation.setDirection(QPropertyAnimation.Forward)
self.animation.start()
def retract(self):
#.........这里部分代码省略.........