author | Radek Brich <radek.brich@devl.cz> |
Sat, 02 Feb 2013 12:54:27 +0100 | |
changeset 76 | fa5301e58eca |
parent 73 | 85a282b5e4fc |
child 77 | fc1989059e19 |
permissions | -rwxr-xr-x |
3
33ec838dc021
Fixed escape sequence handling.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1 |
#!/usr/bin/env python3 |
33ec838dc021
Fixed escape sequence handling.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
2 |
# -*- coding: utf-8 -*- |
33ec838dc021
Fixed escape sequence handling.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
3 |
|
33ec838dc021
Fixed escape sequence handling.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
4 |
import locale |
33ec838dc021
Fixed escape sequence handling.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
5 |
locale.setlocale(locale.LC_ALL, '') |
33ec838dc021
Fixed escape sequence handling.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
6 |
|
76
fa5301e58eca
Update demo_input, demo_editor. Update ScrollView: show/hide scrollbars as needed on child size requests.
Radek Brich <radek.brich@devl.cz>
parents:
73
diff
changeset
|
7 |
from tuikit.application import Application |
fa5301e58eca
Update demo_input, demo_editor. Update ScrollView: show/hide scrollbars as needed on child size requests.
Radek Brich <radek.brich@devl.cz>
parents:
73
diff
changeset
|
8 |
from tuikit.scrollview import ScrollView |
fa5301e58eca
Update demo_input, demo_editor. Update ScrollView: show/hide scrollbars as needed on child size requests.
Radek Brich <radek.brich@devl.cz>
parents:
73
diff
changeset
|
9 |
from tuikit.editbox import EditBox |
3
33ec838dc021
Fixed escape sequence handling.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
10 |
|
33ec838dc021
Fixed escape sequence handling.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
11 |
|
33ec838dc021
Fixed escape sequence handling.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
12 |
class MyApplication(Application): |
33ec838dc021
Fixed escape sequence handling.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
13 |
def __init__(self): |
33ec838dc021
Fixed escape sequence handling.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
14 |
Application.__init__(self) |
33ec838dc021
Fixed escape sequence handling.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
15 |
|
33ec838dc021
Fixed escape sequence handling.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
16 |
self.text = '' |
76
fa5301e58eca
Update demo_input, demo_editor. Update ScrollView: show/hide scrollbars as needed on child size requests.
Radek Brich <radek.brich@devl.cz>
parents:
73
diff
changeset
|
17 |
self.editbox = EditBox(self.text) |
fa5301e58eca
Update demo_input, demo_editor. Update ScrollView: show/hide scrollbars as needed on child size requests.
Radek Brich <radek.brich@devl.cz>
parents:
73
diff
changeset
|
18 |
scroll = ScrollView() |
fa5301e58eca
Update demo_input, demo_editor. Update ScrollView: show/hide scrollbars as needed on child size requests.
Radek Brich <radek.brich@devl.cz>
parents:
73
diff
changeset
|
19 |
scroll.add(self.editbox) |
fa5301e58eca
Update demo_input, demo_editor. Update ScrollView: show/hide scrollbars as needed on child size requests.
Radek Brich <radek.brich@devl.cz>
parents:
73
diff
changeset
|
20 |
self.top.add(scroll, halign='fill', valign='fill') |
3
33ec838dc021
Fixed escape sequence handling.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
21 |
|
76
fa5301e58eca
Update demo_input, demo_editor. Update ScrollView: show/hide scrollbars as needed on child size requests.
Radek Brich <radek.brich@devl.cz>
parents:
73
diff
changeset
|
22 |
self.editbox.add_handler('keypress', self.on_any_input) |
fa5301e58eca
Update demo_input, demo_editor. Update ScrollView: show/hide scrollbars as needed on child size requests.
Radek Brich <radek.brich@devl.cz>
parents:
73
diff
changeset
|
23 |
self.editbox.add_handler('mousedown', self.on_any_input) |
fa5301e58eca
Update demo_input, demo_editor. Update ScrollView: show/hide scrollbars as needed on child size requests.
Radek Brich <radek.brich@devl.cz>
parents:
73
diff
changeset
|
24 |
self.editbox.add_handler('mouseup', self.on_any_input) |
fa5301e58eca
Update demo_input, demo_editor. Update ScrollView: show/hide scrollbars as needed on child size requests.
Radek Brich <radek.brich@devl.cz>
parents:
73
diff
changeset
|
25 |
self.editbox.add_handler('mousewheel', self.on_any_input) |
fa5301e58eca
Update demo_input, demo_editor. Update ScrollView: show/hide scrollbars as needed on child size requests.
Radek Brich <radek.brich@devl.cz>
parents:
73
diff
changeset
|
26 |
self.editbox.add_handler('mousemove', self.on_any_input) |
fa5301e58eca
Update demo_input, demo_editor. Update ScrollView: show/hide scrollbars as needed on child size requests.
Radek Brich <radek.brich@devl.cz>
parents:
73
diff
changeset
|
27 |
self.editbox.add_handler('mousehover', self.on_any_input) |
55
1ab0edd5d784
DriverSDL: mousewheel, key repeation.
Radek Brich <radek.brich@devl.cz>
parents:
45
diff
changeset
|
28 |
|
1ab0edd5d784
DriverSDL: mousewheel, key repeation.
Radek Brich <radek.brich@devl.cz>
parents:
45
diff
changeset
|
29 |
def on_any_input(self, ev): |
76
fa5301e58eca
Update demo_input, demo_editor. Update ScrollView: show/hide scrollbars as needed on child size requests.
Radek Brich <radek.brich@devl.cz>
parents:
73
diff
changeset
|
30 |
if ev.event_name == 'keypress' and ev.keyname == 'escape': |
3
33ec838dc021
Fixed escape sequence handling.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
31 |
self.terminate() |
76
fa5301e58eca
Update demo_input, demo_editor. Update ScrollView: show/hide scrollbars as needed on child size requests.
Radek Brich <radek.brich@devl.cz>
parents:
73
diff
changeset
|
32 |
line = ''.join((ev.event_name.ljust(10), ' : ', repr(ev))) |
fa5301e58eca
Update demo_input, demo_editor. Update ScrollView: show/hide scrollbars as needed on child size requests.
Radek Brich <radek.brich@devl.cz>
parents:
73
diff
changeset
|
33 |
self.editbox.add_line(line) |
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
|
34 |
return True |
3
33ec838dc021
Fixed escape sequence handling.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
35 |
|
33ec838dc021
Fixed escape sequence handling.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
36 |
|
33ec838dc021
Fixed escape sequence handling.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
37 |
if __name__ == '__main__': |
33ec838dc021
Fixed escape sequence handling.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
38 |
app = MyApplication() |
33ec838dc021
Fixed escape sequence handling.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
39 |
app.start() |
33ec838dc021
Fixed escape sequence handling.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
40 |