Repository navigation
Expand file tree
/
Copy pathexample.py
More file actions
93 lines (61 loc) · 2.33 KB
/
Copy pathexample.py
File metadata and controls
93 lines (61 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
from python_table_print.table import PrintTable, Justification
# Create a basic table
my_table = PrintTable()
my_table.add_row("Col 1", "Col 2", "Col 3")
my_table.add_row("Entry 1", "Entry number 2", "Entry 3 baby")
my_table.add_row("Another entry", "yay", "an entry in the table")
my_table.add_row("Fun times", "This is kinda cool", "wooow")
print("Basic Table\n")
print(my_table.get_table())
print("\n\n")
# The header row is optional and can be removed
my_table.has_header_row = False
print("Table Without Header\n")
print(my_table.get_table())
print("\n\n")
# You can set the justification for the whole table, for a row or column, or for an individual cell.
# Each justification command overrides any previous justification set for those cell(s)
my_table.has_header_row = True
my_table.set_table_justification(Justification.CENTRE)
print("Table With Centre Justification\n")
print(my_table.get_table())
print("\n\n")
my_table.set_row_justification(0, Justification.LEFT)
print("Table With Top Row Left-Justified\n")
print(my_table.get_table())
print("\n\n")
my_table.set_column_justification(0, Justification.RIGHT)
print("Table With First Column Right-Justified\n")
print(my_table.get_table())
print("\n\n")
my_table.set_cell_justification(1, 1, Justification.LEFT)
print("Table With One Cell Left-Justified\n")
print(my_table.get_table())
print("\n\n")
my_table.set_title("Title")
print("Table With Title With Centre Justification\n")
print(my_table.get_table())
print("\n\n")
my_table.set_title_justification(Justification.LEFT)
print("Table With Title With Left Justification\n")
print(my_table.get_table())
print("\n\n")
my_table.set_title_justification(Justification.RIGHT)
print("Table With Title With Right Justification\n")
print(my_table.get_table())
print("\n\n")
my_table.set_title("This title is just way way too long and it wil be truncated")
print("Table With A Truncated Title")
print(my_table.get_table())
print("\n\n")
my_table.clear_title()
print("Table With Cleared Title\n")
print(my_table.get_table())
print("\n\n")
my_nearly_empty_table = PrintTable()
my_nearly_empty_table.add_row("Not Empty", "", "", "", "")
my_nearly_empty_table.add_row("", "", "", "", "")
my_nearly_empty_table.add_row("", "", "", "", "")
my_nearly_empty_table.set_title("Title")
print("Nearly empty table\n")
print(my_nearly_empty_table.get_table())