def layout(self, x, y): """ Lays out the child Widgets, in order from left to right. @param x X coordinate of the lower left corner @param y Y coordinate of the lower left corner """ Widget.layout(self, x, y) # Expand any expandable content to our height for item in self.content: if item.is_expandable() and item.height < self.height: item.expand(item.width, self.height) left = x+self.padding/2 if self.align == VALIGN_TOP: for item in self.content: item.layout(left, y + self.height - item.height) left += item.width + self.padding elif self.align == VALIGN_CENTER: for item in self.content: item.layout(left, y + self.height/2 - item.height/2) left += item.width + self.padding else: # VALIGN_BOTTOM for item in self.content: item.layout(left, y) left += item.width + self.padding
def size(self, dialog): """ Calculates size of the layout, based on its children. @param dialog The Dialog which contains the layout """ if dialog is None: return Widget.size(self, dialog) height = 0 if len(self.content) < 2: width = 0 else: width = -self.padding for item in self.content: item.size(dialog) height = max(height, item.height) width += item.width + self.padding self.width, self.height = width+self.padding, height self.expandable = [x for x in self.content if x.is_expandable()]