/examples/kitchensink/Tables.py

http://pyjamas.googlecode.com/ · Python · 34 lines · 25 code · 9 blank · 0 comment · 2 complexity · 9bd61f061c503efcd5e8cda949a75468 MD5 · raw file

  1. from Sink import Sink, SinkInfo
  2. from ui import Grid, FlexTable, HasHorizontalAlignment, Image
  3. class Tables(Sink):
  4. def __init__(self):
  5. inner = Grid(10, 5)
  6. outer = FlexTable()
  7. outer.setWidget(0, 0, Image(self.baseURL() + "rembrandt/LaMarcheNocturne.jpg"))
  8. outer.getFlexCellFormatter().setColSpan(0, 0, 2)
  9. outer.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER)
  10. outer.setHTML(1, 0, "Look to the right...<br>That's a nested table component ->")
  11. outer.setWidget(1, 1, inner)
  12. outer.getCellFormatter().setColSpan(1, 1, 2)
  13. for i in range(10):
  14. for j in range(5):
  15. inner.setText(i, j, "" + i + "," + j)
  16. inner.setWidth("100%")
  17. outer.setWidth("100%")
  18. inner.setBorderWidth(1)
  19. outer.setBorderWidth(1)
  20. self.initWidget(outer)
  21. def onShow(self):
  22. pass
  23. def init():
  24. 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."
  25. return SinkInfo("Tables", text, Tables)