Re: [Pyobjc-dev] Controller Layer
Brought to you by:
ronaldoussoren
From: Carlos P. <car...@ma...> - 2003-12-02 03:21:28
|
Hi, I sent the following email to Bill (b.bum): > There is something fundamental about the key-value binding that I don' > t understand. I have been using it extensively in objective-c, but I > can't seem to be able to use it to connect to a nib in PyObjC. Here is > a sample python class I use: > > # Converter.py: > import objc > > class Converter(objc.runtime.NSObject): > def getAmount(self): > return "1" > if __name__ == "__main__": > AppHelper.runEventLoop() > > > Now I create a MainMenu.nib which has a window with a single > NSTextField. In the nib, I instantiate an empty definition of > Converter in the nib. Converter is defined as a subclass of NSObject. > I then create an instance of NSController, add an "amount" key and > bind the value of the text field to it. Finally, I connect the > Converter instance to the "content" outlet of the NSController. This > is the exact setup I used in an obj-c version of this test. > > I run the following buildapp.py script to make this into a program > > from bundlebuilder import buildapp > buildapp( > mainprogram = "Converter.py", > resources = ["English.lproj" ], > nibname = "MainMenu", > ) > > The result is a sementation fault. What am I doing wrong? He responded as follows: > This'd be an objc/c problem -- if the app is crashing and giving you > the "submit crash report" panel, then click "submit" and copy/paste > the backtrace found in the resulting window. If not, have a look in > ~/Library/Logs/ and see if there is a log there. > > Otherwise, you'd need to run under gdb. > > Try adding... > > def automaticallyNotifiesObserversForKey_(self, aKey): > return NO > > ... to your class and see if that fixes the problem. Also, make sure > you are running pyobjc based on the latest source from CVS -- there > have been many updates that are 10.3 specific. > > Finally, we should continue this on pyobjc-dev. I'm really busy @ > Apple and will likely not have time to answer you in the coming days > -- but the folks on pyobjc-dev will answer and they are really > friendly/knowledgeable. Overloading the method did in fact fix the problem. I thought this might be useful to someone else. Carlos |