def __init__(self): super(GridLayoutBasicExample, self).__init__() # Create a grid layout grid = GridLayout(3, 3) grid.setSpacing(True) # The style allows us to visualize the cell borders in this example. grid.addStyleName('gridexample') grid.setWidth(400, ISizeable.UNITS_PIXELS) grid.setHeight(400, ISizeable.UNITS_PIXELS) # First we insert four components that occupy one cell each topleft = Button('Top Left') grid.addComponent(topleft, 0, 0) grid.setComponentAlignment(topleft, Alignment.MIDDLE_CENTER) topcenter = Button('Top Center') grid.addComponent(topcenter, 1, 0) grid.setComponentAlignment(topcenter, Alignment.MIDDLE_CENTER) bottomleft = Button('Bottom Left') grid.addComponent(bottomleft, 0, 2) grid.setComponentAlignment(bottomleft, Alignment.MIDDLE_CENTER) bottomcenter = Button('Bottom Center') grid.addComponent(bottomcenter, 1, 2) grid.setComponentAlignment(bottomcenter, Alignment.MIDDLE_CENTER) # Insert a component that occupies all the rightmost cells topright = Button('Extra height') grid.addComponent(topright, 2, 0, 2, 2) grid.setComponentAlignment(topright, Alignment.MIDDLE_CENTER) # Insert a component that occupies two cells in horizontal direction middleleft = Button('This is a wide cell in GridLayout') grid.addComponent(middleleft, 0, 1, 1, 1) grid.setComponentAlignment(middleleft, Alignment.MIDDLE_CENTER) # Add the layout to the containing layout. self.addComponent(grid) # Align the grid itself within its container layout. self.setComponentAlignment(grid, Alignment.MIDDLE_CENTER)
def createChildComponentClickableLayout(self): # Create a grid layout with click events layout = GridLayout(5, 2) layout.addStyleName('border') layout.setSpacing(True) layout.setWidth('90%') layout.setMargin(True) # Add some components to the layout layout.addComponent(Label('<b>Clickable layout events include a ' 'reference to the child component beneath the click. ' 'Try clicking anywhere in this layout.</b>', Label.CONTENT_RAW), 0, 0, 4, 0) layout.addComponent(TextField(None, 'Click here')) layout.addComponent(Link('Click here', None)) select = Select(None, ['Click here']) select.select('Click here') layout.addComponent(select) # Listen for layout click event layout.addListener(GridListener(self), ILayoutClickListener) return layout
def createChildComponentClickableLayout(self): # Create a grid layout with click events layout = GridLayout(5, 2) layout.addStyleName('border') layout.setSpacing(True) layout.setWidth('90%') layout.setMargin(True) # Add some components to the layout layout.addComponent( Label( '<b>Clickable layout events include a ' 'reference to the child component beneath the click. ' 'Try clicking anywhere in this layout.</b>', Label.CONTENT_RAW), 0, 0, 4, 0) layout.addComponent(TextField(None, 'Click here')) layout.addComponent(Link('Click here', None)) select = Select(None, ['Click here']) select.select('Click here') layout.addComponent(select) # Listen for layout click event layout.addListener(GridListener(self), ILayoutClickListener) return layout
def __init__(self): super(LayoutAlignmentExample, self).__init__() # Create a grid layout grid = GridLayout(1, 9) grid.setSpacing(True) # The style allows us to visualize the cell borders in this example. grid.addStyleName('gridexample') grid.setWidth('300px') grid.setHeight('500px') # Put a component in each cell with respective alignment. # We'll use different ways to set the alignment: constants, bitmasks, # and string-shorthand. # Here we use the shorthand constants to set the alignment: # Alignment.TOP_LEFT, Alignment.TOP_CENTER, Alignment.TOP_RIGHT # Alignment.MIDDLE_LEFT, Alignment.MIDDLE_CENTER, # Alignment.MIDDLE_RIGHT # Alignment.BOTTOM_LEFT, Alignment.BOTTOM_CENTER, # Alignment.BOTTOM_RIGHT topleft = Button('Top Left') grid.addComponent(topleft) grid.setComponentAlignment(topleft, Alignment.TOP_LEFT) topcenter = Button('Top Center') grid.addComponent(topcenter) grid.setComponentAlignment(topcenter, Alignment.TOP_CENTER) topright = Button('Top Right') grid.addComponent(topright) grid.setComponentAlignment(topright, Alignment.TOP_RIGHT) # Here we use bit additions to set the alignment: # Bits.ALIGNMENT_LEFT, Bits.ALIGNMENT_RIGHT # Bits.ALIGNMENT_TOP, Bits.ALIGNMENT_BOTTOM # Bits.ALIGNMENT_VERTICAL_CENTER, Bits.ALIGNMENT_HORIZONTAL_CENTER middleleft = Button('Middle Left') grid.addComponent(middleleft) grid.setComponentAlignment(middleleft, Alignment( Bits.ALIGNMENT_VERTICAL_CENTER | Bits.ALIGNMENT_LEFT)) middlecenter = Button('Middle Center') grid.addComponent(middlecenter) grid.setComponentAlignment(middlecenter, Alignment( Bits.ALIGNMENT_VERTICAL_CENTER | Bits.ALIGNMENT_HORIZONTAL_CENTER)) middleright = Button('Middle Right') grid.addComponent(middleright) grid.setComponentAlignment(middleright, Alignment( Bits.ALIGNMENT_VERTICAL_CENTER | Bits.ALIGNMENT_RIGHT)) # Here we'll use the convenient string-shorthand: bottomleft = Button('Bottom Left') grid.addComponent(bottomleft) grid.setComponentAlignment(bottomleft, Alignment.BOTTOM_LEFT) bottomcenter = Button('Bottom Center') grid.addComponent(bottomcenter) grid.setComponentAlignment(bottomcenter, Alignment.BOTTOM_CENTER) bottomright = Button('Bottom Right') grid.addComponent(bottomright) grid.setComponentAlignment(bottomright, Alignment.BOTTOM_RIGHT) # Add the layout to the containing layout. self.addComponent(grid) # Align the grid itself within its container layout. self.setComponentAlignment(grid, Alignment.MIDDLE_CENTER)