-
-
Save JokerQyou/1a395c2a76adbc09dcb9 to your computer and use it in GitHub Desktop.
A python lib for sending notification on OS X
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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