Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import AppKit
  4. import Foundation
  5. def notify(title, subtitle, info_text, sound=False, appImage=None, contentImage=None, delay=0):
  6. notification = Foundation.NSUserNotification.alloc().init()
  7. notification.setTitle_(title)
  8. notification.setSubtitle_(subtitle)
  9. notification.setInformativeText_(info_text)
  10. if appImage:
  11. source_img = AppKit.NSImage.alloc().initByReferencingFile_(appImage)
  12. notification.set_identityImage_(source_img)
  13. if contentImage:
  14. source_img = AppKit.NSImage.alloc().initByReferencingFile_(contentImage)
  15. notification.setContentImage_(source_img)
  16. if sound:
  17. notification.setSoundName_("NSUserNotificationDefaultSoundName")
  18. notification.setDeliveryDate_(Foundation.NSDate.dateWithTimeInterval_sinceDate_(delay, Foundation.NSDate.date()))
  19. Foundation.NSUserNotificationCenter.defaultUserNotificationCenter().scheduleNotification_(notification)
  20.  
  21. notify("Macbrained.org", "Python for the Bash Scripter", "Notify!", True )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement