Re: [Pyobjc-dev] A pathetic plea for understanding (MacOS X)
Brought to you by:
ronaldoussoren
From: Steven D. M. <sd...@mi...> - 2001-04-27 18:18:23
|
On Thu, 26 Apr 2001, Deirdre Saoirse Moen wrote: > I heard about this project on the Jython list and, frankly, it seems > a more straightforward way of handling the problem of making > ProjectBuilder/InterfaceBuilder projects. > > The catch: I have a lot of python experience, but not a lot mixing it > with other languages. Even looking through the archives, it's not > clear to me what is done and what might need to be done. The best thing for now is probably to look at and try the HelloWorld program I posted a while back, and look at the apple docs for the Cocoa classes used. If there's anything you don't understand about it, ask and I'll try to explain. ( I probably should do a version of the same program in objective C for comparison, and maybe annotate the example a bit more. ) > To put it simply, I want to build Cocoa projects and code them in > Python. I'm learning ObjC (I learned it a few years ago but not > enough to get fully over the learning curve) and I don't know Java. Hehe! ;-) That's sort of what I was hoping for when I got involved. The truth is that it's not really much of a shortcut right now -- you have to be able to understand enough objective-c to read and understand the apple Foundation and AppKit docs. One the bright side, if you already know C, you can .literally. learn objective-C in a day. ( Learning the whole class library is another matter! ) And I've been learning lots about the objc runtime by hacking on PyObjC. ( If you don't know C, I'm afraid that's not a very bright side! ) > This means I'll want to subclass Cocoa classes in Python -- how close > is this project to allowing me to do that? Is there some kind of > guide for how I'd do it either in Jython OR PyObjC? (Ultimately, I'd > like to try it both ways -- and I'd be more than happy to put up a > page detailing what has to be done). You can't subclass Cocoa classes in Python -- objective C classes are Python objects but not Python classes. This is the notorious class/object barrier in Python, and why you need wrapper classes around dicts and lists and can't directly subclass them. You could do the same thing: write a Python wrapper around an objective C class and subclass that. I'm not sure how I could write a universal wrapper for all objective-C classes without adding more introspection capabilities (which is something that's planned, but not built in -- it can be done with the Neo class inspector -- I'll have to put up some updated instructions on how to get and use that from Python -- you can grab the standalone app at: <http://www.neodata-inc.com/Eng/Self_Introspector.html> ) I would have to say it's not ready for prime time yet. I don't think you could write a whole non-toy Cocoa app with Python at present. I haven't been able to get delegate objects working properly -- which, in the absence of direct subclassing is probably a requirement. I think I'm going to have to build an objc-runtime lib from Darwin sources with debugging info, because I haven't been able to locate the problem with gdb. I have high hopes for it eventually -- some Apple folks on other mainling lists have indicated an interest on their part in opening up ProjectBuilder/InterfaceBuilder to support other languages, but I haven't yet figured out how to reanimate a IB Nib file from Python yet. There's a lot of stuff I haven't explored fully yet: for example, you can load your own objective-C classes as easily as you can load the AppKit classes. (I've done this with the NeoData class inspector) and I can say there's a lot less "impedence difference" between Python and objective-C than between Python and C -- it makes mixed language programming much easier. I haven't explored the notion of doing most of a application framework in objective-C and scripting/customizing it from Python, but this would probably work right now. ( Although getting the delegates working would make it better. ) I would have to admit that right now, PyObjC is mostly for the adventurous hacker -- but I would sure like to get a few more adventurous souls to take a hack at it! -- Steve Majewski |