首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >python中的Growl通知

python中的Growl通知
EN

Stack Overflow用户
提问于 2012-05-16 04:48:15
回答 2查看 2.5K关注 0票数 7

在python中使用Growl,但对出现的任何内容都不感兴趣。使用以下代码。在OSX Lion上运行,带有咆哮1.3.3。有人把这个修好了吗?

代码语言:javascript
复制
import Growl

notifier = Growl.GrowlNotifier(applicationName='mzgrowl', notifications=['alive'])
notifier.register()
notifier.notify('alive', 'mzgrowl', 'test message')
EN

回答 2

Stack Overflow用户

发布于 2012-06-05 19:25:34

看起来像是有了一个新的python绑定库来处理growl:gntp

你可能会有更好的运气。

票数 3
EN

Stack Overflow用户

发布于 2013-03-17 13:31:31

这是另一个适用于咆哮1.2的解决方案。我没有可以测试的1.3版本。它比大多数漂浮着的解决方案都要好,因为你不需要打开咆哮网络。

来自http://wiki.python.org/moin/MacPython/Growl/AppleScriptSupport

代码语言:javascript
复制
$ pip install appscript

然后运行以下命令:

代码语言:javascript
复制
from appscript import *

# connect to Growl
growl = app('GrowlHelperApp')

# Make a list of all the notification types 
# that this script will ever send:
allNotificationsList = ['Test Notification', 'Another Test Notification']

# Make a list of the notifications 
# that will be enabled by default.      
# Those not enabled by default can be enabled later 
# in the 'Applications' tab of the growl prefpane.
enabledNotificationsList = ['Test Notification']

# Register our script with growl.
# You can optionally (as here) set a default icon 
# for this script's notifications.
growl.register(
    as_application='Growl Appscript Sample', 
    all_notifications=allNotificationsList, 
    default_notifications=enabledNotificationsList, 
    icon_of_application='PythonIDE')

# Send a Notification...
growl.notify(
    with_name='Test Notification', 
    title='Test Notification', 
    description='This is a test Appscript notification.', 
    application_name='Growl Appscript Sample')
    # You can optionally add an icon by adding one of these as the last arg:
    # icon_of_application="Script Editor.app")
    # icon_of_file="file:///Users/someone/Growl")
    # image_from_location="file:///Users/someone/pictures/stopWatch.png")

# Another one...
growl.notify(
    with_name='Another Test Notification', 
    title='Another Test Notification :) ', 
    description='Alas - you won\'t see me until you enable me...', 
    application_name='Growl Appscript Sample')
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10608678

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档