def __init__(self): super(PackageIconsExample, self).__init__() self._icons = ['arrow-down.png', 'arrow-left.png', 'arrow-right.png', 'arrow-up.png', 'attention.png', 'calendar.png', 'cancel.png', 'document.png', 'document-add.png', 'document-delete.png', 'document-doc.png', 'document-image.png', 'document-pdf.png', 'document-ppt.png', 'document-txt.png', 'document-web.png', 'document-xsl.png', 'email.png', 'email-reply.png', 'email-send.png', 'folder.png', 'folder-add.png', 'folder-delete.png', 'globe.png', 'help.png', 'lock.png', 'note.png', 'ok.png', 'reload.png', 'settings.png', 'trash.png', 'trash-full.png', 'user.png', 'users.png'] self._sizes = ['16', '32', '64'] self.setSpacing(True) tabSheet = TabSheet() tabSheet.setStyleName(Reindeer.TABSHEET_MINIMAL) for size in self._sizes: iconsSideBySide = 2 if size == '64' else 3 grid = GridLayout(iconsSideBySide * 2, 1) grid.setSpacing(True) grid.setMargin(True) tabSheet.addTab(grid, size + 'x' + size, None) tabSheet.addComponent(grid) for icon in self._icons: res = ThemeResource('../runo/icons/' + size + '/' + icon) e = Embedded(None, res) # Set size to avoid flickering when loading e.setWidth(size + 'px') e.setHeight(size + 'px') name = Label(icon) if size == '64': name.setWidth('185px') else: name.setWidth('150px') grid.addComponent(e) grid.addComponent(name) grid.setComponentAlignment(name, Alignment.MIDDLE_LEFT) self.addComponent(tabSheet)
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)
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)