demos/05_gridlayout.py
author Radek Brich <radek.brich@devl.cz>
Sun, 15 Feb 2015 12:52:46 +0100
changeset 115 b4ff7392003a
permissions -rwxr-xr-x
GridLayout: basic implementation.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
115
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     1
#!/usr/bin/env python3
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     2
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     3
import demobase
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     4
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     5
from tuikit.layouts.grid import GridLayout
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     6
from tuikit.widgets.label import Label
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     7
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     8
l1 = Label('Hello')
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     9
l1.sizemin.update(10, 1)
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    10
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    11
grid = GridLayout()
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    12
grid.add(l1, 1, 1)
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    13
grid.update(10, 10)
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    14
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    15
print(grid._grid_size)
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    16
print(grid._grid)
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    17
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    18
for row in range(grid.row_count):
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    19
    for col in range(grid.column_count):
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    20
        w = grid.get_widget_at(row, col)
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    21
        name = w.name if w else '--'
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    22
        print(name.center(16), end='')
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    23
    print()
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    24
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    25
print(l1.pos)
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    26
print(l1.size)