本文整理汇总了Python中PyQt4.QtCore.QPropertyAnimation.setTargetObject方法的典型用法代码示例。如果您正苦于以下问题:Python QPropertyAnimation.setTargetObject方法的具体用法?Python QPropertyAnimation.setTargetObject怎么用?Python QPropertyAnimation.setTargetObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QPropertyAnimation
的用法示例。
在下文中一共展示了QPropertyAnimation.setTargetObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CImprovedStackWidget
# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setTargetObject [as 别名]
#.........这里部分代码省略.........
"""
if(idx > self.count()-1):
if(self.__m_vertical):
self.__direction = self.__SLIDE_TYPE.TOP2BOTTOM
else:
self.__direction = self.__SLIDE_TYPE.RIGHT2LEFT
idx = (idx) % self.count()
elif (idx<0):
if(self.__m_vertical):
self.__direction = self.__SLIDE_TYPE.BOTTOM2TOP
else:
self.__direction = self.__SLIDE_TYPE.LEFT2RIGHT
idx = (idx + self.count()) % self.count()
self.slideInWgt(self.widget(idx))
def slideInWgt(self, widget):
if self.__m_active:
return #se l'animazione e' attiva, nn faccio nulla.
else:
self.__m_active = True
now = self.currentIndex()
next = self.indexOf(widget)
if(now==next):
self.__m_active = False
return
elif(now < next):
if(self.__m_vertical):
dhint = self.__SLIDE_TYPE.TOP2BOTTOM
else:
dhint = self.__SLIDE_TYPE.RIGHT2LEFT
else:
if(self.__m_vertical):
dhint = self.__SLIDE_TYPE.BOTTOM2TOP
else:
dhint = self.__SLIDE_TYPE.LEFT2RIGHT
#=======================================================================
# if(self.__direction == self.AUTOMATIC):
# self.__direction = dhint
#=======================================================================
self.__direction = dhint
offsetX = self.frameRect().width()
offsetY = self.frameRect().height()
self.widget(next).setGeometry ( 0, 0, offsetX, offsetY )
if (self.__direction==self.__SLIDE_TYPE.BOTTOM2TOP):
offsetX=0
offsetY=-offsetY
elif (self.__direction==self.__SLIDE_TYPE.TOP2BOTTOM):
offsetX=0
elif (self.__direction==self.__SLIDE_TYPE.RIGHT2LEFT):
offsetX=-offsetX
offsetY=0
elif (self.__direction==self.__SLIDE_TYPE.LEFT2RIGHT):
offsetY=0
pnext = self.widget(next).pos()
pnow = self.widget(now).pos()
self.__m_pnow = pnow
self.widget(next).move(pnext.x() - offsetX, pnext.y() - offsetY)
self.widget(next).show()
self.__animnow.setTargetObject(self.widget(now))
self.__animnow.setDuration(self.__m_speed)
self.__animnow.setEasingCurve(self.__m_animationtype)
self.__animnow.setStartValue(QPoint(pnow.x(), pnow.y()))
self.__animnow.setEndValue(QPoint(offsetX+pnow.x(), offsetY+pnow.y()))
self.__animnext.setTargetObject(self.widget(next))
self.__animnext.setDuration(self.__m_speed)
self.__animnext.setEasingCurve(self.__m_animationtype)
self.__animnext.setStartValue(QPoint(-offsetX+pnext.x(), offsetY+pnext.y()))
self.__animnext.setEndValue(QPoint(pnext.x(), pnext.y()))
self.__animgroup.addAnimation(self.__animnow)
self.__animgroup.addAnimation(self.__animnext)
self.__m_next=next
self.__m_now=now
self.__m_active=True
self.__animgroup.start()
def __animationDone(self):
self.setCurrentIndex(self.__m_next)
self.widget(self.__m_now).hide()
self.widget(self.__m_now).move(self.__m_pnow)
self.__m_active=False
self.animationOk.emit()
示例2: CellSkin
# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setTargetObject [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):
#.........这里部分代码省略.........