TABLE
#
Module table
is for printing a colored table in the terminal console
output.
CLASS table
#
- class mdsanima_dev.utils.table.table#
This class create template table with colors, headers and content.
- colors(color: int = 255) int #
Initial color table. Only use for this class.
- Parameters:
color (int, optional) – Color of the table, defaults to
255
.- Returns:
Number of colors from
colors
module.- Return type:
int
- connect(top: bool, length: int, bot: bool) str #
Checking for connectiong table.
- Parameters:
top (bool) – Top element of the table.
length (int) – Length of the table.
bot (bool) – Bottom element of the table.
- Returns:
Element printing of the table in unicode value.
- Return type:
str
METHOD headers()
#
- table.headers(header: str, hcolor: int = 255, top: bool = False, bot: bool = False, tcolor: int = 255) str #
Headers of the template table.
- Parameters:
header (str) – Headers text.
hcolor (int, optional) – Color of text, defaults to
255
.top (bool, optional) – Check connecting top, defaults to
False
.bot (bool, optional) – Check connecting bootom, defaults to
False
.tcolor (int, optional) – Table color, defaults to
255
.
- Returns:
Headers element of template table.
- Return type:
str
- Usage:
Assigning function calling to a variable:
from mdsanima_dev.utils.table import table love = "I Love Python MDSANIMA.COM" t = table() t.headers(love) t.headers(love, hcolor=50) t.headers(love, hcolor=197, tcolor=203) t.headers(love.center(40), hcolor=34, tcolor=220)




METHOD content()
#
- table.content(content_key: str, content_val: str, key_color: int = 255, val_color: int = 255, top: bool = False, bot: bool = False, tcolor: int = 255) str #
Content of the template table. This table constrain two text value.
- Parameters:
content_key (str) – First text value in the left.
content_val (str) – Second text value in the right.
key_color (int, optional) – Text color content key, defaults to
255
.val_color (int, optional) – Text color content value, defaults to
255
.top (bool, optional) – Check connecting top, defaults to
False
.bot (bool, optional) – Check connecting bootom, defaults to
False
.tcolor (int, optional) – Table color, defaults to
255
.
- Returns:
Content element of template table.
- Return type:
str
- Usage:
Assigning function calling to a variable:
from mdsanima_dev.utils.table import table love = "I Love Python" u = "MDSANIMA.COM" j = 20 t = table() t.content(love, u) t.content(love, u, tcolor=197) t.content(love, u, tcolor=227, key_color=86, val_color=76) t.content(love.rjust(j), u.ljust(j), tcolor=31, key_color=32, val_color=33)




CLASS table_elem
#
- class mdsanima_dev.utils.table.table_elem(color: int)#
Element of the table to create your own, what you want.
METHOD bot()
#
- table_elem.bot(length: int) str #
Bootom element of the table.
- Parameters:
length (int) – Length of the table element.
- Returns:
Unicode bootom element printing in one line.
- Return type:
str
METHOD con()
#
- table_elem.con(length: int, key: str, val: str, k_clr: int, v_clr: int) str #
Content element of the table two text value.
- Parameters:
length (int) – Length of the table element.
key (str) – Text printing inside table in the left.
val (str) – Text printing inside table in the right.
k_clr (int) – Text color key.
v_clr (int) – Text color value.
- Returns:
Unicode content element printing in one line.
- Return type:
str
METHOD hed()
#
- table_elem.hed(length: int, text: str, text_color: int) str #
Header element of the table on text value.
- Parameters:
length (int) – Length of the table element.
text (str) – Text printing inside table.
text_color (int) – Text color value.
- Returns:
Unicode header element printing in one line.
- Return type:
str
METHOD mid()
#
- table_elem.mid(length: int) str #
Midle element of the table.
- Parameters:
length (int) – Length of the table element.
- Returns:
Unicode midle element printing in one line.
- Return type:
str
METHOD top()
#
- table_elem.top(length: int) str #
Top element of the table.
- Parameters:
length (int) – Length of the table element.
- Returns:
Unicode top element printing in one line.
- Return type:
str
EXAMPLE USAGE
#
This is a example function to make a colored table on class table_elem method. These example show three different tables that are not linked together:
from mdsanima_dev.utils.table import table_elem
def my_table():
t = table_elem(40)
t.top(64)
t.hed(64, "I love Python".center(62), 155)
t.bot(64)
t.top(64)
t.con(64, "Python", "hello world", 197, 203)
t.bot(64)
t.top(64)
t.hed(64, "mdsanima.com".center(62), 87)
t.bot(64)




This example shows how to create linked tables:
from mdsanima_dev.utils.table import table_elem
def my_table():
t = table_elem(40)
t.top(64)
t.hed(64, "I love Python".center(63), 155)
t.mid(64)
t.con(64, "mdsanima.com".rjust(28), "hello world", 197, 203)
t.con(64, "development".rjust(28), "in progress", 87, 86)
t.con(64, "documentation".rjust(28), "sphinx", 31, 61)
t.mid(64)
t.hed(64, "https://github.com/mdsanima-dev/mdsanima-dev/".center(63), 33)
t.bot(64)



