Test for GridLayout. New Label widget.
authorRadek Brich <radek.brich@devl.cz>
Sun, 10 Apr 2011 22:56:13 +0200
changeset 6 d4ee152d7d07
parent 5 ae128c885d0f
child 7 d4a291b31cbb
Test for GridLayout. New Label widget.
tests/gridlayout.py
tests/tuikit
tuikit/label.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/gridlayout.py	Sun Apr 10 22:56:13 2011 +0200
@@ -0,0 +1,62 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+from tuikit import *
+
+# -------------
+# | 0 | 1 | 2 |
+# -------------
+# | 3     | 4 |
+# -------------
+# | 5         |
+# -------------
+#
+# 3 - colspan = 2
+# 5 - autospan
+
+if __name__ == '__main__':
+    cont = Container()
+
+    w = [None] * 6
+    for i in range(6):
+        w[i] = Widget()
+        cont.add(w[i])
+
+    w[3].layouthints['colspan'] = 2
+
+    w[1].sizemin = (2,2)
+    w[3].sizemin = (6,1)
+
+    grid = GridLayout(3)
+    grid.container = cont
+
+    print('* _fillgrid')
+    grid._fillgrid()
+
+    print('span:')
+    for row in grid._grid:
+        for col in row:
+            print('[%s,%d,%d]' % (
+                col['widget'].__class__.__name__[0],
+                col['colspan'],
+                col['rowspan']), end=' ')
+        print()
+
+    print('* _computesizes')
+    grid._computesizes()
+
+    print('sizemin:')
+    for row in grid._grid:
+        for col in row:
+            w = col['widget']
+            if w is None:
+                print('[0,0]', end=' ')
+            else:
+                print('[%d,%d]' % w.sizemin, end=' ')
+        print()
+
+    print('colminw:')
+    print(grid._colminw)
+
+    print('rowminh:')
+    print(grid._rowminh)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/tuikit	Sun Apr 10 22:56:13 2011 +0200
@@ -0,0 +1,1 @@
+../tuikit
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tuikit/label.py	Sun Apr 10 22:56:13 2011 +0200
@@ -0,0 +1,17 @@
+# -*- coding: utf-8 -*-
+
+from .widget import Widget
+
+
+class Label(Widget):
+    def __init__(self, label=''):
+        Widget.__init__(self, len(label), 1)
+
+        self.label = label
+        self.connect('draw', self.on_draw)
+
+
+    def on_draw(self, screen, x, y):
+        screen.puts(x, y, self.label)
+
+