question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Table: Different behavior using `row_styles` vs. styling each row

See original GitHub issue

Describe the bug There seem to be different behavior using row_styles compared to do the styling in the add_row command.

To Reproduce

console = Console()

bg = Style(bgcolor="rgb(120,40,40)")

table1 = Table(box=box.SIMPLE_HEAD, title="table1", row_styles=["none", bg])
table1.add_column("foo")
table1.add_column("bar")
table1.add_row("1", "2")
table1.add_row("3", "4")
console.print(table1)

table2 = Table(box=box.SIMPLE_HEAD, title="table2")
table2.add_column("foo")
table2.add_column("bar")
table2.add_row("1", "2", style="none")
table2.add_row("3", "4", style=bg)
console.print(table2)

image

Platform Windows 10, Windows terminal, rich 9.2.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
mhedencommented, Dec 2, 2020

Thanks for the hint! I did the following which works fine:

        for row in rows:
            values, level = row
            table.add_row(*values)
            table.row_styles.append(bgs[level])
1reaction
willmcgugancommented, Dec 2, 2020

You can set row_styles to a list of strings after the Table is constructed. But I agree the style on add_row should probably set it for the whole row. I’ll look in to changing that in a next release.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] Table: Different behavior using `row_styles` vs. styling ...
Describe the bug There seem to be different behavior using row_styles compared to do the styling in the add_row command.
Read more >
TableLayoutPanel: Can't get content rows to size correctly
I was struggling a long time with the correct resizing behavior of this object until I found out, that I need to delete...
Read more >
Arranging Controls Using a TableLayoutPanel - Microsoft Learn
Setting Row and Column Properties​​ You can set individual properties of rows and columns by using the RowStyles and ColumnStyles collections.
Read more >
Excel table not formatting new rows appropriately - Super User
Oddly, some of my tables pass formatting (espec. cell type) to new cells in a column as expected using the same paste method....
Read more >
Cell Style Architecture in Windows Forms Grid - Syncfusion
Row Styles. Changes can be done for a particular or range of rows by using the RowStyles property. This property is a GridStyleInfo...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found