Re: [Pyobjc-dev] Re: Multiple Nibs
Brought to you by:
ronaldoussoren
From: Bob I. <bo...@re...> - 2004-05-08 02:07:11
|
I'm not sure. That code is not correct. You can't do this: myModal = MyModalPanel.alloc() myModal.init() You must do this instead: myModal = MyModalPanel.alloc().init() Or this: myModal = MyModalPanel.alloc() myModal = myModal.init() This shouldn't be unfamiliar, this is how ObjC typically works too. 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. Otherwise you should produce a minimal example and one of us will take a look at it. If this is a bug, then it may already be fixed as there have been a lot of changes recently, and there is a release right around the corner. -bob On May 7, 2004, at 9:27 PM, Winston Wolff wrote: > Has anybody responded to this? I'm having the same problem. > > -winston > >> I"m trying to set up a second NIB for a modal dialog to display >> progress >> while my application does some processing in my Mac OS X app. We >> are using >> Python 2.3 with PyObjC 1.1b1. However, the "magic" that loads the >> classes >> from the NIB file doesn"t seem to work for me. (That"s the problem >> with >> magic - it is somewhat obscure 8-) ). My guess is that I"m missing >> some >> important step, but I can"t figure out what it is and I don"t see an >> example >> that covers this. >> >> In my main application, when it is time to show the modal dialog, I >> have: >> >> from mymodalpanelclass import MyModalPanel >> >> def showMyModalPanel(self): >> myModal = MyModalPanel.alloc() >> myModal.init() >> myModal.showDialog(application) >> while <more-work-to-do>: >> <do-some-work> >> myModal.runDialog() >> myModal.closeDialog() >> >> In a secondary NIB file called "MyModalPanel.nib" I created an >> NSPanel >> window, set the class of "File"s Owner" to MyModalPanelController, >> created >> an outlet "myModalPanel" and connected it to the NSPanel window. >> >> In the file that implements MyModalPanel, I have: >> >> from PyObjCTools import NibClassBuilder >> NibClassBuilder.extractClasses("MyModalPanel") >> >> class MyModalPanelController(NibClassBuilder.AutoBaseClass): >> # the actual base class is NSObject >> # the following outlets are added to the class: >> # myModalPanel >> >> def showDialog(self, application): >> self.application = application >> self.myModalPanel.setWorksWhenModal(True) >> self._modalSession = >> self.application.beginModalSessionForWindow_(self.myModalPanel) >> >> def closeDialog(self): >> self.application.endModalSession_(self._modalSession) >> >> def runDialog(self): >> self.application.runModalSession_(self._modalSession) >> >> However, when I run this code, I find that self.myModalPanel is None >> and of >> course, nothing works. My impression was that the Panel would be >> created >> automatically when I created the MyModalPanelController instance. >> What do I >> need to do to get the NSPanel created? |