Hi,

I'm struggling to get an animation working. It seems that animation outside of my class work fine, however as soon as I run them from withing the class, they refuse to start. Can anyone tell me what's wrong with my code:

|import sys|
|from PySide import QtCore, QtGui|
|class| |Pixmap(QtCore.||QObject||):|
|||def __init__(self, pix):|
|||super(Pixmap, self).__init__()|
||
|||if| |type(pix) == type(||""||):|
|||pix = QtGui.||QPixmap||(pix)|
|||self.pixmap_item = QtGui.||QGraphicsPixmapItem||(pix)|
|||self.pixmap_item.setCacheMode(QtGui.||QGraphicsItem||.DeviceCoordinateCache)|
|||def set_pos(self, pos):|
|||self.pixmap_item.setPos(pos)|
|||def get_pos(self):|
|||return| |self.pixmap_item.pos()|
||
|||def get_opacity(self):|
|||return| |self.pixmap_item.opacity()|
||
|||def set_opacity(self, opacity):|
|||self.pixmap_item.setOpacity(opacity)|
|||pos = QtCore.Property(QtCore.||QPointF||, get_pos, set_pos)|
|||opacity = QtCore.Property(||float||, get_opacity, set_opacity)|
|class| |ImageWidget(QtGui.||QGraphicsView||):|
|||LastPanPoint = None|
|||CurrentCenterPoint = None|
||
|||def __init__(self, parent=None):|
|||super(ImageWidget, self).__init__(parent)|
||
|||self.setRenderHints(QtGui.||QPainter||.Antialiasing | QtGui.||QPainter||.SmoothPixmapTransform)|
||
|||# set-up the scene|
|||self.scene = QtGui.||QGraphicsScene||()|
|||self.setScene(self.scene)|
||
||
|||def loadImage(self, f):|
|||# Load image|
|||pixmap = Pixmap(f)|
|||item = pixmap.pixmap_item|
|||item.setOpacity(0)|
|||self.scene.addItem(item)|
||
|||anim = QtCore.||QPropertyAnimation||(pixmap, ||"opacity"||)|
|||anim.setDuration(10000)|
|||anim.setStartValue(0.0)|
|||anim.setEndValue(1.0)|
|||anim.setEasingCurve(QtCore.||QEasingCurve||.InOutBack)|
|||QtCore.||QTimer||.singleShot(1000, anim, QtCore.SLOT(||"start()"||))|
|||QtCore.||QObject||.connect(anim, QtCore.SIGNAL(||"finished()"||), anim, QtCore.SLOT(||"deleteLater()"||))|
||
|if| |__name__ == ||"__main__"||:|
|||a = QtGui.||QApplication||(sys.argv)|
|||view = ImageWidget()|
|||view.setGeometry(100,100, 900, 600)|
|||view.loadImage(sys.argv[1])|
||
|||view.show()|
|||a.exec_()|
_______________________________________________
PySide mailing list
[email protected]
http://lists.pyside.org/listinfo/pyside

Reply via email to