From c44191bc2cf07efe97fc78af6b2ff55ec0b1505a Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Tue, 22 Jun 2021 04:49:25 +0200 Subject: [PATCH] [enh] allow to add caption to table --- moulinette/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/moulinette/__init__.py b/moulinette/__init__.py index c2eb1120..15d29d4b 100755 --- a/moulinette/__init__.py +++ b/moulinette/__init__.py @@ -65,10 +65,11 @@ console.format_exception = _format_exception class Table: - def __init__(self, data, columns=None, title=None, row_function=None): + def __init__(self, data, columns=None, title=None, row_function=None, caption=""): self.data = data self.columns = columns self.title = title + self.caption = caption self.row_function = row_function def __getitem__(self, key): @@ -87,6 +88,8 @@ class Table: table_name = list(self.data.keys())[0] table.title = f"[bold]{self.title if self.title else table_name}[/]" table.title_style = Style(color="white", bgcolor=None) + table.caption = "[dim]" + self.caption + "[/dim]" + table.caption_style = Style(color="white", bgcolor=None) table.row_styles = ["none", "dim"] table.box = box.SIMPLE_HEAD table.border_style = "bright_yellow"