Re: [Pyobjc-dev] Re: Multiple Nibs
Brought to you by:
ronaldoussoren
From: Winston W. <cj...@ob...> - 2004-05-08 05:59:04
|
That's one thing I don't understand. In Obj C, I would call [NSBundle loadNibNamed: "myModelPanel owner: self] and this will connect 'self' to the outlets and actions for the nib. I.e. 'self' is the owner of the NIB. But with Python, you don't specify any owner. How do you choose which object gets to be the owner of the NIB file? For example, if I have: NibClassBuilder.extractClasses("MyModalPanel") myModal = MyModalPanel.alloc().init() Now MyModelPanel is a NIB file which specifies a MyModelPanelController object. So when the NIB file is unfrozen, it will create an instance of MyModelPanelController. First of all, where exactly is the NIB file unfrozen? Is it in extractClasses() or in MyModelPanel.alloc().init()? Second, how do I get a reference to MyModelPanelController? Normally I would say you attach it to an outlet of the NIB File's Owner, but where do I get a reference to the Owner? Does this make any sense? -winston On May 7, 2004, at 8:07 PM, b.bum wrote: > On May 7, 2004, at 7:06 PM, Bob Ippolito wrote: >> The showMyModalPanel looks suspicious otherwise, because if this is >> something coming from interface builder with outlets and such then >> you shouldn't be creating the objects yourself, they should be coming >> from the nib. > > In this case, I think the problem is that the second NIB file isn't > actually loaded (unless there is some code missing). > > The line of code that reads.... > >> NibClassBuilder.extractClasses("MyModalPanel") > > ... doesn't actually load the NIB itself, it just makes sure the > various classes found in the NIB are defined within the runtime. > > You will still need something like... > > if not NSBundle.loadNibNamed_owner_("MyModalPanel", self): > print "nib loading error" > > ... which is the normal Cocoa way of loading NIBs and lets you load > the NIB multiple times if you need to display multiple instances of > the NIBs contents (multiple document applications work this way). > > What Bob said about calling init() does definitely hold. If you are > just doing alloc().init(), I would recommend simply using new() to > minimize code and confusion: > > foo = MyClass.new() # same as foo = MyClass.alloc().init() > > b.bum > > > > ------------------------------------------------------- > This SF.Net email is sponsored by Sleepycat Software > Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to > deliver > higher performing products faster, at low TCO. > http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3 > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |