MacOS10.10通知中心的Python包装器
pync的Python项目详细描述
围绕terminal-notifier命令行工具(版本2.0.0)的一个简单的python包装器,它允许您在macosx10.10或更高版本上向通知中心发送用户通知。
安装
pip install pync
或
pip install git+https://github.com/SeTeM/pync.git
或
git clone git://github.com/SeTeM/pync.git
cd pync
python setup.py install
用法
有关所有选项的完整信息,请参见工具的README。
示例:
使用通知功能
importpyncpync.notify('Hello World')pync.notify('Hello World',title='Python')pync.notify('Hello World',group=os.getpid())pync.notify('Hello World',activate='com.apple.Safari')pync.notify('Hello World',open='http://github.com/')pync.notify('Hello World',execute='say "OMG"')pync.remove_notifications(os.getpid())pync.list_notifications(os.getpid())
使用通知程序对象
frompyncimportNotifierNotifier.notify('Hello World')Notifier.notify('Hello World',title='Python')Notifier.notify('Hello World',group=os.getpid())Notifier.notify('Hello World',activate='com.apple.Safari')Notifier.notify('Hello World',open='http://github.com/')Notifier.notify('Hello World',execute='say "OMG"')Notifier.remove(os.getpid())Notifier.list(os.getpid())