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).
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     1
#!/usr/bin/env python3
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     2
# -*- coding: utf-8 -*-
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     3
19
5e78d52ebb24 Update demos and tests.
Radek Brich <radek.brich@devl.cz>
parents: 6
diff changeset
     4
import sys
5e78d52ebb24 Update demos and tests.
Radek Brich <radek.brich@devl.cz>
parents: 6
diff changeset
     5
sys.path.append('..')
5e78d52ebb24 Update demos and tests.
Radek Brich <radek.brich@devl.cz>
parents: 6
diff changeset
     6
5e78d52ebb24 Update demos and tests.
Radek Brich <radek.brich@devl.cz>
parents: 6
diff changeset
     7
from tuikit import Container, Size, Widget, GridLayout
6
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     8
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     9
# -------------
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    10
# | 0 | 1 | 2 |
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    11
# -------------
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    12
# | 3     | 4 |
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    13
# -------------
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    14
# | 5         |
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    15
# -------------
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    16
#
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    17
# 3 - colspan = 2
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    18
# 5 - autospan
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    19
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    20
if __name__ == '__main__':
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    21
    cont = Container()
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    22
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    23
    w = [None] * 6
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    24
    for i in range(6):
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    25
        w[i] = Widget()
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    26
        cont.add(w[i])
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    27
19
5e78d52ebb24 Update demos and tests.
Radek Brich <radek.brich@devl.cz>
parents: 6
diff changeset
    28
    w[3].hints['colspan'] = 2
6
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    29
19
5e78d52ebb24 Update demos and tests.
Radek Brich <radek.brich@devl.cz>
parents: 6
diff changeset
    30
    w[1].sizemin = Size(2,2)
5e78d52ebb24 Update demos and tests.
Radek Brich <radek.brich@devl.cz>
parents: 6
diff changeset
    31
    w[3].sizemin = Size(6,1)
6
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    32
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    33
    grid = GridLayout(3)
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    34
    grid.container = cont
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    35
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    36
    print('* _fillgrid')
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    37
    grid._fillgrid()
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    38
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    39
    print('span:')
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    40
    for row in grid._grid:
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    41
        for col in row:
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    42
            print('[%s,%d,%d]' % (
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    43
                col['widget'].__class__.__name__[0],
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    44
                col['colspan'],
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    45
                col['rowspan']), end=' ')
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    46
        print()
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    47
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    48
    print('* _computesizes')
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    49
    grid._computesizes()
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    50
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    51
    print('sizemin:')
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    52
    for row in grid._grid:
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    53
        for col in row:
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    54
            w = col['widget']
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    55
            if w is None:
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    56
                print('[0,0]', end=' ')
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    57
            else:
19
5e78d52ebb24 Update demos and tests.
Radek Brich <radek.brich@devl.cz>
parents: 6
diff changeset
    58
                print('[{0.w},{0.h}]'.format(w.sizemin), end=' ')
6
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    59
        print()
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    60
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    61
    print('colminw:')
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    62
    print(grid._colminw)
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    63
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    64
    print('rowminh:')
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    65
    print(grid._rowminh)
19
5e78d52ebb24 Update demos and tests.
Radek Brich <radek.brich@devl.cz>
parents: 6
diff changeset
    66