has wrote:
> On 10 Jul 2009, at 14:45, Brendan Simon (eTRIX) wrote:
> 
>> has wrote:
>>> Brendan Simon (eTRIX) wrote:
>>>
>>>> I have an OS X python program that is invoked via a uri on a webpage --
>>>> eg. "myapp:command"
>>>> [...]
>>> You need to install an Apple event handler that responds to the GetURL
>>> event. Various ways you can do that, depending on whether your Python
>>> application is Carbon or Cocoa based, has an event loop or runs in batch
>>> mode, uses argvemulation, etc. For more specific advice, provide more
>>> details.
>>
>> I'm using wxPython.
>>
>> I think setting argvemulation to True may be the key.
> 
> The argvemulation option uses Python 2.x's plat-mac/argvemulation.py
> module to handle incoming 'open document' Apple events, unpack their
> direct argument as a list of file paths, and add those paths to
> sys.argv. It doesn't recognise GetURL events, however.

I can confirm that the url does NOT get added to sys.argv when using
argv_emulation :(


> I've no idea if there's anything you need to watch for when Apple events
> in a wxPython-based application, so you might need to do a bit of
> research on that front. The basic code for handling a GetURL event
> should go something like this:
> 
> from Carbon import AE
> from Carbon.AppleEvents import *
> 
> 
> def geturl(requestevent, replyevent): # event handler
>     desc = requestevent.AEGetParamDesc(keyDirectObject, typeUTF8Text)
>     url = desc.data.decode('utf8')
>     # do stuff with URL here...
> 
> AE.AEInstallEventHandler(kAEInternetSuite, kAEISGetURL, geturl)
> 
> Studying the argvemulation.py module's implementation may also be
> informative.

I had a look at argv_emulation.py and it seems to have most of this
stuff already.  It handles OpenApplication and OpenDocuments Apple
Events.  Guess the 'proper' thing to do would be to extend
argv_emulation.py to handle the IsGetURL event as described above.

I will give it a go and post the results.

Cheers, Brendan.

begin:vcard
fn:Brendan Simon
n:Simon;Brendan
org:eTRIX pty ltd
adr:;;PO Box 306;St Kilda;VIC;3182;Australia
email;internet:brendan.si...@etrix.com.au
title:Managing Director
tel;work:+61-417-380-984
tel;cell:+61-417-380-984
x-mozilla-html:TRUE
version:2.1
end:vcard

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to