Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import AppKit
- import Foundation
- def notify(title, subtitle, info_text, sound=False, appImage=None, contentImage=None, delay=0):
- notification = Foundation.NSUserNotification.alloc().init()
- notification.setTitle_(title)
- notification.setSubtitle_(subtitle)
- notification.setInformativeText_(info_text)
- if appImage:
- source_img = AppKit.NSImage.alloc().initByReferencingFile_(appImage)
- notification.set_identityImage_(source_img)
- if contentImage:
- source_img = AppKit.NSImage.alloc().initByReferencingFile_(contentImage)
- notification.setContentImage_(source_img)
- if sound:
- notification.setSoundName_("NSUserNotificationDefaultSoundName")
- notification.setDeliveryDate_(Foundation.NSDate.dateWithTimeInterval_sinceDate_(delay, Foundation.NSDate.date()))
- Foundation.NSUserNotificationCenter.defaultUserNotificationCenter().scheduleNotification_(notification)
- notify("Macbrained.org", "Python for the Bash Scripter", "Notify!", True )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement