Ai
3 Star 3 Fork 2

shede333/SWXcodeBuildPythonScript

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
pyNotificationCenter.py 1.37 KB
一键复制 编辑 原始数据 按行查看 历史
shede333 提交于 2013-12-13 20:30 +08:00 . 增加编译完成后的 mac系统通知
#_*_ coding:UTF-8 _*_
# Python integration with Mountain Lion's notification center
# come from https://github.com/alloy/terminal-notifier
import Foundation
import objc
NSUserNotification = objc.lookUpClass('NSUserNotification')
NSUserNotificationCenter = objc.lookUpClass('NSUserNotificationCenter')
def notify(title, subtitle, info_text, delay=0, sound=False, user_info={}):
""" Python method to show a desktop notification on Mountain Lion. Where:
title: Title of notification
subtitle: Subtitle of notification
info_text: Informative text of notification
delay: Delay (in seconds) before showing the notification
sound: Play the default notification sound
userInfo: a dictionary that can be used to handle clicks in your
app's applicationDidFinishLaunching:aNotification method
"""
notification = NSUserNotification.alloc().init()
notification.setTitle_(title)
notification.setSubtitle_(subtitle)
notification.setInformativeText_(info_text)
notification.setUserInfo_(user_info)
if sound:
notification.setSoundName_("NSUserNotificationDefaultSoundName")
notification.setDeliveryDate_(Foundation.NSDate.dateWithTimeInterval_sinceDate_(delay, Foundation.NSDate.date()))
NSUserNotificationCenter.defaultUserNotificationCenter().scheduleNotification_(notification)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/shede333/SWXcodeBuildPythonScript.git
git@gitee.com:shede333/SWXcodeBuildPythonScript.git
shede333
SWXcodeBuildPythonScript
SWXcodeBuildPythonScript
master

搜索帮助