We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When I print a rich ColorTriplet, I don't just want to see the values for red, green, and blue in my console. I also want to see the color.
I tried giving the ColorTriplet a new __rich_repr__ on the fly which also includes a small color swatch in its color.
__rich_repr__
ColorTriplet.__rich_repr__ = lambda self: [("red", self.red), ("green", self.green), ("blue", self.blue), ("color", Text("██", style=f"rgb({self.red}, {self.green}, {self.blue})"))]
However, the resulting console output looks like this:
>>> ColorTriplet(12,24,25) ColorTriplet(red=12, green=24, blue=25, color=<text '██' []>)
where '██' just gets displayed in the default green string color.
'██'
Can rich renderables not be used inside a __rich_repr__?
The text was updated successfully, but these errors were encountered:
Thank you for your issue. Give us a little time to review it.
PS. You might want to check the FAQ if you haven't done so already.
This is an automated reply, generated by FAQtory
Sorry, something went wrong.
That methods creates reprs, which are intended to be formatted like a Python expression. It won't produce any escape sequences.
Why do you want to print a ColorTriplet? It was only intended for the Color class, which already generates the actual color if you print it.
No branches or pull requests
When I print a rich ColorTriplet, I don't just want to see the values for red, green, and blue in my console. I also want to see the color.
I tried giving the ColorTriplet a new
__rich_repr__
on the fly which also includes a small color swatch in its color.However, the resulting console output looks like this:
where
'██'
just gets displayed in the default green string color.Can rich renderables not be used inside a
__rich_repr__
?The text was updated successfully, but these errors were encountered: