Exemplo n.º 1
0
 def multicolumn(self, list, cols=4):
     """Format a list of items into a multi-column list."""
     result = Grid()
     result.setWidth("100%")
     rows = (len(list)+cols-1)/cols
     result.resize(rows, cols)
     for col in range(cols):
         for i in range(rows*col, rows*col+rows):
             if i < len(list):
                 result.setHTML(0, i, list[i] + "<br />\n")
     return result
Exemplo n.º 2
0
 def multicolumn(self, items, cols=4):
     """Format a list of items into a multi-column list."""
     result = Grid()
     result.setWidth("100%")
     rows = (len(items)+cols-1)/cols
     result.resize(rows, cols)
     i = 0
     for col in range(cols):
         for row in range(rows):
             if items and i < len(items):
                 result.setHTML(row, col, items[i] + "<br />\n")
             i += 1
     return result
Exemplo n.º 3
0
    def __init__(self):
        Sink.__init__(self)
        inner = Grid(10, 5)
        outer = FlexTable()

        outer.setWidget(0, 0, Image(self.baseURL() + "rembrandt/LaMarcheNocturne.jpg"))
        outer.getFlexCellFormatter().setColSpan(0, 0, 2)
        outer.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER)

        outer.setHTML(1, 0, "Look to the right...<br>That's a nested table component ->")
        outer.setWidget(1, 1, inner)
        outer.getCellFormatter().setColSpan(1, 1, 2)
        
        for i in range(10):
            for j in range(5):
                inner.setText(i, j, "%d" % i + ",%d" % j)

        inner.setWidth("100%")
        outer.setWidth("100%")

        inner.setBorderWidth(1)
        outer.setBorderWidth(1)

        self.initWidget(outer)