Extending Python with Obj-C on MacOSX(server)?

Jeffrey P Shell jeffrey at digicool.com
Thu Jun 22 11:51:14 EDT 2000


> Has anyone any examples of how I extend Python with Apple's Cocoa layer?

Since Objective C can live alongside / inside C and C++, a long way is to
use the Python C API to write extension modules that use Objective C code
inside of them to send messages to the Cocoa framework.

Objective Everything from TipTop (www.tiptop.com) is/was a product that more
directly integrated Python/Perl/TCL into the YellowBox (now Cocoa)
framework.  I doubt it will run on MacOS X DP3 or 4 (or even any of the
earlier developer previews).  I haven't been able to execute any .app's on
my MacOS X Server partion when in DP4.  But Objective Everything has not
been updated for a long time anyways (it has Python 1.4).

A more interesting solution that I've been just lightly experimenting with
is JPython.  As long as Apple's Cocoa classes are in your class path (which
can be set by:

setenv CLASSPATH .:`javaconfig DefaultClasspath`

), you get access to all of Cocoa as described in the Java references for
the AppKit and Foundation frameworks, ie:

from com.apple.yellow import application      #AppKit
from com.apple.yellow import foundation      #FoundationKit

I've just done a *little* bit of poking around.  I've gotten some strange
memory leak errors when trying to play around with
foundation.NSGregorianDate, and I don't know if that's because the MacOS X
Java is still in development or I just haven't gone through and configured
JPython ++ Friends properly.

When the new audio subsystem for MacOS X is closer to completion (hopefully
in the upcoming beta), I plan to start developing some small tools using
Cocoa.  I haven't yet decided on whether I'm going to learn Objective C or
Java or try to extend the new ProjectBuilder (as it gets more polished) to
use JPython (ie - recognize Python files, use 'jpythonc' to compile into
Java classes from the ProjectBuilder UI).  I mainly want to be able to use
Interface Builder to define my interfaces and be not-too-many steps removed
from the core Audio API's.






More information about the Python-list mailing list