author | Radek Brich <radek.brich@devl.cz> |
Sun, 15 Feb 2015 12:48:23 +0100 | |
changeset 114 | 26c02bd94bd9 |
parent 111 | b055add74b18 |
child 117 | 8680c2333546 |
permissions | -rwxr-xr-x |
86
0978fb755d31
Add core Application (adjusted), Window (new version), Signal (replaces Emitter), Size (adjusted). Add application demo.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1 |
#!/usr/bin/env python3 |
0978fb755d31
Add core Application (adjusted), Window (new version), Signal (replaces Emitter), Size (adjusted). Add application demo.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
2 |
|
92
b97c4e25ed6d
Configure logging for demos.
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
3 |
import demobase |
86
0978fb755d31
Add core Application (adjusted), Window (new version), Signal (replaces Emitter), Size (adjusted). Add application demo.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
4 |
|
0978fb755d31
Add core Application (adjusted), Window (new version), Signal (replaces Emitter), Size (adjusted). Add application demo.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
5 |
from tuikit.core.application import Application |
87
ee5ea9671f28
Add core Widget, Container. Add widgets Label.
Radek Brich <radek.brich@devl.cz>
parents:
86
diff
changeset
|
6 |
from tuikit.widgets.label import Label |
89 | 7 |
from tuikit.widgets.button import Button |
97
0c2e0c09ba5c
Add TextField widget, keypress event, cursor.
Radek Brich <radek.brich@devl.cz>
parents:
92
diff
changeset
|
8 |
from tuikit.widgets.textfield import TextField |
86
0978fb755d31
Add core Application (adjusted), Window (new version), Signal (replaces Emitter), Size (adjusted). Add application demo.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
9 |
|
87
ee5ea9671f28
Add core Widget, Container. Add widgets Label.
Radek Brich <radek.brich@devl.cz>
parents:
86
diff
changeset
|
10 |
label = Label('Hello there!') |
114
26c02bd94bd9
Add Widget.posreq. Add OffsetLayout.
Radek Brich <radek.brich@devl.cz>
parents:
111
diff
changeset
|
11 |
label.posreq.update(20, 10) |
86
0978fb755d31
Add core Application (adjusted), Window (new version), Signal (replaces Emitter), Size (adjusted). Add application demo.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
12 |
|
109
105b1affc3c2
Update keypress propagation. Allow focus change by tab key. Add log property to Widget for smart logging.
Radek Brich <radek.brich@devl.cz>
parents:
97
diff
changeset
|
13 |
button1 = Button() |
114
26c02bd94bd9
Add Widget.posreq. Add OffsetLayout.
Radek Brich <radek.brich@devl.cz>
parents:
111
diff
changeset
|
14 |
button1.posreq.update(20, 20) |
109
105b1affc3c2
Update keypress propagation. Allow focus change by tab key. Add log property to Widget for smart logging.
Radek Brich <radek.brich@devl.cz>
parents:
97
diff
changeset
|
15 |
button2 = Button() |
114
26c02bd94bd9
Add Widget.posreq. Add OffsetLayout.
Radek Brich <radek.brich@devl.cz>
parents:
111
diff
changeset
|
16 |
button2.posreq.update(30, 20) |
89 | 17 |
|
97
0c2e0c09ba5c
Add TextField widget, keypress event, cursor.
Radek Brich <radek.brich@devl.cz>
parents:
92
diff
changeset
|
18 |
field = TextField('text field') |
114
26c02bd94bd9
Add Widget.posreq. Add OffsetLayout.
Radek Brich <radek.brich@devl.cz>
parents:
111
diff
changeset
|
19 |
field.posreq.update(20, 30) |
97
0c2e0c09ba5c
Add TextField widget, keypress event, cursor.
Radek Brich <radek.brich@devl.cz>
parents:
92
diff
changeset
|
20 |
|
86
0978fb755d31
Add core Application (adjusted), Window (new version), Signal (replaces Emitter), Size (adjusted). Add application demo.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
21 |
app = Application() |
87
ee5ea9671f28
Add core Widget, Container. Add widgets Label.
Radek Brich <radek.brich@devl.cz>
parents:
86
diff
changeset
|
22 |
app.root_window.add(label) |
109
105b1affc3c2
Update keypress propagation. Allow focus change by tab key. Add log property to Widget for smart logging.
Radek Brich <radek.brich@devl.cz>
parents:
97
diff
changeset
|
23 |
app.root_window.add(button1) |
105b1affc3c2
Update keypress propagation. Allow focus change by tab key. Add log property to Widget for smart logging.
Radek Brich <radek.brich@devl.cz>
parents:
97
diff
changeset
|
24 |
app.root_window.add(button2) |
97
0c2e0c09ba5c
Add TextField widget, keypress event, cursor.
Radek Brich <radek.brich@devl.cz>
parents:
92
diff
changeset
|
25 |
app.root_window.add(field) |
109
105b1affc3c2
Update keypress propagation. Allow focus change by tab key. Add log property to Widget for smart logging.
Radek Brich <radek.brich@devl.cz>
parents:
97
diff
changeset
|
26 |
app.root_window.focus_widget = field |
105b1affc3c2
Update keypress propagation. Allow focus change by tab key. Add log property to Widget for smart logging.
Radek Brich <radek.brich@devl.cz>
parents:
97
diff
changeset
|
27 |
|
111 | 28 |
def on_keypress(ev): |
29 |
if ev.keyname == 'escape': |
|
109
105b1affc3c2
Update keypress propagation. Allow focus change by tab key. Add log property to Widget for smart logging.
Radek Brich <radek.brich@devl.cz>
parents:
97
diff
changeset
|
30 |
app.stop() |
105b1affc3c2
Update keypress propagation. Allow focus change by tab key. Add log property to Widget for smart logging.
Radek Brich <radek.brich@devl.cz>
parents:
97
diff
changeset
|
31 |
|
105b1affc3c2
Update keypress propagation. Allow focus change by tab key. Add log property to Widget for smart logging.
Radek Brich <radek.brich@devl.cz>
parents:
97
diff
changeset
|
32 |
app.window_manager.sig_keypress.connect(on_keypress) |
105b1affc3c2
Update keypress propagation. Allow focus change by tab key. Add log property to Widget for smart logging.
Radek Brich <radek.brich@devl.cz>
parents:
97
diff
changeset
|
33 |
|
86
0978fb755d31
Add core Application (adjusted), Window (new version), Signal (replaces Emitter), Size (adjusted). Add application demo.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
34 |
app.start() |
109
105b1affc3c2
Update keypress propagation. Allow focus change by tab key. Add log property to Widget for smart logging.
Radek Brich <radek.brich@devl.cz>
parents:
97
diff
changeset
|
35 |