demo_treeview.py
changeset 62 2f61931520c9
parent 45 43b2279b06e1
child 64 03f591f5fe5c
equal deleted inserted replaced
61:15088f62c4ac 62:2f61931520c9
     7 from tuikit import Application, TreeView, TreeModel, ScrollView, VerticalLayout
     7 from tuikit import Application, TreeView, TreeModel, ScrollView, VerticalLayout
     8 
     8 
     9 
     9 
    10 class MyApplication(Application):
    10 class MyApplication(Application):
    11     def __init__(self):
    11     def __init__(self):
    12         Application.__init__(self)
    12         Application.__init__(self, top_layout=VerticalLayout)
    13         self.top.add_handler('keypress', self.on_top_keypress)
    13         self.top.add_handler('keypress', self.on_top_keypress)
    14 
    14 
    15         model = TreeModel()
    15         model = TreeModel()
    16         model.add('/',  ['a', 'b'])
    16         model.add('/',  ['a', 'b'])
    17         model.add('/a', ['c', 'd'])
    17         model.add('/a', ['c', 'd'])
    27 
    27 
    28         scroll = ScrollView()
    28         scroll = ScrollView()
    29         scroll.add(view)
    29         scroll.add(view)
    30         self.top.add(scroll, expand=True, fill=True)
    30         self.top.add(scroll, expand=True, fill=True)
    31 
    31 
    32         self.top.layout = VerticalLayout()
       
    33 
       
    34     def on_top_keypress(self, ev):
    32     def on_top_keypress(self, ev):
    35         if ev.keyname == 'escape':
    33         if ev.keyname == 'escape':
    36             self.terminate()
    34             self.terminate()
    37             return True
    35             return True
    38 
    36