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