author | Radek Brich <radek.brich@devl.cz> |
Fri, 28 Mar 2014 19:58:59 +0100 | |
changeset 97 | 0c2e0c09ba5c |
parent 96 | 68c562e0eb1f |
child 106 | abcadb7e2ef1 |
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 |
|
96
68c562e0eb1f
Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents:
76
diff
changeset
|
3 |
import demobase |
2
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
4 |
|
96
68c562e0eb1f
Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents:
76
diff
changeset
|
5 |
from tuikit.core.application import Application |
68c562e0eb1f
Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents:
76
diff
changeset
|
6 |
#from tuikit.scrollview import ScrollView |
68c562e0eb1f
Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents:
76
diff
changeset
|
7 |
from tuikit.widgets.textbox import TextBox |
2
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 |
|
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
10 |
class MyApplication(Application): |
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
11 |
def __init__(self): |
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
12 |
Application.__init__(self) |
96
68c562e0eb1f
Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents:
76
diff
changeset
|
13 |
#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
|
14 |
|
96
68c562e0eb1f
Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents:
76
diff
changeset
|
15 |
t = open('../tuikit/core/widget.py').read() |
68c562e0eb1f
Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents:
76
diff
changeset
|
16 |
editbox = TextBox(t) |
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:
62
diff
changeset
|
17 |
|
96
68c562e0eb1f
Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents:
76
diff
changeset
|
18 |
#scroll = ScrollView() |
68c562e0eb1f
Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents:
76
diff
changeset
|
19 |
#scroll.add(editbox) |
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:
62
diff
changeset
|
20 |
|
96
68c562e0eb1f
Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents:
76
diff
changeset
|
21 |
self.root_window.add(editbox) |
68c562e0eb1f
Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents:
76
diff
changeset
|
22 |
#self.root_window.add(scroll, halign='fill', valign='fill') |
2
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
23 |
|
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
|
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': |
2
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
26 |
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
|
27 |
return True |
2
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
28 |
|
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
29 |
|
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
30 |
if __name__ == '__main__': |
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
31 |
app = MyApplication() |
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
32 |
app.start() |
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
33 |