2012-05-15 25 views
6

在python中使用低吼,但沒有任何出現的運氣。使用下面的代碼。使用Growl 1.3.3在OSX Lion上運行。任何人都有這個工作?python中的低吼通知

import Growl 

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

錯誤消息?堆棧跟蹤?還是它不工作? – BluePeppers

+0

只是不工作:( –

+0

位有更多的信息我已經嘗試過使用OSX Lion運行Growl 1.2.2的相同代碼,它完美的工作,但仍然沒有運氣與咆哮1.3.3。有沒有python綁定更改? –

回答

2

它看起來像有一個新的Python綁定庫低吼:gntp

你可能有更好的運氣與。

0

下面是與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') 
+0

截至2013年7月13日這不起作用。複製並直接粘貼到文本編輯器中,確保我已經安裝了appscript,並且它始終在第一行代碼中斷開(沒有導入行)。在IDLE,一定要在 「咆哮=應用程序( 'GrowlHelperApp'),並得到了: 」回溯(最近通話最後一個): 文件「 」,1號線,在 咆哮= appscript.app( 'GrowlHelperApp') NameError:name'appscript'沒有定義「 – Tango

+0

@Tango你運行了」pip install appscript「嗎? –

+0

是的,我必須誠實地說,在這一點上,我正在處理一個程序的幾個不同元素,包括處理與Python和AppleScript,加上與多個調制解調器和通知溝通,現在,我不能重複我昨天做了什麼,並確保我做的都一樣 - 所以如果我發現未來的問題,我會提供更新,但就目前而言,當我無法使用它時,我轉而執行另一組任務,並沒有保留超出上述內容的信息(換句話說,我無法重複和驗證,bu如果/我可以的話,我會再次發表評論。) – Tango