Skip to content

Instantly share code, notes, and snippets.

@davelab6
Forked from typemytype/motivation.py
Created October 17, 2015 14:00
Show Gist options
  • Save davelab6/44a569df3f1103fccadf to your computer and use it in GitHub Desktop.
Save davelab6/44a569df3f1103fccadf to your computer and use it in GitHub Desktop.
from mojo.events import addObserver
from AppKit import NSSound, NSURL
path = u"http://soundbible.com/grab.php?id=1995&type=mp3"
url = NSURL.URLWithString_(path)
sound = NSSound.alloc().initWithContentsOfURL_byReference_(url, False)
class SomeMotivation(object):
def __init__(self):
addObserver(self, "mouseDragged", "mouseDragged")
def mouseDragged(self, notification):
if sound.isPlaying():
return
glyph = notification["glyph"]
sel = glyph.selection
if len(sel) == 1 and sel[0].type == "offCurve":
sound.play()
SomeMotivation()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment