editor.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 import os
       
     8 
       
     9 from tuikit.application import Application
       
    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
       
    15 
       
    16 
       
    17 class MyApplication(Application):
       
    18     def __init__(self):
       
    19         Application.__init__(self)
       
    20         self.top.connect('keypress', self.globalkeypress)
       
    21 
       
    22         #edit = EditField(50, 'DlouhyTest12')
       
    23         #self.top.add(edit)
       
    24 
       
    25 
       
    26         t = open('tuikit/widget.py').read()
       
    27         textedit = TextEdit(100, 40, t)
       
    28         self.top.add(textedit)
       
    29         textedit.x = 2
       
    30         self.textedit = textedit
       
    31 
       
    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 globalkeypress(self, keyname, char):
       
    52         if keyname == 'escape':
       
    53             self.terminate()
       
    54         if keyname == 'f1':
       
    55             self.textedit.settext('%s' % self.top.focuschild)
       
    56             self.textedit.redraw()
       
    57             
       
    58 
       
    59 
       
    60 if __name__ == '__main__':
       
    61     os.environ['ESCDELAY'] = '25' # do not wait 1 second after pressing Escape key
       
    62     app = MyApplication()
       
    63     app.start()
       
    64