tests/gridlayout.py
changeset 6 d4ee152d7d07
child 19 5e78d52ebb24
equal deleted inserted replaced
5:ae128c885d0f 6:d4ee152d7d07
       
     1 #!/usr/bin/env python3
       
     2 # -*- coding: utf-8 -*-
       
     3 
       
     4 from tuikit import *
       
     5 
       
     6 # -------------
       
     7 # | 0 | 1 | 2 |
       
     8 # -------------
       
     9 # | 3     | 4 |
       
    10 # -------------
       
    11 # | 5         |
       
    12 # -------------
       
    13 #
       
    14 # 3 - colspan = 2
       
    15 # 5 - autospan
       
    16 
       
    17 if __name__ == '__main__':
       
    18     cont = Container()
       
    19 
       
    20     w = [None] * 6
       
    21     for i in range(6):
       
    22         w[i] = Widget()
       
    23         cont.add(w[i])
       
    24 
       
    25     w[3].layouthints['colspan'] = 2
       
    26 
       
    27     w[1].sizemin = (2,2)
       
    28     w[3].sizemin = (6,1)
       
    29 
       
    30     grid = GridLayout(3)
       
    31     grid.container = cont
       
    32 
       
    33     print('* _fillgrid')
       
    34     grid._fillgrid()
       
    35 
       
    36     print('span:')
       
    37     for row in grid._grid:
       
    38         for col in row:
       
    39             print('[%s,%d,%d]' % (
       
    40                 col['widget'].__class__.__name__[0],
       
    41                 col['colspan'],
       
    42                 col['rowspan']), end=' ')
       
    43         print()
       
    44 
       
    45     print('* _computesizes')
       
    46     grid._computesizes()
       
    47 
       
    48     print('sizemin:')
       
    49     for row in grid._grid:
       
    50         for col in row:
       
    51             w = col['widget']
       
    52             if w is None:
       
    53                 print('[0,0]', end=' ')
       
    54             else:
       
    55                 print('[%d,%d]' % w.sizemin, end=' ')
       
    56         print()
       
    57 
       
    58     print('colminw:')
       
    59     print(grid._colminw)
       
    60 
       
    61     print('rowminh:')
       
    62     print(grid._rowminh)