The main objetive of this module is to keep it really simple.
Basic usage:
1 2 3 4 5 6 7 8 9 10 11 12 | >>> from pybles import pybles
>>> PB = pybles.Pyble()
>>> PB.add_column('First Name')
>>> PB.add_column('Last Name')
>>> PB.add_line(['John', 'Doe'])
>>> PB.show_table()
>>>
--------------------------
| First Name | Last Name |
--------------------------
| John | Doe |
--------------------------
|
Once you already added at least one line, header can’t be modified. If you try to do it, HeaderAlreadySet is raised:
1 2 3 4 5 6 7 8 9 10 11 | >>> from pybles import pybles
>>> PB = pybles.Pyble()
>>> PB.add_column('First Name')
>>> PB.add_column('Last Name')
>>> PB.add_line(['John', 'Doe'])
>>> PB.add_column('Age')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pybles/pybles.py", line 62, in add_column
raise HeaderAlreadySet
pybles.pybles.HeaderAlreadySet: El numero de columnas no puede ser modificado una vez seteadas filas
|
You must add a line with the correct number of cells. Each line is represented by a list and each element of the list represent a cell. If you don’t keep this in mind, IncorrectNumberOfCells will be raised.
1 2 3 4 5 6 7 8 9 10 | >>> from pybles import pybles
>>> PB = pybles.Pyble()
>>> PB.add_column('First Name')
>>> PB.add_column('Last Name')
>>> PB.add_line(['John'])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pybles/pybles.py", line 68, in add_line
raise IncorrectNumberOfCells
pybles.pybles.IncorrectNumberOfCells: La cantidad de celdas es incorrecta
|
Changing cells/table tokens:
1 2 3 4 5 6 7 8 9 10 11 12 | >>> from pybles import pybles
>>> PB = pybles.Pyble(row_token='$', column_token='+')
>>> PB.add_column('First Name')
>>> PB.add_column('Last Name')
>>> PB.add_line(['John', 'Doe'])
>>> PB.show_table()
>>>
$$$$$$$$$$$$$$$$$$$$$$$$$$
+ FIRST NAME + LAST NAME +
$$$$$$$$$$$$$$$$$$$$$$$$$$
+ John + Doe +
$$$$$$$$$$$$$$$$$$$$$$$$$$
|
Using colors with the default schema:
1 2 3 4 5 6 7 | >>> from pybles import pybles
>>> PB = pybles.Pyble()
>>> PB.set_color(True)
>>> PB.add_column('First Name')
>>> PB.add_column('Last Name')
>>> PB.add_line(['John', 'Doe'])
>>> PB.show_table()
|
1 2 3 4 5 6 7 8 9 | >>> from pybles import pybles
>>> PB = pybles.Pyble(header_color='STRONG_YELLOW', header_background_color='BG_BLUE',
cell_a_color='STRONG_BLUE', cell_b_color='STRONG_YELLOW',
cell_a_background_color='BG_YELLOW', cell_b_background_color='BG_BLUE')
>>> PB.set_color(True)
>>> PB.add_column('First Name')
>>> PB.add_column('Last Name')
>>> PB.add_line(['John', 'Doe'])
>>> PB.show_table()
|
Supported colors are:
OKBLUE BG_BLACK BG_RED YELLOW BG_WHITE GREEN BG_YELLOW RED STRONG_RED OKGREEN PURPLE STRONG_PURPLE WARNING STRONG_TURQUESA HEADER FAIL WHITE BG_PURPLE BG_GREEN BG_GRAY BLUE BG_TURQUESA STRONG_GREEN STRONG_BLUE TURQUESA STRONG_WHITE STRONG_YELLOW BG_BLUE