Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A python lib for sending notification on OS X
# coding: utf-8
from Foundation import NSUserNotification
from Foundation import NSUserNotificationCenter
from Foundation import NSUserNotificationDefaultSoundName
def notify(message, title='Notification', sound=False):
notification = NSUserNotification.alloc().init()
notification.setTitle_(title)
notification.setInformativeText_(message)
if sound:
notification.setSoundName_(NSUserNotificationDefaultSoundName)
center = NSUserNotificationCenter.defaultUserNotificationCenter()
center.deliverNotification_(notification)
if __name__ == '__main__':
notify('This is a notification test', title='Test script', sound=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment