author | Radek Brich <radek.brich@devl.cz> |
Sun, 27 Jan 2013 12:54:52 +0100 | |
changeset 69 | 4e7be77bafff |
parent 64 | 03f591f5fe5c |
child 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 |
|
9 |
||
10 |
||
11 |
class MyApplication(Application): |
|
12 |
def __init__(self): |
|
13 |
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
|
14 |
self.top.add_handler('keypress', self.on_top_keypress) |
21 | 15 |
|
16 |
data = [] |
|
17 |
for y in range(100): |
|
22
6ca8b2d221c3
Update TableView: cursor movement.
Radek Brich <radek.brich@devl.cz>
parents:
21
diff
changeset
|
18 |
row = [str(y+1)] |
21 | 19 |
for x in range(10): |
20 |
row.append('r{}:c{}'.format(y, x)) |
|
21 |
data.append(row) |
|
22 |
model = TableModel(data) |
|
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
|
23 |
|
21 | 24 |
view = TableView(model) |
25 |
view.addcolumn(header=True, expand=False, sizereq=5) |
|
26 |
for x in range(10): |
|
27 |
view.addcolumn(title='head'+str(x)) |
|
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
|
28 |
|
64
03f591f5fe5c
Drop Container.offset, add special layout for that - OffsetLayout.
Radek Brich <radek.brich@devl.cz>
parents:
45
diff
changeset
|
29 |
self.top.add(view, halign='fill', valign='fill') |
21 | 30 |
|
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
|
31 |
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
|
32 |
if ev.keyname == 'escape': |
21 | 33 |
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
|
34 |
return True |
21 | 35 |
|
36 |
||
37 |
if __name__ == '__main__': |
|
38 |
app = MyApplication() |
|
39 |
app.start() |
|
40 |