示例#1
0
文件: shake.py 项目: Terrabits/qtrf
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
示例#2
0
 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)
示例#3
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)
示例#4
0
 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)
示例#5
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)