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'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.
HTH
has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net
_______________________________________________
Pythonmac-SIG maillist - Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig