diff -r ce2e67e7bbb8 -r 6796adfdc7eb demo_tableview.py --- a/demo_tableview.py Wed Sep 03 19:17:04 2014 +0200 +++ b/demo_tableview.py Wed Sep 03 21:56:20 2014 +0200 @@ -6,6 +6,7 @@ from tuikit import Application from tuikit.tableview import TableView, TableModel +from tuikit.scrollview import ScrollView class MyApplication(Application): @@ -13,20 +14,23 @@ Application.__init__(self) self.top.add_handler('keypress', self.on_top_keypress) - data = [] - for y in range(100): - row = [str(y+1)] - for x in range(10): - row.append('r{}:c{}'.format(y, x)) - data.append(row) - model = TableModel(data) + model = TableModel() + model.set_num_headers(1, 1) + for col in range(10): + model.insert_column(col) + model.set_column_header(col, 0, 'col'+str(col+1)) + for row in range(100): + model.insert_row(row) + model.set_row_header(row, 0, 'row'+str(row+1)) + for col in range(10): + model.set_item(row, col, 'r{}:c{}'.format(row+1, col+1)) 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, halign='fill', valign='fill') + scroll = ScrollView() + scroll.add(view) + + self.top.add(scroll, halign='fill', valign='fill') def on_top_keypress(self, ev): if ev.keyname == 'escape':