def render_tables(): console = Console( width=60, force_terminal=True, file=io.StringIO(), legacy_windows=False, color_system=None, ) table = Table(title="test table", caption="table caption", expand=True) table.add_column("foo", footer=Text("total"), no_wrap=True, overflow="ellipsis") table.add_column("bar", justify="center") table.add_column("baz", justify="right") table.add_row("Averlongwordgoeshere", "banana pancakes", None) assert Measurement.get(console, table, 80) == Measurement(41, 48) for width in range(10, 60, 5): console.print(table, width=width) table.expand = False console.print(table, justify="left") console.print(table, justify="center") console.print(table, justify="right") assert table.row_count == 1 table.row_styles = ["red", "yellow"] table.add_row("Coffee") table.add_row("Coffee", "Chocolate", None, "cinnamon") assert table.row_count == 3 console.print(table) table.show_lines = True console.print(table) table.show_footer = True console.print(table) table.show_edge = False console.print(table) table.padding = 1 console.print(table) table.width = 20 assert Measurement.get(console, table, 80) == Measurement(20, 20) console.print(table) return console.file.getvalue()
table.expand = True header("expand=True") console.print(table, justify="center") table.width = 50 header("width=50") console.print(table, justify="center") table.width = None table.expand = False table.row_styles = ["dim", "none"] header("row_styles=['dim', 'none']") console.print(table, justify="center") table.width = None table.expand = False table.row_styles = ["dim", "none"] table.leading = 1 header("leading=1, row_styles=['dim', 'none']") console.print(table, justify="center") table.width = None table.expand = False table.row_styles = ["dim", "none"] table.show_lines = True table.leading = 0 header("show_lines=True, row_styles=['dim', 'none']") console.print(table, justify="center")