[Pythonmac-SIG] noob question: handling protocols and files

Kevin Dangoor dangoor at gmail.com
Sun Aug 7 22:01:17 CEST 2005


On 8/7/05, Ronald Oussoren <ronaldoussoren at mac.com> wrote:
> > Here's the objC example from Apple's doc:
> > [appleEventManager setEventHandler:self
> > andSelector:@selector(handleGetURLEvent:withReplyEvent:)
> > forEventClass:kAEInternetSuite andEventID:kAEISGetURL];
> >
> > Here's my translation to Python:
> >             sel = objc.selector
> > (MacController.handleGetURLEvent_withReplyEvent_,
> >                 signature="vO:O:")
> >
> > aem.setEventHandler_andSelector_forEventClass_andEventID_(self,
> >                 sel,
> >                 1735750252L, 1735750252L)
> 
> 
> That's very wrong. You shouldn't call objc.selector unless you're
> defining a new method (in a class definition on the argument for
> objc.classAddMethods). The call to objc.selector should be in the
> class definition of MacController.

I was confused by @selector(handleGetURLEvent:withReplyEvent:) and the
error message I got when I tried my first intuition. My first attempt
was to just pass my Python method, but that complained saying that SEL
was expected instead of an instance method.

I really don't think I would have guessed to pass a string with the
selector name. That and the use of GURL instead of gurl was all it
took to get my program called at the right time.

The PyObjC examples are hugely useful, so this is a great addition to
the pydoc example.

Kevin


More information about the Pythonmac-SIG mailing list