def shake(window): # window starts shifted to the right start_position = window.geometry() start_position.moveRight(start_position.right() + OFFSET_PX) # window stops in original position end_position = window.geometry() # define window shake "curve" shake_curve = QEasingCurve(QEasingCurve.OutElastic) shake_curve.setAmplitude(AMPLITUDE_PX) shake_curve.setPeriod(PERIOD_S) # define animation properties animation = QPropertyAnimation(window, b'geometry') animation.setStartValue(start_position) animation.setEndValue(end_position) animation.setDuration(DURATION_MS) animation.setEasingCurve(shake_curve) # start animation.start() return animation
def testObjectCleanup(self): for i in range(100): ec = QEasingCurve() ec.setCustomType(myFunction) self.assertEqual(ec.valueForProgress(1.0), 100.0) self.assertEqual(ec.valueForProgress(0.5), -100.0)
def testCustomType(self): ec = QEasingCurve() ec.setCustomType(myFunction) self.assertEqual(ec.valueForProgress(1.0), 100.0) self.assertEqual(ec.valueForProgress(0.5), -100.0)