def size(self, dialog): """ Calculate size of the FreeLayout and all Widgets inside @param dialog The Dialog which contains the FreeLayout """ if dialog is None: return Spacer.size(self, dialog) for anchor, offset_x, offset_y, widget in self.content: widget.size(dialog)
def layout(self, x, y): """ Lays out Widgets within the FreeLayout. We make no attempt to assure there's enough space for them. @param x X coordinate of lower left corner @param y Y coordinate of lower left corner """ Spacer.layout(self, x, y) for anchor, offset_x, offset_y, widget in self.content: x, y = GetRelativePoint(self, anchor, widget, anchor, (offset_x, offset_y)) widget.layout(x, y)
def __init__(self, width=0, height=0, content=[]): """ Creates a new FreeLayout. @param width Minimum width of FreeLayout area @param height Minimum height of FreeLayout area @param content A list of placement/Widget tuples, in the form: [(ANCHOR_TOP_LEFT, 0, 0, YourWidget()), (ANCHOR_TOP_RIGHT, 0, 0, YourWidget()), (ANCHOR_CENTER, 30, -20, YourWidget())] where each tuple is (anchor, offset-x, offset-y, widget) """ Spacer.__init__(self, width, height) self.content = content
def add(self, item): """ Adds a new Widget to the layout. @param item The Widget to be added """ self.content.append(item or Spacer()) if self.saved_dialog is not None: self.saved_dialog.set_needs_layout()
def __init__(self, content=[], align=HALIGN_CENTER, padding=5): """ Creates a new VerticalLayout. @param content A list of Widgets to be arranged @param align HALIGN_LEFT if Widgets are to be left-justified, HALIGN_CENTER if they should be centered, and HALIGN_RIGHT if they are to be right-justified. @param padding This amount of padding is inserted between widgets. """ assert isinstance(content, list) or isinstance(content, tuple) Widget.__init__(self) self.align = align self.padding = padding self.content = [x or Spacer() for x in content] self.expandable = []