diff --git a/gestion/affich_tools.py b/gestion/affich_tools.py index d2652395..f29aaa13 100755 --- a/gestion/affich_tools.py +++ b/gestion/affich_tools.py @@ -143,7 +143,7 @@ def cprint(txt, col='blanc', newline=True): else: 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. @@ -200,9 +200,12 @@ def tableau(data, titre=None, largeur=None, alignement=None, format=None, dialog 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) ] elif '*' in largeur: - rows, cols = get_screen_size() - if dialog: - cols = cols - 6 + if width: + cols = width + else: + rows, cols = get_screen_size() + if dialog: + cols = cols - 6 for i in range(nbcols) : if largeur[i] in ['*',-1] : largeur[i] = max(cols - sum([l for l in largeur if l != '*']) - nbcols - 1, 3)