demos/06_gridlayout.py
author Radek Brich <radek.brich@devl.cz>
Mon, 16 Feb 2015 21:17:43 +0100
changeset 117 8680c2333546
parent 115 demos/05_gridlayout.py@b4ff7392003a
permissions -rwxr-xr-x
Update FixedLayout. Add demo launcher.
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
from tuikit.layouts.grid import GridLayout
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     4
from tuikit.widgets.label import Label
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     5
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     6
l1 = Label('Hello')
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     7
l1.sizemin.update(10, 1)
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     8
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     9
grid = GridLayout()
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    10
grid.add(l1, 1, 1)
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    11
grid.update(10, 10)
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    12
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    13
print(grid._grid_size)
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    14
print(grid._grid)
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    15
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    16
for row in range(grid.row_count):
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    17
    for col in range(grid.column_count):
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    18
        w = grid.get_widget_at(row, col)
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    19
        name = w.name if w else '--'
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    20
        print(name.center(16), end='')
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    21
    print()
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    22
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    23
print(l1.pos)
b4ff7392003a GridLayout: basic implementation.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    24
print(l1.size)