2012-05-15 3 views
6

Growl을 파이썬으로 사용하지만 아무런 행운이 표시되지 않습니다. 다음 코드를 사용합니다. Growl 1.3.3을 사용하여 OSX Lion에서 실행. 누구나이게 효과가 있니? gntp파이썬에서 Growl 알림

당신은 그와 함께 더 나은 행운을 가질 수있다 : 으르렁 거리는 소리에 대한 새로운 파이썬 바인딩 라이브러리가 같은

import Growl 

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

오류 메시지? 스택 트레이스? 아니면 그냥 작동하지 않는거야? – BluePeppers

+0

그냥 작동하지 않습니다 : ( –

+0

Bit 추가 정보 Growl 1.2.2를 실행하는 OSX Lion에서 동일한 코드를 시도했지만 완벽하게 작동합니다. 그러나 Growl 1.3.3에서는 아직 행운이 없습니다. 파이썬 바인딩이 변경 되었습니까? –

답변

2

는 것 같습니다.

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

7/13/14 현재이 작동하지 않습니다. 텍스트 편집기에 복사하여 붙여 넣기하여 appscript를 설치했는지 확인하고 가져 오기 라인이없는 코드 줄에서 항상 중단됩니다. IDLE에서 "growl = app ('GrowlHelperApp')에 도착하여 다음과 같은 정보를 얻었습니다."Traceback (가장 최근의 마지막 통화) : 파일 " NameError : name 'appscript'가 정의되지 않았습니다. " – Tango

+0

@ 탱고 그리고"pip install appscript "를 실행 했습니까? –

+0

예. 지금부터는 프로그램의 여러 요소를 다루고 있기 때문에 솔직히 말해야합니다. 파이썬과 애플 스크립트, 그리고 여러 모뎀이나 알림과 통신하여, 어제 한 일을 복제 할 수 없으며, 모든 것을 똑같이하고 있다고 확신 할 수 없다. 그래서 나는 미래의 문제를 발견하면, 하지만 지금은 제대로 작동하지 않을 때 다른 작업으로 이동하고 위의 정보를 넘어서지 못했습니다. (즉, 반복해서 확인할 수는 없습니다. 가능한 경우 언제든지 다시 말씀 드리겠습니다.) – Tango