I do like to extend this answer especially the blink
function to change the geometry of the label setGeometry
, in particular, the starting coordinates of the label.
So according to duration, the label will change not only the color but also the position(Geometry) periodically.
Can you please tell me if that is possible (without blocking loops) and how can I do it please? thanks in advance.
CodePudding user response:
Thanks to the suggestion of @musicamante here is the solution:
self.pos_anim = QPropertyAnimation(self, b"geometry")
def alarm_alert(self, pos1, pos2, duration=3000):
"""
Function: alarm_alert, to alarm the motion of the Animated QLabel.
---
Parameters:
@param: pos1, QRect, geometry of first position.
@param: pos2, QRect, geometry of second position.
@param:duration, int, motion duration in ms.
---
@return: None
"""
self.pos_anim.stop()
self.pos_anim.setDuration(duration)
self.pos_anim.setStartValue(pos2)
self.color_anim.setKeyValueAt(0.2, pos2)
self.color_anim.setKeyValueAt(0.6, pos1)
self.color_anim.setKeyValueAt(0.2, pos2)
self.pos_anim.setEndValue(pos1)
self.pos_anim.setLoopCount(-1)
self.pos_anim.start()