demo_treeview.py
changeset 41 37b7dfc3eae6
parent 40 5faa38c10b67
child 42 0224ce40792f
equal deleted inserted replaced
40:5faa38c10b67 41:37b7dfc3eae6
     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)
    13         self.top.connect('keypress', self.globalkeypress)
    13         self.top.connect('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'])
    18         model.add((0,1), ['e', 'f'])
    18         model.add((0,1), ['e', 'f'])
    30         self.top.add(scroll, expand=True, fill=True)
    30         self.top.add(scroll, expand=True, fill=True)
    31 
    31 
    32         vert = VerticalLayout()
    32         vert = VerticalLayout()
    33         self.top.layout(vert)
    33         self.top.layout(vert)
    34 
    34 
    35     def globalkeypress(self, eo, keyname, char):
    35     def on_top_keypress(self, ev):
    36         if keyname == 'escape':
    36         if ev.keyname == 'escape':
    37             self.terminate()
    37             self.terminate()
    38 
    38 
    39 
    39 
    40 if __name__ == '__main__':
    40 if __name__ == '__main__':
    41     app = MyApplication()
    41     app = MyApplication()