Pyobjc 2.4 doesn't work with Growl on SL and below

Issue #31 resolved
Former user created an issue

This is rather strange. If I run the code below on Lion using pyobjc 2.4a0 I see a Growl message. If I run it in Snow Leopard using pyobjc 2.4a0 it doesn't work. But if I run it using pyobjc 1.4.1a0 it works again. I'm using Growl SDK 1.2.1.

#!/usr/bin/env python -i

# May 12, 2007
# by tooru
# clickable growl example
# requires pyobjc and growl.framework

import objc
from Foundation import *
from AppKit import *
from PyObjCTools import NibClassBuilder, AppHelper
import time

# load Growl.framework
myGrowlBundle=objc.loadBundle("GrowlApplicationBridge", globals(), bundle_path=objc.pathForFramework(

# growl delegate
class rcGrowl(NSObject):

    def rcSetDelegate(self):


    def registrationDictionaryForGrowl(self):

        return {u'ApplicationName':u'rcGrowlMacTidy',u"AllNotifications":[u'test1'],u"DefaultNotifications":[u'test1']}

    # don't know if it is working or not
    def applicationNameForGrowl(self):
        return u'rcGrowlMacTidy'

    # the method below is called when notification is clicked
    def growlNotificationWasClicked_(self,clickContextS):

        print ''
        print 'clicked at',time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.localtime())
        print 'clickContextS =',clickContextS

    # the method below is called when notification is timed out
    def growlNotificationTimedOut_(self,clickContextS):

        print ''
        print 'timeout at',time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.localtime())
        print 'clickContextS =',clickContextS

    # doesn't seem to work
    def growlIsReady(self):

        print 'growl IS READY'

# delegate for setting up NSStatusitem 
class Timer(NSObject):

    statusbar = None
    state = 'idle'

    def applicationDidFinishLaunching_(self, notification):
        statusbar = NSStatusBar.systemStatusBar()
        # Create the statusbar item
        self.statusitem = statusbar.statusItemWithLength_(NSVariableStatusItemLength)

        # Let it highlight upon clicking
        # Set a tooltip
        # Set an initial title

        # Build a very simple menu = NSMenu.alloc().init()

        menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Popup notification', 'rcNotification:', '')
        # Default event
        menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Quit', 'terminate:', '')
        # Bind it to the status item

    def rcNotification_(self,notification):

        print ''
        print time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.localtime()), 'Growl notification...'

            u'myTitle',u'test',u'test1',None,0,False,time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.localtime()))

if __name__ == "__main__":

    # set up system statusbar GUI
    app = NSApplication.sharedApplication()
    delegate = Timer.alloc().init()

    # set up growl delegate


Comments (4)

  1. Ronald Oussoren repo owner

    It is unclear what's going on here.

    1) I got this to work on a 10.5 system by going into the Growl preference pane
    and looking at the list of options for a notification.

    2) Once is started working I couldn't break it anymore on that machine.

  2. Ronald Oussoren repo owner

    The attached patches seems to fix most of the issue.

    One open problem left: Python integers need to be converted to NSNumber, otherwise it still won't work. I'm working on a patch for that.

    Note: the registration dict must contain an 'ApplicationId' key on the version of Growl that I tested with.

  3. Ronald Oussoren repo owner

    TODO: investigate if it is possible to encode dict, list, tuple and set instances as well in a way that allows decoding in pure Objective-C processes (again ignoring subclasses of those types).

    This likely requires the introduction of helper classes for encoding type information, and might only work for keyed archivers.

  4. Log in to comment