--- a/demo_layout.py Wed Jan 02 11:48:36 2013 +0100
+++ b/demo_layout.py Fri Jan 04 00:13:59 2013 +0100
@@ -10,12 +10,13 @@
class MyApplication(Application):
def __init__(self):
Application.__init__(self)
- self.top.connect('keypress', self.on_top_keypress)
+ self.top.add_handler('keypress', self.on_top_keypress)
#self.top.borders = (1,1,1,1)
self.top.layout = VerticalLayout(homogeneous=False)
+ self._row_num = 0
self.buildrow()
self.buildrow(expand=True)
self.buildrow(expand=True, fill=True)
@@ -25,17 +26,20 @@
self.buildrow(homogeneous=True, fill=True, spacing=2)
def buildrow(self, homogeneous=False, spacing=0, expand=False, fill=False):
- hbox1 = Container()
- hbox1.sizereq.h = 2
- hbox1.layout = HorizontalLayout(homogeneous=homogeneous, spacing=spacing)
- self.top.add(hbox1)
+ hbox = Container()
+ hbox.sizereq.h = 2
+ hbox.layout = HorizontalLayout(homogeneous=homogeneous, spacing=spacing)
+ self._row_num += 1
+ hbox.name = 'hbox' + str(self._row_num)
+ self.top.add(hbox)
for i in range(5):
btn = Button('Btn' + str(i) * i * i)
- hbox1.add(btn, expand=expand, fill=fill)
+ hbox.add(btn, expand=expand, fill=fill)
def on_top_keypress(self, ev):
if ev.keyname == 'escape' or ev.char == 'q':
self.terminate()
+ return True
if __name__ == '__main__':