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