Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running python code from standard Cocoa application

I have an XCode project built as a Cocoa single document application (it's not a Python-Cocoa application, that is not what I want).

All the documentation I found assumes I want to create a Cocoa application with code written in Python and this is not the case - I want a standard Cocoa application that calls a method out of a Python class.

Can I use PyObjC to run python code from a file without replacing the Cocoa standard main.c with a main.py file?

Later edit: I am aware of Python.framework but as far as I can tell I can only send parameters to PyRun_SimpleFile through the environment - I'd like to use the bridge directly to exchange data with the python code.

like image 730
diciu Avatar asked Apr 21 '09 11:04

diciu


1 Answers

A google search for embed python objective C, returns a few links that might be of interest, in particular:

  • http://blog.alienoverlord.com/?p=14
  • http://blog.tlensing.org/2008/11/04/embedding-python-in-a-cocoa-application/
like image 88
codeape Avatar answered Sep 18 '22 23:09

codeape