How to scrub svg animation?
-
Hello. Using PyQt, I have created a little rotating triangle svg, the source for which was stolen from MDN. I create it like so:
self.animWidget = QSvgWidget('assets/images/rotating-triangle.svg', self) self.animWidget.move(200,300) self.anim = self.animWidget.children()[0] self.animTimer = self.anim.children()[0] self.uiAnimateTriangle.clicked.connect(self.animateTriangle)
How do I scrub through it, ie, set animation speed to 0 and change the time in animation? Running the following gives very weird results:
print('cf', self.anim.currentFrame()) #Prints "cf 95280", OK… self.anim.setCurrentFrame(10) print('nf', self.anim.currentFrame()) #Prints "nf 180600", wtf.
In addition, setting
self.anim.setFramesPerSecond(0)
does seem to take, but it does not pause the animation. Callingself.animTimer.stop()
seems to work, but I think it only is stopping the repaintNeeded signals from being emitted. When I emit them myself, the triangle is still animated.I'd like to have a little animated focus ring around some of my widgets, but I'm not sure how to do this if I can't control the animations.
Thanks!
-
QSvgRenderer does not give you the ability to start/stop the animation. You can only control the frame rate.
BTW. what is the self.anim object? I don't see anything relating to it in documentation. I think you may be using some private APIs here.