[Pyobjc-dev] Multiple Nibs
Brought to you by:
ronaldoussoren
From: Bob S. <rsw...@tr...> - 2004-03-30 16:39:54
|
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? Thanks! - Bob |