|
1 | 1 | #!/usr/bin/env python |
2 | 2 | # coding=utf-8 |
3 | | -from tableformatter import generate_table, FancyGrid, SparseGrid |
4 | 3 | """ |
5 | 4 | Simple demonstration of TableFormatter with a list of tuples as table entries. |
6 | 5 | TableFormatter will automatically expand the row height to handle multi-line entries. |
7 | 6 | """ |
8 | | - |
| 7 | +import tableformatter as tf |
| 8 | +from tableformatter import generate_table |
9 | 9 |
|
10 | 10 | rows = [('A1', 'A2', 'A3', 'A4'), |
11 | 11 | ('B1', 'B2\nB2\nB2', 'B3', 'B4'), |
12 | 12 | ('C1', 'C2', 'C3', 'C4'), |
13 | 13 | ('D1', 'D2', 'D3', 'D4')] |
14 | 14 |
|
15 | | - |
16 | 15 | columns = ('Col1', 'Col2', 'Col3', 'Col4') |
17 | 16 |
|
18 | 17 | print("Basic Table, default style (AlternatingRowGrid):") |
|
24 | 23 |
|
25 | 24 |
|
26 | 25 | print("Basic Table, FancyGrid:") |
27 | | -print(generate_table(rows, grid_style=FancyGrid)) |
| 26 | +print(generate_table(rows, grid_style=tf.FancyGrid())) |
28 | 27 |
|
29 | 28 | print("Basic Table, SparseGrid:") |
30 | | -print(generate_table(rows, grid_style=SparseGrid)) |
| 29 | +print(generate_table(rows, grid_style=tf.SparseGrid())) |
31 | 30 |
|
32 | 31 | print("Table with header, AlteratingRowGrid:") |
33 | 32 | print(generate_table(rows, columns)) |
|
38 | 37 |
|
39 | 38 |
|
40 | 39 | print("Table with header, transposed, FancyGrid:") |
41 | | -print(generate_table(rows, columns, grid_style=FancyGrid, transpose=True)) |
| 40 | +print(generate_table(rows, columns, grid_style=tf.FancyGrid(), transpose=True)) |
42 | 41 |
|
43 | 42 | print("Table with header, transposed, SparseGrid:") |
44 | | -print(generate_table(rows, columns, grid_style=SparseGrid, transpose=True)) |
| 43 | +print(generate_table(rows, columns, grid_style=tf.SparseGrid(), transpose=True)) |
0 commit comments