demo_layout.py
author Radek Brich <radek.brich@devl.cz>
Wed, 02 Jan 2013 11:48:36 +0100
changeset 44 d77f1ae3786c
parent 42 0224ce40792f
child 45 43b2279b06e1
permissions -rwxr-xr-x
Add Widget.spot property. TreeView: move spot with cursor node. ScrollView: scroll when spot moves.

#!/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.on_top_keypress)

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

        self.top.layout = VerticalLayout(homogeneous=False)

        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):
        hbox1 = Container()
        hbox1.sizereq.h = 2
        hbox1.layout = HorizontalLayout(homogeneous=homogeneous, spacing=spacing)
        self.top.add(hbox1)
        for i in range(5):
            btn = Button('Btn' + str(i) * i * i)
            hbox1.add(btn, expand=expand, fill=fill)

    def on_top_keypress(self, ev):
        if ev.keyname == 'escape' or ev.char == 'q':
            self.terminate()


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