demo_tableview.py
changeset 21 8553a6bd2d82
child 22 6ca8b2d221c3
equal deleted inserted replaced
20:472a753664f9 21:8553a6bd2d82
       
     1 #!/usr/bin/env python3
       
     2 # -*- coding: utf-8 -*-
       
     3 
       
     4 import locale
       
     5 locale.setlocale(locale.LC_ALL, '')
       
     6 
       
     7 from tuikit import Application
       
     8 from tuikit.layout import VerticalLayout
       
     9 from tuikit.tableview import TableView, TableModel
       
    10 
       
    11 
       
    12 class MyApplication(Application):
       
    13     def __init__(self):
       
    14         Application.__init__(self)
       
    15         self.top.connect('keypress', self.globalkeypress)
       
    16 
       
    17         data = []
       
    18         for y in range(100):
       
    19             row = [str(y)]
       
    20             for x in range(10):
       
    21                 row.append('r{}:c{}'.format(y, x))
       
    22             data.append(row)
       
    23         model = TableModel(data)
       
    24         
       
    25         view = TableView(model)
       
    26         view.addcolumn(header=True, expand=False, sizereq=5)
       
    27         for x in range(10):
       
    28             view.addcolumn(title='head'+str(x))
       
    29         
       
    30         self.top.add(view, expand=True, fill=True)
       
    31 
       
    32         vert = VerticalLayout()
       
    33         self.top.layout(vert)
       
    34 
       
    35     def globalkeypress(self, keyname, char):
       
    36         if keyname == 'escape':
       
    37             self.terminate()
       
    38 
       
    39 
       
    40 if __name__ == '__main__':
       
    41     app = MyApplication()
       
    42     app.start()
       
    43