demo_layout.py
changeset 62 2f61931520c9
parent 45 43b2279b06e1
child 63 2a0e04091898
equal deleted inserted replaced
61:15088f62c4ac 62:2f61931520c9
     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 
       
    14         self.top = VerticalLayout(homogeneous=False)
    13         self.top.add_handler('keypress', self.on_top_keypress)
    15         self.top.add_handler('keypress', self.on_top_keypress)
    14 
       
    15         #self.top.borders = (1,1,1,1)
    16         #self.top.borders = (1,1,1,1)
    16 
       
    17         self.top.layout = VerticalLayout(homogeneous=False)
       
    18 
    17 
    19         self._row_num = 0
    18         self._row_num = 0
    20         self.buildrow()
    19         self.buildrow()
    21         self.buildrow(expand=True)
    20         self.buildrow(expand=True)
    22         self.buildrow(expand=True, fill=True)
    21         self.buildrow(expand=True, fill=True)
    24         self.buildrow(homogeneous=True, fill=True)
    23         self.buildrow(homogeneous=True, fill=True)
    25         self.buildrow(homogeneous=True, fill=True, spacing=1)
    24         self.buildrow(homogeneous=True, fill=True, spacing=1)
    26         self.buildrow(homogeneous=True, fill=True, spacing=2)
    25         self.buildrow(homogeneous=True, fill=True, spacing=2)
    27 
    26 
    28     def buildrow(self, homogeneous=False, spacing=0, expand=False, fill=False):
    27     def buildrow(self, homogeneous=False, spacing=0, expand=False, fill=False):
    29         hbox = Container()
    28         hbox = HorizontalLayout(homogeneous=homogeneous, spacing=spacing)
    30         hbox.sizereq.h = 2
    29         hbox.resize(h=2)
    31         hbox.layout = HorizontalLayout(homogeneous=homogeneous, spacing=spacing)
       
    32         self._row_num += 1
    30         self._row_num += 1
    33         hbox.name = 'hbox' + str(self._row_num)
    31         hbox.name = 'hbox' + str(self._row_num)
    34         self.top.add(hbox)
    32         self.top.add(hbox)
    35         for i in range(5):
    33         for i in range(5):
    36             btn = Button('Btn' + str(i) * i * i)
    34             btn = Button('Btn' + str(i) * i * i)