tests/gridlayout.py
author Radek Brich <radek.brich@devl.cz>
Sun, 02 Oct 2011 23:32:35 +0200
changeset 15 c55b4749e562
parent 6 d4ee152d7d07
child 19 5e78d52ebb24
permissions -rwxr-xr-x
Add Pager.
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
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     4
from tuikit import *
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     5
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     6
# -------------
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     7
# | 0 | 1 | 2 |
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
# | 3     | 4 |
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    10
# -------------
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    11
# | 5         |
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    12
# -------------
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
# 3 - colspan = 2
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    15
# 5 - autospan
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
if __name__ == '__main__':
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    18
    cont = Container()
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
    w = [None] * 6
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    21
    for i in range(6):
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    22
        w[i] = Widget()
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    23
        cont.add(w[i])
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    24
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    25
    w[3].layouthints['colspan'] = 2
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    26
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    27
    w[1].sizemin = (2,2)
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    28
    w[3].sizemin = (6,1)
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    29
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    30
    grid = GridLayout(3)
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    31
    grid.container = cont
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
    print('* _fillgrid')
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    34
    grid._fillgrid()
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('span:')
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    37
    for row in grid._grid:
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    38
        for col in row:
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    39
            print('[%s,%d,%d]' % (
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    40
                col['widget'].__class__.__name__[0],
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    41
                col['colspan'],
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    42
                col['rowspan']), end=' ')
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    43
        print()
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    44
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    45
    print('* _computesizes')
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    46
    grid._computesizes()
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('sizemin:')
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    49
    for row in grid._grid:
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    50
        for col in row:
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    51
            w = col['widget']
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    52
            if w is None:
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    53
                print('[0,0]', end=' ')
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    54
            else:
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    55
                print('[%d,%d]' % w.sizemin, end=' ')
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    56
        print()
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    57
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    58
    print('colminw:')
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    59
    print(grid._colminw)
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('rowminh:')
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    62
    print(grid._rowminh)