demo_window.py
changeset 62 2f61931520c9
parent 45 43b2279b06e1
child 74 23767a33a781
equal deleted inserted replaced
61:15088f62c4ac 62:2f61931520c9
     6 import os
     6 import os
     7 
     7 
     8 from tuikit.application import Application
     8 from tuikit.application import Application
     9 from tuikit.window import Window
     9 from tuikit.window import Window
    10 from tuikit.button import Button
    10 from tuikit.button import Button
       
    11 from tuikit import AnchorLayout
       
    12 from tuikit.common import Borders
    11 
    13 
    12 
    14 
    13 class MyApplication(Application):
    15 class MyApplication(Application):
    14     def __init__(self):
    16     def __init__(self):
    15         Application.__init__(self)
    17         Application.__init__(self)
       
    18         self.top = AnchorLayout()
       
    19         self.top.name = 'top'
    16         self.top.add_handler('keypress', self.on_top_keypress)
    20         self.top.add_handler('keypress', self.on_top_keypress)
    17 
    21 
    18         #edit = EditField(50, 'DlouhyTest12')
    22         #edit = EditField(50, 'DlouhyTest12')
    19         #self.top.add(edit)
    23         #self.top.add(edit)
    20 
    24 
    21         win = Window()
    25         win = Window()
    22         self.top.add(win)
    26         win.title = 'demo_window'
       
    27         win.resize(80, 25)
       
    28         self.top.add(win, halign='left', valign='top')
    23 
    29 
    24         button = Button('click!')
    30         button = Button('click!')
    25         win.add(button)
    31 #        win.add(button, x=10, y=6)
    26         button.x = 10
       
    27         button.y = 7
       
    28 
    32 
    29         button.add_handler('click', self.on_button_click)
    33         button.add_handler('click', self.on_button_click)
    30         self.button = button
    34         self.button = button
    31 
    35 
    32         subwin = Window(8,8)
    36         subwin = Window()
       
    37         subwin.name = 'subwin'
    33         win.add(subwin)
    38         win.add(subwin)
    34 
    39 
    35 
    40 
    36     def on_button_click(self, ev):
    41     def on_button_click(self, ev):
    37         self.button.label = 'YES'
    42         self.button.label = 'YES'
    46 
    51 
    47 if __name__ == '__main__':
    52 if __name__ == '__main__':
    48     locale.setlocale(locale.LC_ALL, '')
    53     locale.setlocale(locale.LC_ALL, '')
    49     os.environ['ESCDELAY'] = '25' # do not wait 1 second after pressing Escape key
    54     os.environ['ESCDELAY'] = '25' # do not wait 1 second after pressing Escape key
    50     app = MyApplication()
    55     app = MyApplication()
    51     #app.start()
    56     app.start()
    52 
    57 
    53     cProfile.run('app.start()', 'demo_window.appstats')
    58     #cProfile.run('app.start()', 'demo_window.appstats')
    54     p = pstats.Stats('demo_window.appstats')
    59     #p = pstats.Stats('demo_window.appstats')
    55     p.sort_stats('time', 'cumulative').print_stats(20)
    60     #p.sort_stats('time', 'cumulative').print_stats(20)
    56 
    61