Re: [Pyobjc-dev] Altered classes
Brought to you by:
ronaldoussoren
From: Bill B. <bb...@CO...> - 2001-05-11 20:26:17
|
The original method was something like "loadNibNamed:owner:" -- i.e. it takes two arguments and has two :'s. The Python mangled version is "loadNibNamed_owner_", as a result. There is a lot more that goes on ApplicationMain and in the startup of the application than you might otherwise expect given evidence at runtime. In particular, there is all kinds of binding to the Finder and the WindowServer, etc... I know why the Application delegate stuff isn't working and how to fix it. I'll try to do so on the train home tonight and commit the code tonight/tomorrow. It ain't pretty but, thankfully, I solved the problem before. (If interested, see the mssh project-- http://www.codefab.com/pub/unsupported. While there, see NoisyAppKit-- it spews everything that happens at app launch on mach ports...). b.bum On Friday, May 11, 2001, at 04:12 PM, Deirdre Saoirse Moen wrote: >> Basically, pyobjc mangles the ObjC selector names by substituting _ >> for each : (because : is reserved in python). > > I guess what I don't understand is why the *trailing* underscore. I did > understand the underscore bit though. > >> As well, there will be a certain line beyond which we really, really, >> really need to have the Main Event Loop running to do anything from >> Python to the Appkit... > > Understandable. In looking through AppKit, it seems that it loads all > the stuff prior to the main loop, but I could be wrong. Basically I was > trying it before running the app, but maybe that's the wrong approach. > > If you look at the Main file from an existing PB project, this is what > it looks like these days: > > #import <Cocoa/Cocoa.h> > > int main(int argc, const char *argv[]) > { > return NSApplicationMain(argc, argv); > } > > Maybe the Nib loading problem is from trying to use something other > than that specific function? > > Unfortunately, in the example below, it doesn't exist: > > import pyobjc > import sys > > rt = pyobjc.runtime > > def main(): > > pool = rt.NSAutoreleasePool() > # Load Application Framework: > foundationKit = rt.NSBundle.bundleWithPath_( > '/System/Library/Frameworks/Foundation.framework').load() > appKit = rt.NSBundle.bundleWithPath_( > '/System/Library/Frameworks/AppKit.framework').load() > > Doc = rt.NSDocument.alloc() > Nib = rt.NSBundle.loadNibNamed_owner_("MainMenu.nib", Doc) > # print Nib > > return rt.NSApplicationMain(len(sys.argv), sys.argv) > > if __name__ == '__main__' : > main() > > >> Has anyone tried creating a Python object and setting it as NSApp's >> delegate, then seeing if you could grab notifications?? > > Since people have tried this, I'd be interested in what *everyone* has > tried, what did work and what didn't. I can make a coherent document > out of it and then maybe that will open the door for other "bang and > slash" people to try and figure out stuff. Then it won't be so lonely > here. :) > > -- _Deirdre Stash-o-Matic: http://weirdre.com > http://deirdre.net > Macintosh Developer (seeking work): Will work for Cocoa > "I love deadlines. I like the whooshing sound they make as they fly by." > - Douglas Adams |