author | Radek Brich <radek.brich@devl.cz> |
Fri, 04 Jan 2013 00:13:59 +0100 | |
changeset 45 | 43b2279b06e1 |
parent 42 | 0224ce40792f |
child 64 | 03f591f5fe5c |
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.layout import VerticalLayout |
|
9 |
from tuikit.tableview import TableView, TableModel |
|
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 |
|
17 |
data = [] |
|
18 |
for y in range(100): |
|
22
6ca8b2d221c3
Update TableView: cursor movement.
Radek Brich <radek.brich@devl.cz>
parents:
21
diff
changeset
|
19 |
row = [str(y+1)] |
21 | 20 |
for x in range(10): |
21 |
row.append('r{}:c{}'.format(y, x)) |
|
22 |
data.append(row) |
|
23 |
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
|
24 |
|
21 | 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)) |
|
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 |
|
21 | 30 |
self.top.add(view, expand=True, fill=True) |
31 |
||
42
0224ce40792f
Make Container.layout a property.
Radek Brich <radek.brich@devl.cz>
parents:
41
diff
changeset
|
32 |
self.top.layout = VerticalLayout() |
21 | 33 |
|
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
|
34 |
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
|
35 |
if ev.keyname == 'escape': |
21 | 36 |
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
|
37 |
return True |
21 | 38 |
|
39 |
||
40 |
if __name__ == '__main__': |
|
41 |
app = MyApplication() |
|
42 |
app.start() |
|
43 |