PageRenderTime 139ms CodeModel.GetById 126ms app.highlight 4ms RepoModel.GetById 7ms app.codeStats 1ms

/examples/kitchensink/Tables.py

http://pyjamas.googlecode.com/
Python | 34 lines | 30 code | 4 blank | 0 comment | 5 complexity | 9bd61f061c503efcd5e8cda949a75468 MD5 | raw file
 1from Sink import Sink, SinkInfo
 2from ui import Grid, FlexTable, HasHorizontalAlignment, Image
 3
 4class Tables(Sink):
 5    def __init__(self):
 6        inner = Grid(10, 5)
 7        outer = FlexTable()
 8
 9        outer.setWidget(0, 0, Image(self.baseURL() + "rembrandt/LaMarcheNocturne.jpg"))
10        outer.getFlexCellFormatter().setColSpan(0, 0, 2)
11        outer.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER)
12
13        outer.setHTML(1, 0, "Look to the right...<br>That's a nested table component ->")
14        outer.setWidget(1, 1, inner)
15        outer.getCellFormatter().setColSpan(1, 1, 2)
16        
17        for i in range(10):
18            for j in range(5):
19                inner.setText(i, j, "" + i + "," + j)
20
21        inner.setWidth("100%")
22        outer.setWidth("100%")
23
24        inner.setBorderWidth(1)
25        outer.setBorderWidth(1)
26
27        self.initWidget(outer)
28        
29    def onShow(self):
30        pass
31
32def init():
33    text="The <code>FlexTable</code> widget doubles as a tabular data formatter and a panel.  In this example, you'll see that there is an outer table with four cells, two of which contain nested components."
34    return SinkInfo("Tables", text, Tables)