[Pythonmac-SIG] running Cocoa application from python

has hengist.podd at virgin.net
Fri Jun 6 15:01:04 CEST 2008


Roger Herikstad wrote:

> I'm developing a Cocoa
> application for plotting relatively large data sets (10000-100 000
> points) containing waveforms recorded from electrophysiological
> experiments. The program allows for efficient panning through the
> data, zooming, as well as other features. Since I am doing most of my
> analysis in python, the idea occurred to me to try creating an
> interface of sort to my Cocoa application using python.

Options:

1. Use IPC (e.g. Apple events, Distributed Objects) to communicate  
with your application from a separate Python process.


2. Embed a Python interpreter in your application and use PyObjC to  
interact with Cocoa objects from Python and vice-versa. (This topic  
came up last month if you check the archives.) Two variations on this:

i. embed the interpreter directly in your application (simpler)

ii. create an NSBundle-based plugin API (c.f. VoodooPad) which takes a  
suitably packaged Python interpreter or anything else you might want  
to add (more flexible).


3. Package your application's Model layer as a self-contained  
framework (as you suggest) which a Python process can import via PyObjC.


Since you're dealing with fairly large amounts of data and speed is  
presumably a requirement, that probably eliminates #1. Of #2 and #3,  
#2 is probably the easier to implement as it can easily be added to an  
existing application without having to do lots of refactoring to break  
out the Model as an independent framework. #3 might be worth  
considering if you'd have other uses for such a framework, however.

HTH

has
-- 
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net



More information about the Pythonmac-SIG mailing list