Skip to content

Conditional styling #1261

Answered by willmcgugan
axiomiety asked this question in Ideas
May 28, 2021 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Not convinced this is a good idea. Rich tables deliberately don't care too much about the contents of the cells, and only needs to know how to render them. Adding this callable would require the Table class to have at least some understanding of the cell contents.

I think there may be better ways of achieving this, albeit not quite as transparently.

One option would be to create a highlighter that highlights the text "failed" and "pass" differently. See highlighters in the docs.

Another option (and my preferred option) would be to create a renderable that renders the appropriate result based on a boolean. Something like this:

class Status:
    def __init__(self, success:bool) -> None:
   …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@axiomiety
Comment options

Answer selected by axiomiety
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants