demo_window.py
changeset 45 43b2279b06e1
parent 29 c0cdef06fd16
child 62 2f61931520c9
--- a/demo_window.py	Wed Jan 02 11:48:36 2013 +0100
+++ b/demo_window.py	Fri Jan 04 00:13:59 2013 +0100
@@ -13,7 +13,7 @@
 class MyApplication(Application):
     def __init__(self):
         Application.__init__(self)
-        self.top.connect('keypress', self.globalkeypress)
+        self.top.add_handler('keypress', self.on_top_keypress)
 
         #edit = EditField(50, 'DlouhyTest12')
         #self.top.add(edit)
@@ -26,20 +26,22 @@
         button.x = 10
         button.y = 7
 
-        button.connect('click', self.buttonclick)
+        button.add_handler('click', self.on_button_click)
         self.button = button
 
         subwin = Window(8,8)
         win.add(subwin)
 
 
-    def buttonclick(self):
+    def on_button_click(self, ev):
         self.button.label = 'YES'
+        return True
 
 
-    def globalkeypress(self, keyname, char):
-        if keyname == 'escape':
+    def on_top_keypress(self, ev):
+        if ev.keyname == 'escape':
             self.terminate()
+            return True
 
 
 if __name__ == '__main__':
@@ -47,7 +49,7 @@
     os.environ['ESCDELAY'] = '25' # do not wait 1 second after pressing Escape key
     app = MyApplication()
     #app.start()
-    
+
     cProfile.run('app.start()', 'demo_window.appstats')
     p = pstats.Stats('demo_window.appstats')
     p.sort_stats('time', 'cumulative').print_stats(20)