Пример #1
0
def create_cgpath(frame):
    newPath = CGPathCreateMutable()
    CGPathMoveToPoint(newPath, None, 0, 0)
    CGPathAddLineToPoint(newPath, None, frame.size.width, 0)
    CGPathAddLineToPoint(newPath, None, 0, frame.size.height)
    CGPathCloseSubpath(newPath)
    return newPath
Пример #2
0
    def shake(self, the_window):
        '''Uses CoreAnimation to "shake" the alert window'''
        # adapted from here:
        # http://stackoverflow.com/questions/10517386/how-to-give-nswindow-a-shake-effect-as-saying-no-as-in-login-failure-window/23491643#23491643

        numberOfShakes = 3
        durationOfShake = 0.5
        vigourOfShake = 0.05

        frame = the_window.frame()
        shakeAnimation = CAKeyframeAnimation.animation()

        shakePath = CGPathCreateMutable()
        CGPathMoveToPoint(shakePath, None, NSMinX(frame), NSMinY(frame))
        for index in range(numberOfShakes):
            CGPathAddLineToPoint(
                shakePath, None,
                NSMinX(frame) - frame.size.width * vigourOfShake, NSMinY(frame))
            CGPathAddLineToPoint(
                shakePath, None,
                NSMinX(frame) + frame.size.width * vigourOfShake, NSMinY(frame))
        CGPathCloseSubpath(shakePath)
        shakeAnimation.setPath_(shakePath)
        shakeAnimation.setDuration_(durationOfShake)

        the_window.setAnimations_({'frameOrigin': shakeAnimation})
        the_window.animator().setFrameOrigin_(frame.origin)
Пример #3
0
def create_cgpath(frame):
    newpath = CGPathCreateMutable()
    CGPathAddArc(newpath, None, 0,0, math.sqrt(frame.size.width**2 + frame.size.height**2)/2, math.radians(90), 0, True)
    CGPathAddLineToPoint(newpath, None, 0,0)
    return newpath