Re: [Pyobjc-dev] Embedding Python in an ObjC application
Brought to you by:
ronaldoussoren
From: Ronald O. <ron...@ma...> - 2004-06-14 20:42:21
|
On 14-jun-04, at 22:26, Dan Grassi wrote: > Hi, > > I want to use python from a Cocoa application other than as a class in > a .nib file. I have this working somewhat but there are a couple of > problems: > > 1) I need to run on 10.2.x and above but PyObjC is not not included in > 10.2.x. Thus I would like to embed the Python framework in my > application. > > 2) While my example runs with ZeroLink enabled I get a linker error > with ZeroLink disabled: > ld: Undefined symbols: > .objc_class_name_TestPy > > I use the basic files from the SimpleConboBoxPlus example: > PythonGlue.h > PythonGlue.m > PythonGlue.py > > I added to the top of main() in main.m: > NSAutoreleasePool* pythonAutoreleasePool = [[NSAutoreleasePool alloc] > init]; > [[PythonGlue alloc] init]; > > I added the following resource file TestPy.py: > from Foundation import * > class TestPy(NSObject): > def test(self): > print "TestPy:test" > > In my application I added: > [[[TestPy alloc] init] test]; This line causes the link error, use [[[NSClassFromString(@"TestPy") alloc] init] test]; instead. Ronald -- X|support bv http://www.xsupport.nl/ T: +31 610271479 F: +31 204416173 |