demos/03_application.py
changeset 109 105b1affc3c2
parent 97 0c2e0c09ba5c
child 111 b055add74b18
--- a/demos/03_application.py	Fri Mar 28 19:58:59 2014 +0100
+++ b/demos/03_application.py	Wed Sep 03 19:08:21 2014 +0200
@@ -10,15 +10,26 @@
 label = Label('Hello there!')
 label.pos.update(20, 10)
 
-button = Button()
-button.pos.update(20, 20)
+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(button)
+app.root_window.add(button1)
+app.root_window.add(button2)
 app.root_window.add(field)
-app.root_window.focus_child = 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()
+