demo_layout.py
author Radek Brich <radek.brich@devl.cz>
Tue, 04 Oct 2011 22:51:12 +0200
changeset 16 8791a7da6835
child 41 37b7dfc3eae6
permissions -rwxr-xr-x
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import locale
locale.setlocale(locale.LC_ALL, '')

from tuikit import *


class MyApplication(Application):
    def __init__(self):
        Application.__init__(self)
        self.top.connect('keypress', self.globalkeypress)

        #self.top.borders = (1,1,1,1)

        vert = VerticalLayout(homogeneous=False)
        self.top.layout(vert)
        
        self.buildrow()
        self.buildrow(expand=True)
        self.buildrow(expand=True, fill=True)
        self.buildrow(homogeneous=True)
        self.buildrow(homogeneous=True, fill=True)
        self.buildrow(homogeneous=True, fill=True, spacing=1)
        self.buildrow(homogeneous=True, fill=True, spacing=2)
        
    def buildrow(self, homogeneous=False, spacing=0, expand=False, fill=False):
        horz = HorizontalLayout(homogeneous=homogeneous, spacing=spacing)
        hbox1 = Container()
        hbox1.sizereq.h = 2
        hbox1.layout(horz)
        self.top.add(hbox1)
        for i in range(5):
            btn = Button('Btn' + str(i) * i * i)
            hbox1.add(btn, expand=expand, fill=fill)
        
    def globalkeypress(self, keyname, char):
        if keyname == 'escape' or char == 'q':
            self.terminate()


if __name__ == '__main__':
    app = MyApplication()
    app.start()