demos/03_application.py
author Radek Brich <radek.brich@devl.cz>
Mon, 16 Feb 2015 21:17:43 +0100
changeset 117 8680c2333546
parent 114 26c02bd94bd9
permissions -rwxr-xr-x
Update FixedLayout. Add demo launcher.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
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
     3
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
     4
from tuikit.widgets.label import Label
89
94f5baef19ac Add Theme, Button.
Radek Brich <radek.brich@devl.cz>
parents: 87
diff changeset
     5
from tuikit.widgets.button import Button
97
0c2e0c09ba5c Add TextField widget, keypress event, cursor.
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
     6
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
     7
87
ee5ea9671f28 Add core Widget, Container. Add widgets Label.
Radek Brich <radek.brich@devl.cz>
parents: 86
diff changeset
     8
label = Label('Hello there!')
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
     9
button1 = Button()
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
    10
button2 = Button()
97
0c2e0c09ba5c Add TextField widget, keypress event, cursor.
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
    11
field = TextField('text field')
0c2e0c09ba5c Add TextField widget, keypress event, cursor.
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
    12
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
    13
app = Application()
117
8680c2333546 Update FixedLayout. Add demo launcher.
Radek Brich <radek.brich@devl.cz>
parents: 114
diff changeset
    14
app.root_window.add(label, 20, 10)
8680c2333546 Update FixedLayout. Add demo launcher.
Radek Brich <radek.brich@devl.cz>
parents: 114
diff changeset
    15
app.root_window.add(button1, 20, 20)
8680c2333546 Update FixedLayout. Add demo launcher.
Radek Brich <radek.brich@devl.cz>
parents: 114
diff changeset
    16
app.root_window.add(button2, 30, 20)
8680c2333546 Update FixedLayout. Add demo launcher.
Radek Brich <radek.brich@devl.cz>
parents: 114
diff changeset
    17
app.root_window.add(field, 20, 30)
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
    18
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
    19
111
b055add74b18 Refactor events.
Radek Brich <radek.brich@devl.cz>
parents: 109
diff changeset
    20
def on_keypress(ev):
b055add74b18 Refactor events.
Radek Brich <radek.brich@devl.cz>
parents: 109
diff changeset
    21
    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
    22
        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
    23
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.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
    25
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
    26
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
    27