def notify(title, subtitle, info_text, delay=0, sound=False, userInfo={},
is_error=False):
icon = NSImage.alloc().initByReferencingFile_(
os.path.join(ICON_PATH, 'douban.png'))
notification = NSUserNotification.alloc().init()
notification.setTitle_(title)
notification.setSubtitle_(subtitle)
notification.setInformativeText_(info_text)
notification.setUserInfo_(userInfo)
notification.set_identityImage_(icon)
if is_error:
error_image = NSImage.alloc().initByReferencingFile_(
os.path.join(ICON_PATH, 'error.png'))
notification.setContentImage_(error_image)
if sound:
notification.setSoundName_('NSUserNotificationDefaultSoundName')
notification.setDeliveryDate_(
Foundation.NSDate.dateWithTimeInterval_sinceDate_(
delay, Foundation.NSDate.date()))
NSUserNotificationCenter.defaultUserNotificationCenter(
).scheduleNotification_(notification)
评论列表
文章目录