Update Tab class

This commit is contained in:
Gino D
2023-01-06 15:46:48 +01:00
parent 9f4b0903be
commit cbcc6d2b8d

View File

@@ -35,7 +35,7 @@ import subprocess
from serial import Serial
from dotenv import dotenv_values
from typing import List, Optional, Tuple, Union
from typing import List, Optional, Tuple, Union, Iterable
BUFFER_SIZE: int = 256
@@ -45,7 +45,7 @@ class Tab():
colsize: List = []
text_to_right: List = []
def __init__(self, *colsizes: int, nb_columns: int = 0, bordered: bool = False):
def __init__(self, *colsizes: int, align_to_right: Union[List, Tuple] = [], nb_columns: int = 0, bordered: bool = False):
self.colsize = list(colsizes)
self.bordered = bordered
auto_size = nb_columns - len(self.colsize)
@@ -57,6 +57,9 @@ class Tab():
for i in range(len(self.colsize), nb_columns):
self.colsize.append(column_size)
if isinstance(align_to_right, (list, tuple)):
self.align_to_right(*align_to_right)
def head(self, *texts: str):
self.border('=')
self.line(*texts, bordered=False)
@@ -85,7 +88,7 @@ class Tab():
word = word.strip()
next_sentence = ' '.join(lines[column_num][1][lineno] + [word])
if len(next_sentence) >= max_length:
if len(next_sentence) > max_length:
lineno += 1
lines[column_num][1].append([])