On Mar 1, 2005, at 1:50 AM, Bob Ippolito wrote:
>> [...] when I amend windowControllerDidLoadNib_ as follows:
>> def windowControllerDidLoadNib_(self, controller):
>> if self.path:
>> self.window.setTitle_( "foobar" )
>> i.e. attempt to set the title on the window, I get an error that
>> TinyTinyDocument has no attribute `window.' This is the same problem
>> as with the example I provided earlier.
> At this point, I don't think the window ivar is initialized yet
> (though you're getting AttributeError because it's not picked out of
> the nib, I guess it comes from the superclass). That's not the
> correct way to do it anyhow, you should implement -[NSDocument
> displayName] instead.
> def displayName(self):
> return u'foobar'
That is a good solution for that issue, but I would like to also set
the position of the window. I couldn't see anything in NSDocument
documentation for that, but I could have missed something.
I almost have this working. I can put a button in the window and have
it call a function that, say, changes the window title, like this:
def setMyWindowTitle_(self, sender):
self.windowControllers().window().setTitle_( "hooray!" )
That works fine. But, I would like to set the title (or rather, change
the window position, since displayName works well enough for the
title), without having to have specific user interaction such as
clicking a button. It'd be nice if it was set correctly when the
window came up in the first place.
It seems this problem must be easy. It seems like a method like
windowControllerDidLoadNib_ or awakeFromNib should be the answer; but
the line of code above does not have the desired effect when placed in
windowControllerDidLoadNib_ (it does nothing, no error either tho), and
when I put it in awakeFromNib, I get an error that the maximum
recursion depth was exceeded -- awakeFromNib seems to call itself
repeatedly when that line is executed (!).
> The Xcode templates are not currently suitable (and really never have
> been) for building redistributable applications, so all of the
> examples have been converted to use py2app setup.py files (though some
> have a vestigal .xcode or .pbproj). The tutorial should cover what
> you need to know regarding py2app.
Fair enough. It's not really a problem to develop this way now that
I'm used to it.