Re: [Pyobjc-dev] How to get NSDoc subclass's window outlet?
Brought to you by:
ronaldoussoren
From: <bb...@ma...> - 2002-12-15 14:32:15
|
On Sunday, Dec 15, 2002, at 02:18 US/Eastern, David Eppstein wrote: > I have a Python subclass of NSDocument, that wants to access the > NSDocument's window outlet. Is it possible? If I do window = > objc.IBOutlet("window"), I get None as the value of the outlet > (despite it being connected in the nib, and other outlets working). > But if I don't set the outlet in the Python code, I get exception: No > attribute window. I can't see an accessor function that would give me > the same information in the NSDocument documentation. Generally, you never should or need to access an instance variable of AppKit classes directly, even when subclassing. An accessor method is almost always provided. In this case, NSDocument implements the -window method for exactly this purpose. Try self.window(). If that doesn't work, then there is a bug. In the case of NSDocument, the iVar is named _window. Because of the way documents manage their windows-- typically through instances of NSWindowController, but not always-- the -window method has a bunch of additional intelligence to deal with complex situations. b.bum |