Search code examples
pythoncocoamacospyobjc

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.


Solution

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