author | Radek Brich <radek.brich@devl.cz> |
Wed, 20 Aug 2014 15:06:52 +0200 | |
changeset 102 | 29a8a26a721f |
parent 99 | f3063f08ba81 |
permissions | -rwxr-xr-x |
21 | 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.tableview import TableView, TableModel |
|
99
f3063f08ba81
Update TableView (old uncommitted work).
Radek Brich <radek.brich@devl.cz>
parents:
64
diff
changeset
|
9 |
from tuikit.scrollview import ScrollView |
21 | 10 |
|
11 |
||
12 |
class MyApplication(Application): |
|
13 |
def __init__(self): |
|
14 |
Application.__init__(self) |
|
45
43b2279b06e1
Clean up Emitter class, simplify event handling. Fix Container.focusnext() method. Add events test (handler auto-registration, order).
Radek Brich <radek.brich@devl.cz>
parents:
42
diff
changeset
|
15 |
self.top.add_handler('keypress', self.on_top_keypress) |
21 | 16 |
|
99
f3063f08ba81
Update TableView (old uncommitted work).
Radek Brich <radek.brich@devl.cz>
parents:
64
diff
changeset
|
17 |
model = TableModel() |
f3063f08ba81
Update TableView (old uncommitted work).
Radek Brich <radek.brich@devl.cz>
parents:
64
diff
changeset
|
18 |
model.set_num_headers(1, 1) |
f3063f08ba81
Update TableView (old uncommitted work).
Radek Brich <radek.brich@devl.cz>
parents:
64
diff
changeset
|
19 |
for col in range(10): |
f3063f08ba81
Update TableView (old uncommitted work).
Radek Brich <radek.brich@devl.cz>
parents:
64
diff
changeset
|
20 |
model.insert_column(col) |
f3063f08ba81
Update TableView (old uncommitted work).
Radek Brich <radek.brich@devl.cz>
parents:
64
diff
changeset
|
21 |
model.set_column_header(col, 0, 'col'+str(col+1)) |
f3063f08ba81
Update TableView (old uncommitted work).
Radek Brich <radek.brich@devl.cz>
parents:
64
diff
changeset
|
22 |
for row in range(100): |
f3063f08ba81
Update TableView (old uncommitted work).
Radek Brich <radek.brich@devl.cz>
parents:
64
diff
changeset
|
23 |
model.insert_row(row) |
f3063f08ba81
Update TableView (old uncommitted work).
Radek Brich <radek.brich@devl.cz>
parents:
64
diff
changeset
|
24 |
model.set_row_header(row, 0, 'row'+str(row+1)) |
f3063f08ba81
Update TableView (old uncommitted work).
Radek Brich <radek.brich@devl.cz>
parents:
64
diff
changeset
|
25 |
for col in range(10): |
f3063f08ba81
Update TableView (old uncommitted work).
Radek Brich <radek.brich@devl.cz>
parents:
64
diff
changeset
|
26 |
model.set_item(row, col, 'r{}:c{}'.format(row+1, col+1)) |
41
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
27 |
|
21 | 28 |
view = TableView(model) |
41
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
29 |
|
99
f3063f08ba81
Update TableView (old uncommitted work).
Radek Brich <radek.brich@devl.cz>
parents:
64
diff
changeset
|
30 |
scroll = ScrollView() |
f3063f08ba81
Update TableView (old uncommitted work).
Radek Brich <radek.brich@devl.cz>
parents:
64
diff
changeset
|
31 |
scroll.add(view) |
f3063f08ba81
Update TableView (old uncommitted work).
Radek Brich <radek.brich@devl.cz>
parents:
64
diff
changeset
|
32 |
|
f3063f08ba81
Update TableView (old uncommitted work).
Radek Brich <radek.brich@devl.cz>
parents:
64
diff
changeset
|
33 |
self.top.add(scroll, halign='fill', valign='fill') |
21 | 34 |
|
41
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
35 |
def on_top_keypress(self, ev): |
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
36 |
if ev.keyname == 'escape': |
21 | 37 |
self.terminate() |
45
43b2279b06e1
Clean up Emitter class, simplify event handling. Fix Container.focusnext() method. Add events test (handler auto-registration, order).
Radek Brich <radek.brich@devl.cz>
parents:
42
diff
changeset
|
38 |
return True |
21 | 39 |
|
40 |
||
41 |
if __name__ == '__main__': |
|
42 |
app = MyApplication() |
|
43 |
app.start() |
|
44 |