demos/03_application.py
author Radek Brich <radek.brich@devl.cz>
Wed, 03 Sep 2014 19:13:37 +0200
changeset 110 cf3d49cdd6e2
parent 109 105b1affc3c2
child 111 b055add74b18
permissions -rwxr-xr-x
Add cursesw driver, using curses get_wch() for unicode input. It alse has enabled keypad() to let curses interpret control keys and mouse input.

#!/usr/bin/env python3

import demobase

from tuikit.core.application import Application
from tuikit.widgets.label import Label
from tuikit.widgets.button import Button
from tuikit.widgets.textfield import TextField

label = Label('Hello there!')
label.pos.update(20, 10)

button1 = Button()
button1.pos.update(20, 20)
button2 = Button()
button2.pos.update(30, 20)

field = TextField('text field')
field.pos.update(20, 30)

app = Application()
app.root_window.add(label)
app.root_window.add(button1)
app.root_window.add(button2)
app.root_window.add(field)
app.root_window.focus_widget = field

def on_keypress(keyname, char, mod):
    if keyname == 'escape':
        app.stop()

app.window_manager.sig_keypress.connect(on_keypress)

app.start()