本文整理汇总了Python中PyQt4.QtCore.QPropertyAnimation.state方法的典型用法代码示例。如果您正苦于以下问题:Python QPropertyAnimation.state方法的具体用法?Python QPropertyAnimation.state怎么用?Python QPropertyAnimation.state使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QPropertyAnimation
的用法示例。
在下文中一共展示了QPropertyAnimation.state方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ScreensharingToolbox
# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import state [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.init(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):
#.........这里部分代码省略.........
示例2: NodeBodyItem
# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import state [as 别名]
class NodeBodyItem(GraphicsPathObject):
"""
The central part (body) of the `NodeItem`.
"""
def __init__(self, parent=None):
GraphicsPathObject.__init__(self, parent)
assert(isinstance(parent, NodeItem))
self.__processingState = 0
self.__progress = -1
self.__animationEnabled = False
self.__isSelected = False
self.__hasFocus = False
self.__hover = False
self.__shapeRect = QRectF(-10, -10, 20, 20)
self.setAcceptHoverEvents(True)
self.setFlag(QGraphicsItem.ItemSendsScenePositionChanges, True)
self.setFlag(QGraphicsItem.ItemSendsGeometryChanges, True)
self.setPen(QPen(Qt.NoPen))
self.setPalette(default_palette())
self.shadow = QGraphicsDropShadowEffect(
blurRadius=3,
color=QColor(SHADOW_COLOR),
offset=QPointF(0, 0),
)
self.setGraphicsEffect(self.shadow)
self.shadow.setEnabled(True)
self.__blurAnimation = QPropertyAnimation(self.shadow, "blurRadius",
self)
self.__blurAnimation.setDuration(100)
self.__blurAnimation.finished.connect(self.__on_finished)
self.__pingAnimation = QPropertyAnimation(self, "scale", self)
self.__pingAnimation.setDuration(250)
self.__pingAnimation.setKeyValues([(0.0, 1.0), (0.5, 1.1), (1.0, 1.0)])
# TODO: The body item should allow the setting of arbitrary painter
# paths (for instance rounded rect, ...)
def setShapeRect(self, rect):
"""
Set the item's shape `rect`. The item should be confined within
this rect.
"""
path = QPainterPath()
path.addEllipse(rect)
self.setPath(path)
self.__shapeRect = rect
def setPalette(self, palette):
"""
Set the body color palette (:class:`QPalette`).
"""
self.palette = palette
self.__updateBrush()
def setAnimationEnabled(self, enabled):
"""
Set the node animation enabled.
"""
if self.__animationEnabled != enabled:
self.__animationEnabled = enabled
def setProcessingState(self, state):
"""
Set the processing state of the node.
"""
if self.__processingState != state:
self.__processingState = state
if not state and self.__animationEnabled:
self.ping()
def setProgress(self, progress):
"""
Set the progress indicator state of the node. `progress` should
be a number between 0 and 100.
"""
self.__progress = progress
self.update()
def ping(self):
"""
Trigger a 'ping' animation.
"""
animation_restart(self.__pingAnimation)
def hoverEnterEvent(self, event):
self.__hover = True
self.__updateShadowState()
return GraphicsPathObject.hoverEnterEvent(self, event)
def hoverLeaveEvent(self, event):
#.........这里部分代码省略.........
示例3: CellSkin
# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import state [as 别名]
class CellSkin(Cell):
sel_brush = QBrush(QColor("cyan"))
sel_pen = QPen(QBrush(QColor("black")), 3)
posChanged = pyqtSignal()
def __init__(self, cid, data, cons=None, props=None):
Cell.__init__(self, cid, data, cons, props)
self.skin = None
self.old_brush = None
self.old_pen = None
self.loaded = False
self.initialMove = True
self.animation = QPropertyAnimation()
# Called when we can't find the attribute, probably going
# to skin
def __getattr__(self, name):
if name in self.__dict__:
return self.__dict__[name]
return self.__dict__["skin"].__getattribute__(name)
def __del__(self):
if self.skin:
del self.skin
def getChild(self, num=0):
childs = self.skin.childItems()
if self.skin and num >= 0 and \
num < len(childs):
return childs[num]
return None
def getSkin(self):
return self.skin
def add(self, space):
if not self.loaded:
if not self.skin:
self.skin = Skin()
self.skin.xChanged.connect(self.posChanged)
self.skin.yChanged.connect(self.posChanged)
self.skin.zChanged.connect(self.posChanged)
self.skin.setPen(QPen(QBrush(QColor("black")), 1))
self.skin.setBrush(QColor("tan"))
dlog.debug("adding skin for first time: " + str(self.skin))
space.scene.addItem(self.getSkin())
self.placeChildren(space)
self.updateRect()
self.skin.setZValue(2)
self.initialMove = True
else:
dlog.debug ("adding item: " + str(self.getSkin()))
space.scene.addItem(self.getSkin())
self.loaded = True
@pyqtSlot()
def updateRect(self):
if self.skin:
self.skin.setRect(self.skin.childrenBoundingRect())
def setPos(self, center):
if self.skin:
# setPos works in terms of topLeft, but center point is
# easiest on the frontend, so convert
rect = self.getSkin().sceneBoundingRect()
topLeft = QPointF(center[0] - rect.width()/2,
center[1] - rect.height()/2)
if self.initialMove:
self.skin.setPos(topLeft)
self.skin.setTargetPos(topLeft)
self.initialMove = False
else:
self.animation.stop()
while self.animation.state() != self.animation.Stopped:
pass
self.animation.setTargetObject(self.skin)
self.animation.setPropertyName("pos")
self.animation.setDuration(1000)
self.animation.setEndValue(topLeft)
self.skin.setTargetPos(topLeft)
self.animation.start()
def remove(self, scene, cached=True):
if not self.loaded:
return
scene.removeItem(self.getSkin())
self.loaded = False
if not cached:
self.skin = None
def select(self):
# subclasses can play with these, so save them
self.old_brush = self.skin.brush()
self.old_pen = self.skin.pen()
self.skin.setBrush(self.sel_brush)
self.skin.setPen(self.sel_pen)
self.skin.setZValue(8)
def deselect(self):
#.........这里部分代码省略.........