Re: [Pyobjc-dev] A pathetic plea for understanding (MacOS X)
Brought to you by:
ronaldoussoren
From: Deirdre S. M. <de...@de...> - 2001-04-27 18:55:29
|
> > 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. ) So far, so good. I think I'm starting in a different direction than you did, which is fine. Actually, I think I may take a stab at writing the ObjC version of the HelloWorld -- that would probably help a lot (I'm not working right now, and I want to get a job as a Mac developer again, and without strong OS X skills, my options in the valley are Somewhat Limited one might say -- so this really IS "Professional Development" time for me). > > 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. Well, it helps that I understand class libraries and how they work generally, having worked with several (PowerPlant being the one I'm best at). >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! ) I've spent 13 years as a MacOS developer (mostly in C) and the last 3 years mostly on Linux, but now that OS X is shipping, I've wanted to spend more time developing for it. So I should be OK. > > 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. Aha! Well, this probably dashes my immediate hopes for the currency converter project. I think I probably could do that in Jython without too much pain (worth a stab anyway). My understanding of Python internals is limited, in part because I've never mixed it with other languages and never really needed to know about the issues of language mixing. > 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'd thought it would need wrappering, but was so encouraged to see some of the stuff you did in HelloWorld and didn't think of a possible downside. I'll claim fatigue: I was playing from 8 in the morning until 2 a.m. on various projects yesterday. >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. In your other mail, you mentioned that you'd had a stab at it. I'd be willing to attempt to browbeat it. And if Apple would ever call back about that position, I did apply to be on the ProjectBuilder team (they've called about other open positions, but not about one in that group). Bah. :) http://private.apple.com/cgi-bin/t3.cgi/tafs/extShowDescription.taf?_req=1539189 >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. ) Interesting. I was thinking Obj-C, due to its dynamic (smalltalkish) nature would make it a better fit. >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! Well, I'll keep stabbing away and asking questions. -- -- _Deirdre Stash-o-Matic: http://weirdre.com http://deirdre.net "I love deadlines. I like the whooshing sound they make as they fly by." - Douglas Adams |