author | Radek Brich <radek.brich@devl.cz> |
Wed, 30 Jan 2013 19:44:01 +0100 | |
changeset 72 | 6e0656600754 |
parent 62 | 2f61931520c9 |
child 76 | fa5301e58eca |
permissions | -rwxr-xr-x |
2
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1 |
#!/usr/bin/env python3 |
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
2 |
# -*- coding: utf-8 -*- |
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
3 |
|
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
4 |
import locale |
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
5 |
locale.setlocale(locale.LC_ALL, '') |
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
6 |
|
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
7 |
import os |
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
8 |
|
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
9 |
from tuikit.application import Application |
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
10 |
from tuikit.textedit import TextEdit |
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
11 |
|
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
12 |
|
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
13 |
class MyApplication(Application): |
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
14 |
def __init__(self): |
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
15 |
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:
41
diff
changeset
|
16 |
self.top.add_handler('keypress', self.on_top_keypress) |
2
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
17 |
|
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
18 |
t = open('tuikit/widget.py').read() |
62
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
45
diff
changeset
|
19 |
textedit = TextEdit(t) |
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
45
diff
changeset
|
20 |
self.top.add(textedit, halign='fill', valign='fill') |
2
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
21 |
|
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
|
22 |
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
|
23 |
if ev.keyname == 'escape': |
2
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
24 |
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:
41
diff
changeset
|
25 |
return True |
2
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
26 |
|
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
27 |
|
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
28 |
if __name__ == '__main__': |
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
29 |
os.environ['ESCDELAY'] = '25' # do not wait 1 second after pressing Escape key |
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
30 |
app = MyApplication() |
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
31 |
app.start() |
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
32 |