You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds the ability to justify the entire table, a row, a column, or an individual cell either left, centre, or right.
Closes#50. Closes#52.
* Included the enum in there and added a comment about turning the internal storage into a table
* Linting
* Updated teh settings so that self is displayed slightly differently
* First pass at writing the code
* Changed the code to catch the case wehre columns weren't being created
* Included justification to the init thingies
* Included comments on what I need to do next
* Exposed the functions. Made some tests. Updated the example. Still some more work to be done
* Got rid of a comment
* udpated the names of some of the tests to better reflect that they're testing specifically the justification of the rows
* Included Python doco for all of the methods
* Updated to include columns setting the justification as well as lintint
* Fixed the issue with the header row not having a border on the bottom
* linting
* Updated the tests to include testing the columns
* linting
* Updated the notes with what I have left to do
* Updated the TODO comment
* Updated the examples to include a more coherent example of what was being implemented
* Changed a comment slightly
* Fixed up and cleaned up some code
* Linting
* Updated the tests to match changing the default justification to the left justification
* Updated the README
* Got rid of comments that I had already completed
@@ -3,7 +3,9 @@ A project to dynamically scale and print tables using text in Python
3
3
4
4
# Usage
5
5
6
-
Python Table Print is object-oriented. This means that a `PrintTable` object gets instantiated and added to/edited. When the table is ready to be printed/created, this can be done by calling the `print_table`/`get_table` methods. An example can be found in `example.py`, but is copied here for convenience:
6
+
Python Table Print is object-oriented. This means that a `PrintTable` object gets instantiated and added to/edited. When the table is ready to be printed/created, this can be done by calling the `get_table` method. An example can be found in `example.py`, but is copied here for convenience:
In the above example, the `print_table` method was called which prints using the default `print` function. However, if the table in string form is preferred, then this is also easily achievable:
34
+
As shown in the above example, getting the current table is as simple as calling the `get_table()` method. This returns the table as a simple string. This can then be passed to whatever function you like, in this case the `print` function.
35
+
36
+
## Header
37
+
38
+
By default, the first row of the table is treated as the header of the table, and is printed with an extra border around it, not done for any other row. This behaviour can be turned off/on by setting the property `has_header` to `True`/`False`:
33
39
34
40
```python
35
41
from table import PrintTable
36
42
37
43
my_table = PrintTable()
38
44
45
+
my_table.add_row("Col 1", "Col 2", "Col 3")
46
+
my_table.add_row("Entry 1", "Entry number 2", "Entry 3 baby")
47
+
my_table.add_row("Another entry", "yay", "an entry in the table")
48
+
my_table.add_row("Fun times", "This is kinda cool", "wooow")
Be default, all of the cells are justified to the left. However, justification can be changed for the entire table, for a row or column, or for individual cells. Whenever a justification is set it overrides any previous justification set on that/those cell/cells. Note that `Justification` also needs to be imported.
67
+
68
+
### Justification for the Table:
69
+
70
+
```python
71
+
from table import PrintTable, Justification
72
+
73
+
my_table = PrintTable()
74
+
75
+
my_table.add_row("Col 1", "Col 2", "Col 3")
76
+
my_table.add_row("Entry 1", "Entry number 2", "Entry 3 baby")
77
+
my_table.add_row("Another entry", "yay", "an entry in the table")
78
+
my_table.add_row("Fun times", "This is kinda cool", "wooow")
By default, the first row of the table is treated as the header of the table, and is printed with an extra border around it, not done for any other row. This behaviour can be turned off/on by setting the property `has_header` to `True`/`False`:
0 commit comments