---------- Forwarded message ---------- From: Nehemiah Dacres <[EMAIL PROTECTED]> Date: May 15, 2007 1:16 PM Subject: Re: [Pythonmac-SIG] pyobjc class To: julien ricard <[EMAIL PROTECTED]>
that @ symbol means that the term is a compiler directive, in other words, its a reserved word in the Objective-C language thats how you get the method selector of a given method. find the python or pyobjc equivalent of that and use that method instead. On 5/15/07, julien ricard <[EMAIL PROTECTED]> wrote:
hi, I'm trying to convert the objective-c class iTunesConnection.h shown below to a pyobjc class. What I've done so far is shown in iTunesConnection.py. The following line nc.addObserver_selector_name_object _(self, selector(updateNow), u"com.apple.iTunes.playerInfo",None) returns an error: "global name 'selector' is not defined" I'm very new to objc and pyobjc, and I'm investigating what's wrong here, but if anybody could help... thanks! Julien ************************* iTunesConnection.h**************************************** #import <Foundation/NSDistributedNotificationCenter.h> #import <Foundation/NSString.h> #import <AppKit/NSAppleScriptExtensions.h> @interface iTunesConnection : NSObject - (id) init; @end @implementation iTunesConnection - (id) init { NSDistributedNotificationCenter *nc = [NSDistributedNotificationCenter defaultCenter]; [nc addObserver:self selector:@selector(updateNow:) name:@"com.apple.iTunes.playerInfo " object:nil]; return self; } - (void) updateNow:(NSNotification *)notification { NSString *updateScript = [NSString stringWithFormat:@"tell application \nend tell"]; NSAppleScript *as = [[[NSAppleScript alloc] initWithSource:updateScript] autorelease]; [as executeAndReturnError:nil]; } @end ***************************************************************** ************************* iTunesConnection.py**************************************** from Foundation import * class iTunesConnection(NSObject): def init(self): self = super(iTunesConnection, self).init() nc = NSDistributedNotificationCenter.defaultCenter() nc.addObserver_selector_name_object_(self, selector(updateNow), u"com.apple.iTunes.playerInfo",None) return self def updateNow(???): ???? ****************************************************************** _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
-- "lalalalala! it's not broken because I can use it" http://linux.slashdot.org/comments.pl?sid=194281&threshold=1&commentsort=0&mode=thread&cid=15927703 -- "lalalalala! it's not broken because I can use it" http://linux.slashdot.org/comments.pl?sid=194281&threshold=1&commentsort=0&mode=thread&cid=15927703
_______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig