demo_checkbox.py
changeset 34 e3beacd5e536
parent 30 05500124d7fb
child 41 37b7dfc3eae6
equal deleted inserted replaced
33:45f1b6d590bd 34:e3beacd5e536
     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_keypress)
    14 
    14 
    15         vert = VerticalLayout(homogeneous=False)
    15         vert = VerticalLayout(homogeneous=False)
    16         self.top.layout(vert)
    16         self.top.layout(vert)
    17         
    17         
    18         combo = ComboBox(items=['abc', 'xyz'])
    18         combo = ComboBox(items=['abc', 'xyz'])
    20         
    20         
    21         for i in range(10):
    21         for i in range(10):
    22             cbox = Checkbox('checkbox ' + str(i))
    22             cbox = Checkbox('checkbox ' + str(i))
    23             self.top.add(cbox)
    23             self.top.add(cbox)
    24         
    24         
    25     def globalkeypress(self, keyname, char):
    25     def on_keypress(self, keyname, char):
    26         if keyname == 'escape' or char == 'q':
    26         if keyname == 'escape' or char == 'q':
    27             self.terminate()
    27             self.terminate()
    28 
    28 
    29 
    29 
    30 if __name__ == '__main__':
    30 if __name__ == '__main__':