demo_tableview.py
changeset 21 8553a6bd2d82
child 22 6ca8b2d221c3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/demo_tableview.py	Sat Oct 08 17:16:07 2011 +0200
@@ -0,0 +1,43 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import locale
+locale.setlocale(locale.LC_ALL, '')
+
+from tuikit import Application
+from tuikit.layout import VerticalLayout
+from tuikit.tableview import TableView, TableModel
+
+
+class MyApplication(Application):
+    def __init__(self):
+        Application.__init__(self)
+        self.top.connect('keypress', self.globalkeypress)
+
+        data = []
+        for y in range(100):
+            row = [str(y)]
+            for x in range(10):
+                row.append('r{}:c{}'.format(y, x))
+            data.append(row)
+        model = TableModel(data)
+        
+        view = TableView(model)
+        view.addcolumn(header=True, expand=False, sizereq=5)
+        for x in range(10):
+            view.addcolumn(title='head'+str(x))
+        
+        self.top.add(view, expand=True, fill=True)
+
+        vert = VerticalLayout()
+        self.top.layout(vert)
+
+    def globalkeypress(self, keyname, char):
+        if keyname == 'escape':
+            self.terminate()
+
+
+if __name__ == '__main__':
+    app = MyApplication()
+    app.start()
+