demo_editor.py
changeset 45 43b2279b06e1
parent 41 37b7dfc3eae6
child 62 2f61931520c9
equal deleted inserted replaced
44:d77f1ae3786c 45:43b2279b06e1
     6 
     6 
     7 import os
     7 import os
     8 
     8 
     9 from tuikit.application import Application
     9 from tuikit.application import Application
    10 from tuikit.editfield import EditField
    10 from tuikit.editfield import EditField
    11 from tuikit.window import Window
       
    12 from tuikit.button import Button
       
    13 from tuikit.scrollbar import VScrollbar
       
    14 from tuikit.textedit import TextEdit
    11 from tuikit.textedit import TextEdit
    15 
    12 
    16 
    13 
    17 class MyApplication(Application):
    14 class MyApplication(Application):
    18     def __init__(self):
    15     def __init__(self):
    19         Application.__init__(self)
    16         Application.__init__(self)
    20         self.top.connect('keypress', self.on_top_keypress)
    17         self.top.add_handler('keypress', self.on_top_keypress)
    21 
    18 
    22         #edit = EditField(50, 'DlouhyTest12')
    19         #edit = EditField(50, 'DlouhyTest12')
    23         #self.top.add(edit)
    20         #self.top.add(edit)
    24 
       
    25 
    21 
    26         t = open('tuikit/widget.py').read()
    22         t = open('tuikit/widget.py').read()
    27         textedit = TextEdit(100, 40, t)
    23         textedit = TextEdit(100, 40, t)
    28         self.top.add(textedit)
    24         self.top.add(textedit)
    29         textedit.x = 2
    25         textedit.x = 2
    30         self.textedit = textedit
    26         self.textedit = textedit
    31 
    27 
    32         #win = Window()
       
    33         #self.top.add(win)
       
    34 
       
    35         #button = Button('click!')
       
    36         #win.add(button)
       
    37         #button.x = 10
       
    38         #button.y = 7
       
    39 
       
    40         #button.connect('click', self.buttonclick)
       
    41         #self.button = button
       
    42 
       
    43         #subwin = Window(8,8)
       
    44         #win.add(subwin)
       
    45 
       
    46 
       
    47     def buttonclick(self):
       
    48         self.button.label = 'YES'
       
    49 
       
    50 
       
    51     def on_top_keypress(self, ev):
    28     def on_top_keypress(self, ev):
    52         if ev.keyname == 'escape':
    29         if ev.keyname == 'escape':
    53             self.terminate()
    30             self.terminate()
       
    31             return True
    54 
    32 
    55 
    33 
    56 if __name__ == '__main__':
    34 if __name__ == '__main__':
    57     os.environ['ESCDELAY'] = '25' # do not wait 1 second after pressing Escape key
    35     os.environ['ESCDELAY'] = '25' # do not wait 1 second after pressing Escape key
    58     app = MyApplication()
    36     app = MyApplication()