author | Radek Brich <radek.brich@devl.cz> |
Wed, 02 Jan 2013 00:16:12 +0100 | |
changeset 43 | 369c8ef5070a |
parent 42 | 0224ce40792f |
child 45 | 43b2279b06e1 |
permissions | -rwxr-xr-x |
30
05500124d7fb
Add setup script. Add Checkbox widget + demo. Updates.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1 |
#!/usr/bin/env python3 |
05500124d7fb
Add setup script. Add Checkbox widget + demo. Updates.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
2 |
# -*- coding: utf-8 -*- |
05500124d7fb
Add setup script. Add Checkbox widget + demo. Updates.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
3 |
|
05500124d7fb
Add setup script. Add Checkbox widget + demo. Updates.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
4 |
import locale |
05500124d7fb
Add setup script. Add Checkbox widget + demo. Updates.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
5 |
locale.setlocale(locale.LC_ALL, '') |
05500124d7fb
Add setup script. Add Checkbox widget + demo. Updates.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
6 |
|
05500124d7fb
Add setup script. Add Checkbox widget + demo. Updates.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
7 |
from tuikit import * |
05500124d7fb
Add setup script. Add Checkbox widget + demo. Updates.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
8 |
|
05500124d7fb
Add setup script. Add Checkbox widget + demo. Updates.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
9 |
|
05500124d7fb
Add setup script. Add Checkbox widget + demo. Updates.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
10 |
class MyApplication(Application): |
05500124d7fb
Add setup script. Add Checkbox widget + demo. Updates.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
11 |
def __init__(self): |
05500124d7fb
Add setup script. Add Checkbox widget + demo. Updates.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
12 |
Application.__init__(self) |
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:
34
diff
changeset
|
13 |
self.top.connect('keypress', self.on_top_keypress) |
30
05500124d7fb
Add setup script. Add Checkbox widget + demo. Updates.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
14 |
|
42
0224ce40792f
Make Container.layout a property.
Radek Brich <radek.brich@devl.cz>
parents:
41
diff
changeset
|
15 |
self.top.layout = VerticalLayout(homogeneous=False) |
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:
34
diff
changeset
|
16 |
|
30
05500124d7fb
Add setup script. Add Checkbox widget + demo. Updates.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
17 |
combo = ComboBox(items=['abc', 'xyz']) |
05500124d7fb
Add setup script. Add Checkbox widget + demo. Updates.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
18 |
self.top.add(combo) |
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:
34
diff
changeset
|
19 |
|
30
05500124d7fb
Add setup script. Add Checkbox widget + demo. Updates.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
20 |
for i in range(10): |
05500124d7fb
Add setup script. Add Checkbox widget + demo. Updates.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
21 |
cbox = Checkbox('checkbox ' + str(i)) |
05500124d7fb
Add setup script. Add Checkbox widget + demo. Updates.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
22 |
self.top.add(cbox) |
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:
34
diff
changeset
|
23 |
|
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:
34
diff
changeset
|
24 |
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:
34
diff
changeset
|
25 |
if ev.keyname == 'escape' or ev.char == 'q': |
30
05500124d7fb
Add setup script. Add Checkbox widget + demo. Updates.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
26 |
self.terminate() |
05500124d7fb
Add setup script. Add Checkbox widget + demo. Updates.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
27 |
|
05500124d7fb
Add setup script. Add Checkbox widget + demo. Updates.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
28 |
|
05500124d7fb
Add setup script. Add Checkbox widget + demo. Updates.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
29 |
if __name__ == '__main__': |
05500124d7fb
Add setup script. Add Checkbox widget + demo. Updates.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
30 |
app = MyApplication() |
05500124d7fb
Add setup script. Add Checkbox widget + demo. Updates.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
31 |
app.start() |
05500124d7fb
Add setup script. Add Checkbox widget + demo. Updates.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
32 |