demo_layout.py
changeset 16 8791a7da6835
child 41 37b7dfc3eae6
equal deleted inserted replaced
15:c55b4749e562 16:8791a7da6835
       
     1 #!/usr/bin/env python3
       
     2 # -*- coding: utf-8 -*-
       
     3 
       
     4 import locale
       
     5 locale.setlocale(locale.LC_ALL, '')
       
     6 
       
     7 from tuikit import *
       
     8 
       
     9 
       
    10 class MyApplication(Application):
       
    11     def __init__(self):
       
    12         Application.__init__(self)
       
    13         self.top.connect('keypress', self.globalkeypress)
       
    14 
       
    15         #self.top.borders = (1,1,1,1)
       
    16 
       
    17         vert = VerticalLayout(homogeneous=False)
       
    18         self.top.layout(vert)
       
    19         
       
    20         self.buildrow()
       
    21         self.buildrow(expand=True)
       
    22         self.buildrow(expand=True, fill=True)
       
    23         self.buildrow(homogeneous=True)
       
    24         self.buildrow(homogeneous=True, fill=True)
       
    25         self.buildrow(homogeneous=True, fill=True, spacing=1)
       
    26         self.buildrow(homogeneous=True, fill=True, spacing=2)
       
    27         
       
    28     def buildrow(self, homogeneous=False, spacing=0, expand=False, fill=False):
       
    29         horz = HorizontalLayout(homogeneous=homogeneous, spacing=spacing)
       
    30         hbox1 = Container()
       
    31         hbox1.sizereq.h = 2
       
    32         hbox1.layout(horz)
       
    33         self.top.add(hbox1)
       
    34         for i in range(5):
       
    35             btn = Button('Btn' + str(i) * i * i)
       
    36             hbox1.add(btn, expand=expand, fill=fill)
       
    37         
       
    38     def globalkeypress(self, keyname, char):
       
    39         if keyname == 'escape' or char == 'q':
       
    40             self.terminate()
       
    41 
       
    42 
       
    43 if __name__ == '__main__':
       
    44     app = MyApplication()
       
    45     app.start()
       
    46