test_input.py
changeset 19 5e78d52ebb24
parent 18 e6c3a5ee91aa
child 20 472a753664f9
equal deleted inserted replaced
18:e6c3a5ee91aa 19:5e78d52ebb24
     1 #!/usr/bin/env python3
       
     2 # -*- coding: utf-8 -*-
       
     3 
       
     4 import locale
       
     5 locale.setlocale(locale.LC_ALL, '')
       
     6 
       
     7 from tuikit import *
       
     8 
       
     9 
       
    10 class MyApplication(Application):
       
    11     def __init__(self):
       
    12         Application.__init__(self)
       
    13         self.top.connect('keypress', self.globalkeypress)
       
    14 
       
    15         self.text = ''
       
    16         textedit = TextEdit(100, 40, self.text)
       
    17         self.top.add(textedit)
       
    18         textedit.x = 2
       
    19         self.textedit = textedit
       
    20 
       
    21 
       
    22     def globalkeypress(self, keyname, char):
       
    23         if char == 'q':
       
    24             self.terminate()
       
    25         self.text += 'keyname: %s  char: %s\n' % (keyname, char)
       
    26         self.textedit.settext(self.text)
       
    27         self.textedit.scrolltoend()
       
    28 
       
    29 
       
    30 if __name__ == '__main__':
       
    31     app = MyApplication()
       
    32     app.start()
       
    33