[affich_tools] Ajout d'une largeur optionnelle à la fonction tableau.
This commit is contained in:
parent
82b5caa988
commit
b3420a3152
1 changed files with 7 additions and 4 deletions
|
@ -143,7 +143,7 @@ def cprint(txt, col='blanc', newline=True):
|
||||||
else:
|
else:
|
||||||
print t,
|
print t,
|
||||||
|
|
||||||
def tableau(data, titre=None, largeur=None, alignement=None, format=None, dialog=False):
|
def tableau(data, titre=None, largeur=None, alignement=None, format=None, dialog=False, width=None):
|
||||||
"""
|
"""
|
||||||
Retourne une chaine formatée repésentant un tableau.
|
Retourne une chaine formatée repésentant un tableau.
|
||||||
|
|
||||||
|
@ -200,6 +200,9 @@ def tableau(data, titre=None, largeur=None, alignement=None, format=None, dialog
|
||||||
if not largeur :
|
if not largeur :
|
||||||
largeur = [ max([len(re.sub('\\\Z.' if dialog else '\x1b\[1;([0-9]|[0-9][0-9])m','',ligne[i])) for ligne in data]) for i in range(nbcols) ]
|
largeur = [ max([len(re.sub('\\\Z.' if dialog else '\x1b\[1;([0-9]|[0-9][0-9])m','',ligne[i])) for ligne in data]) for i in range(nbcols) ]
|
||||||
elif '*' in largeur:
|
elif '*' in largeur:
|
||||||
|
if width:
|
||||||
|
cols = width
|
||||||
|
else:
|
||||||
rows, cols = get_screen_size()
|
rows, cols = get_screen_size()
|
||||||
if dialog:
|
if dialog:
|
||||||
cols = cols - 6
|
cols = cols - 6
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue