Skip to content

Instantly share code, notes, and snippets.

@rcaldwel
Created January 28, 2013 20:42
Show Gist options
  • Save rcaldwel/4658815 to your computer and use it in GitHub Desktop.
Save rcaldwel/4658815 to your computer and use it in GitHub Desktop.
nifty
def notify(title, subtitle=None):
"""Display a NSUserNotification on Mac OS X >= 10.8"""
from objc import lookUpClass
NSUserNotification = lookUpClass('NSUserNotification')
NSUserNotificationCenter = lookUpClass('NSUserNotificationCenter')
if not NSUserNotification or not NSUserNotificationCenter:
return
notification = NSUserNotification.alloc().init()
notification.setTitle_(str(title))
if subtitle:
notification.setSubtitle_(str(subtitle))
notifcation_center = NSUserNotificationCenter.defaultUserNotificationCenter()
notifcation_center.scheduleNotification_(notification)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment