Skip to content

Instantly share code, notes, and snippets.

@typemytype
Created October 9, 2015 22:43
Show Gist options
  • Save typemytype/2578e1e860042d2f6d47 to your computer and use it in GitHub Desktop.
Save typemytype/2578e1e860042d2f6d47 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