Re: [Pyobjc-dev] NSApplicationMain idiom: wish to standardize
Brought to you by:
ronaldoussoren
From: Ronald O. <ous...@ci...> - 2003-03-21 16:44:17
|
On Thursday, Mar 20, 2003, at 15:23 Europe/Amsterdam, Just van Rossum wrote: > I've been using the following idiom to enter the Cocoa main event loop > for > some time now: [example removed] > It's more complicated than what I originally thought was needed back > when we > discussed NSApplicationMain raising exceptions, as simply calling > NSApplicationMain() again causes the main nib to be reloaded. > > The thing is, it's quite a few lines now, and I keep copying it to new > apps. > I would like to put it in a module, but if it's deemed general enough, > I > could also integrate it into PyObjC somewhere. What do people think, > is it > desirable to have in PyObjC? I would propose a new submodule op > AppKit, eg. > named mainHelper.py. The above could then become > > from AppKit import mainHelper > mainHelper.runEventLoop() > > Better names are gladly accepted... I think this would be very usefull. However, I think this module should be in a seperate package to make it clear that this is a PyObjC helper module instead of wrapped Cocoa functionality. Foundation.Conversion should be moved to this package as well. How about PyObjCTools? - module PyObjCTools.Conversion would be the new name of Foundation.Conversion - module PyObjCTools.AppHelper would contain your function and other NSApplication related tools Speaking of NSApplicationMain... Does anyone care to offer on opinion on the enormous amount of time between the call to NSApplicationMain and the call to awakeFromNib in a simple application? That period of time takes about 4 seconds of the 5 seconds my application needs to start up (using a savagely butchered version of PyObjC, 'import AppKit' would use another 2 seconds if I hadn't build a mini module that exports all definitions I need from AppKit and Foundation). Ronald |