demo_treeview.py
changeset 64 03f591f5fe5c
parent 62 2f61931520c9
equal deleted inserted replaced
63:2a0e04091898 64:03f591f5fe5c
     2 # -*- coding: utf-8 -*-
     2 # -*- coding: utf-8 -*-
     3 
     3 
     4 import locale
     4 import locale
     5 locale.setlocale(locale.LC_ALL, '')
     5 locale.setlocale(locale.LC_ALL, '')
     6 
     6 
     7 from tuikit import Application, TreeView, TreeModel, ScrollView, VerticalLayout
     7 from tuikit import Application, TreeView, TreeModel, ScrollView
     8 
     8 
     9 
     9 
    10 class MyApplication(Application):
    10 class MyApplication(Application):
    11     def __init__(self):
    11     def __init__(self):
    12         Application.__init__(self, top_layout=VerticalLayout)
    12         Application.__init__(self)
    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'])
    25         view = TreeView(model)
    25         view = TreeView(model)
    26         #view.collapse('/a/d')
    26         #view.collapse('/a/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, halign='fill', valign='fill')
    31 
    31 
    32     def on_top_keypress(self, ev):
    32     def on_top_keypress(self, ev):
    33         if ev.keyname == 'escape':
    33         if ev.keyname == 'escape':
    34             self.terminate()
    34             self.terminate()
    35             return True
    35             return True