[Pythonmac-SIG] Launching a python app with an associated document
Bob Ippolito
bob at redivi.com
Fri Jun 30 21:48:47 CEST 2006
On Jun 30, 2006, at 11:54 AM, Mike Covill wrote:
> Does anyone have experience creating a pure python app (no Cocoa
> integration) which is associated with a document extension?
>
> We would like to be able to launch our application by double-
> clicking an associated document (associated using
> CFBundleDocumentTypes in the info.plist) and having the data in the
> document loaded into the python app. I have added the following
> code to our setup.py file:
>
> plist = dict(
> CFBundleDocumentTypes = [
> dict(
> CFBundleTypeExtensions=["madf",],
> CFBundleTypeName="myApp Data File",
> CFBundleTypeRole="Editor",
> CFBundleTypeIconFile='myAppDocument.icns',
> ),
> ]
> )
>
> py2app_options = dict(...,
> plist=plist,
> )
>
> the application now launches when we double-click on the document,
> but I have yet to find how we might feed the contents of the
> document to an appropriate reader function inside our app. We had
> a look at the sys.argv list passed in to main.py thinking the name
> of the document might be in there but this doesn't seem to be the
> case. We also checked os.environ.
You want to use the argv_emulation option. OS X sends the list of
documents to open via Apple Events.
-bob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/pythonmac-sig/attachments/20060630/63adf4cf/attachment.html
More information about the Pythonmac-SIG
mailing list