I\'d like to have a python program alert me when it has completed its task by making a beep noise. Currently, I use import os
and then use a command line spee
Building on Barry Wark's answer...
NSBeep()
from AppKit works fine, but also makes the terminal/app icon in the taskbar jump.
A few extra lines with NSSound()
avoids that and gives the opportunity to use another sound:
from AppKit import NSSound
#prepare sound:
sound = NSSound.alloc()
sound.initWithContentsOfFile_byReference_('/System/Library/Sounds/Ping.aiff', True)
#rewind and play whenever you need it:
sound.stop() #rewind
sound.play()
Standard sound files can be found via commandline locate /System/Library/Sounds/*.aiff
The file used by NSBeep()
seems to be '/System/Library/Sounds/Funk.aiff'