Re: [Pyobjc-dev] UI bindings no longer work for me
Brought to you by:
ronaldoussoren
From: Mani G. <ma...@tu...> - 2009-09-01 14:07:46
|
On Tue, Sep 1, 2009 at 2:26 AM, Ronald Oussoren<ron...@ma...> wrote: > > On 1 Sep, 2009, at 6:23, Jason Foreman wrote: > >> On Aug 31, 2009, at 10:12 PM, Mani Ghasemlou wrote: >>> >>> I have an NSImageView, whose Hidden state is bound to a variable of my >>> app delegate. Clicking the "Show" button sets this value to False, and >>> "Hide" sets this value to True. >>> >>> Using Snow Leopard, the NSImageView's Hidden state does not change >>> when clicking these buttons. Using Leopard, the image shows and hides >>> itself depending on the button pressed. >>> >>> Can someone help me understand what I might be doing wrong? >> >> >> I'm sure someone with more PyObjC experience can give you a better answer, >> but here's my findings: >> >> There seems to be an issue with the way you initialize your app delegate >> and KVC/KVO. If you change your calls like "self.hideComputer = False" to >> "self.setValue_forKey_(False, 'hideComputer')" it starts working. >> Similarly, you can override the app delegate's init method, and this seems >> to setup KVC correctly for the hideComputer field: >> >> class BindingsUITestAppDelegate(NSObject): >> # hideComputer = ivar('hideComputer') >> def init(self): >> self.hideComputer = False >> return self >> .... etc >> >> >> I don't have any idea why this is, and am anxious myself to hear an >> explanation from the gurus. But in the meantime this might be a suitable >> workaround for you. > > This will be fixed in the next release of PyObjC. A collegue ran into the > same issue a while back, and it turns out that the machinery that should > ensure that the right KVO methods are called didn't work properly anymore. > > There are two workarounds for this: > 1) Use setValue_forKey_ (or self._.hideComputer = False) > 2) Explicitly call willChangeValueForKey_ and didChangeValueForKey_ > > I haven't committed the proper fix because the fix is in my SL tree and I > haven't had time after the SL release to actually commit the code. The > commit, and the next PyObjC 2.2 beta release, will happen sometime this week > (the release will probably be done in the weekend). > > Ronald >> >> >> Jason >> >> >> Gentlemen, thank you for the quick replies. I will go ahead and implement the workaround. Regards, Mani |