From: Kevin A. <al...@se...> - 2005-12-27 19:15:44
|
There is a fitToComponents convenience method in model.py that currently is only used by dialogs sample, so needs more testing in other samples with static layouts that have this spacing problem. This does seem to work in the dialogs sample on Windows and the Mac. The comment and code I wrote last year is at the end of this message. I'm thinking that I should just go ahead and add a fitToComponents call in other samples for the next release like this one: def on_initialize(self, event): self.fitToComponents(None, 5) If we can verify it is working fine then it can be incorporated into the resource file and done automatically for applications that don't explicitly turn it off, which would typically be apps with their own sizer code. Any other ideas? If this isn't working on GTK1 or GTK2, etc. let me know. ka --- # KEA 2004-09-24 # experiment to see if we could fit the panel # to the boundaries of the components with a little # padding to get around the problem of a static layout # having too much vertical space on GTK and Mac or not # enough vertical space on Windows if the layout was designed # for GTK or Mac... # the idea is that this would become an option in the resource # that could be called automatically # but I'm just testing now to see if it actually produces good results def fitToComponents(self, widthPadding=None, heightPadding=5): print "self.size:", self.size print "self.panel.size:", self.panel.size width = 0 height = 0 # height = self.panel.size for c in self.components.itervalues(): print " ", c.name, c.position, c.size x, y = c.position w, h = c.size width = max(x + w, width) height = max(y + h, height) print "width, height", width, height newWidth, newHeight = self.panel.size if widthPadding is not None: newWidth = width + widthPadding if heightPadding is not None: newHeight = height + heightPadding print "newWidth, newHeight", newWidth, newHeight self.panel.SetSize((newWidth, newHeight)) self.SetClientSize((newWidth, newHeight)) |