demos/03_application.py
changeset 118 8c7970520632
parent 117 8680c2333546
child 119 dd91747504dd
equal deleted inserted replaced
117:8680c2333546 118:8c7970520632
     1 #!/usr/bin/env python3
       
     2 
       
     3 from tuikit.core.application import Application
       
     4 from tuikit.widgets.label import Label
       
     5 from tuikit.widgets.button import Button
       
     6 from tuikit.widgets.textfield import TextField
       
     7 
       
     8 label = Label('Hello there!')
       
     9 button1 = Button()
       
    10 button2 = Button()
       
    11 field = TextField('text field')
       
    12 
       
    13 app = Application()
       
    14 app.root_window.add(label, 20, 10)
       
    15 app.root_window.add(button1, 20, 20)
       
    16 app.root_window.add(button2, 30, 20)
       
    17 app.root_window.add(field, 20, 30)
       
    18 app.root_window.focus_widget = field
       
    19 
       
    20 def on_keypress(ev):
       
    21     if ev.keyname == 'escape':
       
    22         app.stop()
       
    23 
       
    24 app.window_manager.sig_keypress.connect(on_keypress)
       
    25 
       
    26 app.start()
       
    27