From b3420a31520437110c875500786e47143d6f45af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Elliott=20B=C3=A9cue?= Date: Mon, 10 Mar 2014 10:03:56 +0100 Subject: [PATCH] =?UTF-8?q?[affich=5Ftools]=20Ajout=20d'une=20largeur=20op?= =?UTF-8?q?tionnelle=20=C3=A0=20la=20fonction=20tableau.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gestion/affich_tools.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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)