[Pythonmac-SIG] noob question: handling protocols and files
Bob Ippolito
bob at redivi.com
Mon Aug 8 00:30:38 CEST 2005
On Aug 7, 2005, at 10:01 AM, Kevin Dangoor wrote:
> 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.
That should've worked.
> 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.
Selectors themselves are just interned char*
-bob
More information about the Pythonmac-SIG
mailing list