tests/gridlayout.py
author Radek Brich <radek.brich@devl.cz>
Fri, 01 Feb 2013 00:24:02 +0100
changeset 74 23767a33a781
parent 19 5e78d52ebb24
permissions -rwxr-xr-x
Add ScrollWindow. Rewrite EditBox to work with OffsetLayout. Add propery "exposed" to DrawEvent. Add Widget._view_size. Add config file (driver, log_level).

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

import sys
sys.path.append('..')

from tuikit import Container, Size, Widget, GridLayout

# -------------
# | 0 | 1 | 2 |
# -------------
# | 3     | 4 |
# -------------
# | 5         |
# -------------
#
# 3 - colspan = 2
# 5 - autospan

if __name__ == '__main__':
    cont = Container()

    w = [None] * 6
    for i in range(6):
        w[i] = Widget()
        cont.add(w[i])

    w[3].hints['colspan'] = 2

    w[1].sizemin = Size(2,2)
    w[3].sizemin = Size(6,1)

    grid = GridLayout(3)
    grid.container = cont

    print('* _fillgrid')
    grid._fillgrid()

    print('span:')
    for row in grid._grid:
        for col in row:
            print('[%s,%d,%d]' % (
                col['widget'].__class__.__name__[0],
                col['colspan'],
                col['rowspan']), end=' ')
        print()

    print('* _computesizes')
    grid._computesizes()

    print('sizemin:')
    for row in grid._grid:
        for col in row:
            w = col['widget']
            if w is None:
                print('[0,0]', end=' ')
            else:
                print('[{0.w},{0.h}]'.format(w.sizemin), end=' ')
        print()

    print('colminw:')
    print(grid._colminw)

    print('rowminh:')
    print(grid._rowminh)