下面是與Growl 1.2配合使用的另一個解決方案。我沒有1.3來測試。這比大部分解決方案都要好,因爲你不必打開咆哮網絡。
從http://wiki.python.org/moin/MacPython/Growl/AppleScriptSupport:
$ pip install appscript
並運行此:
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')
錯誤消息?堆棧跟蹤?還是它不工作? – BluePeppers
只是不工作:( –
位有更多的信息我已經嘗試過使用OSX Lion運行Growl 1.2.2的相同代碼,它完美的工作,但仍然沒有運氣與咆哮1.3.3。有沒有python綁定更改? –