demos/20_texteditor.py
changeset 118 8c7970520632
parent 117 8680c2333546
equal deleted inserted replaced
117:8680c2333546 118:8c7970520632
       
     1 #!/usr/bin/env python3
       
     2 
       
     3 import sys
       
     4 
       
     5 from tuikit.core.application import Application
       
     6 #from tuikit.scrollview import ScrollView
       
     7 from tuikit.widgets.textbox import TextBox
       
     8 
       
     9 
       
    10 class MyApplication(Application):
       
    11 
       
    12     def __init__(self):
       
    13         Application.__init__(self)
       
    14         self.window_manager.sig_keypress.connect(self.on_wm_keypress)
       
    15         #self.top.add_handler('keypress', self.on_top_keypress)
       
    16 
       
    17         t = open(sys.argv[0]).read()
       
    18         editbox = TextBox(t)
       
    19 
       
    20         #scroll = ScrollView()
       
    21         #scroll.add(editbox)
       
    22 
       
    23         self.root_window.add(editbox)
       
    24         #self.root_window.add(scroll, halign='fill', valign='fill')
       
    25 
       
    26     def on_wm_keypress(self, ev):
       
    27         if ev.keyname == 'escape':
       
    28             self.stop()
       
    29             return True
       
    30 
       
    31 if __name__ == '__main__':
       
    32     app = MyApplication()
       
    33     app.start()
       
    34