author | Radek Brich <radek.brich@devl.cz> |
Fri, 07 Oct 2011 11:07:59 +0200 | |
changeset 18 | e6c3a5ee91aa |
parent 11 | 762513aacc87 |
permissions | -rwxr-xr-x |
11
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1 |
#!/usr/bin/env python3 |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
2 |
# -*- coding: utf-8 -*- |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
3 |
|
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
4 |
import locale |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
5 |
locale.setlocale(locale.LC_ALL, '') |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
6 |
|
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
7 |
from tuikit import * |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
8 |
|
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
9 |
|
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
10 |
class MyApplication(Application): |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
11 |
def __init__(self): |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
12 |
Application.__init__(self) |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
13 |
self.top.connect('keypress', self.globalkeypress) |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
14 |
|
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
15 |
model = TreeModel() |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
16 |
model.add('/', ['a', 'b']) |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
17 |
model.add('/a', ['c', 'd']) |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
18 |
model.add((0,1), ['e', 'f']) |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
19 |
model.add('/0/1/0', 'g') |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
20 |
model.add('/a/d/f', 'h') |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
21 |
|
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
22 |
view = TreeView(model) |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
23 |
view.collapse('/a/d') |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
24 |
self.top.add(view) |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
25 |
|
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
26 |
vert = VerticalLayout() |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
27 |
self.top.layout(vert) |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
28 |
|
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
29 |
def globalkeypress(self, keyname, char): |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
30 |
if keyname == 'escape': |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
31 |
self.terminate() |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
32 |
|
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
33 |
|
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
34 |
if __name__ == '__main__': |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
35 |
app = MyApplication() |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
36 |
app.start() |
762513aacc87
TreeView: Add cursor, node collapse, reworked draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
37 |