You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'll echo the others here by first expressing my thanks for making such a great tool. I'm an enthusiast, and rich has become an integral part of my daily code. I greatly admire your work.
I'm having an issue with panels. If a Panel instance has stylized title and subtitle attributes, their styles will invariably be overwritten by whatever the border_style is at the time of rendering (if a border style is present). I would expect this kind of behavior if title and subtitle were without styles, but not when they've been explicitly defined in the Panel instance.
How to Recreate
This code will recreate the problem.
from rich.panel import Panel
from rich.text import Text
from rich import print
title = Text("Wake up!", "bold #ffb703")
subtitle = Text("The world says hello!", "italic #f64740")
renderable = Text(f"A panel with 'title' and 'subtitle' elements")
panel = Panel(
renderable=renderable,
title=title,
subtitle=subtitle,
border_style="#5EAD7A",
style='bold #81adc8'
)
print(panel)
panel = Panel(
renderable=renderable,
title=title,
subtitle=subtitle,
)
panel.style='bold #81adc8'
print(panel)
Which produces
I would expect the title/subtitles in the resulting panels would be stylized according to what's specified in the Panel instance, like this
Root Cause
I think this problem is due to the way the __rich_console__ method for Panel overwrites the styling for title_text and subtitle_text with border_style (if Panel.border_style != "none"), irrespective of whether styling for Panel.title or Panel.subtitle were defined already. The code in question:
I've forked rich and made local modifications with a possible solution. I'll create a pull request in accordance with your guidelines later today so we can review.
This problem is tangential to issue 2446, but not the same. The code introduced by pull request 2543 aimed at resolving the issue is what resulted in the current behavior.
I'll echo the others here by first expressing my thanks for making such a great tool. I'm an enthusiast, and
rich
has become an integral part of my daily code. I greatly admire your work.To the problem...
Problem Description
I'm having an issue with panels. If a
Panel
instance has stylizedtitle
andsubtitle
attributes, their styles will invariably be overwritten by whatever theborder_style
is at the time of rendering (if a border style is present). I would expect this kind of behavior iftitle
andsubtitle
were without styles, but not when they've been explicitly defined in thePanel
instance.How to Recreate
This code will recreate the problem.
Which produces
I would expect the title/subtitles in the resulting panels would be stylized according to what's specified in the
Panel
instance, like thisRoot Cause
I think this problem is due to the way the
__rich_console__
method forPanel
overwrites the styling fortitle_text
andsubtitle_text
withborder_style
(ifPanel.border_style != "none"
), irrespective of whether styling forPanel.title
orPanel.subtitle
were defined already. The code in question:rich.panel.Panel; 198-199
rich.panel.Panel; 247-248
Proposed Solution
I've forked
rich
and made local modifications with a possible solution. I'll create a pull request in accordance with your guidelines later today so we can review.Platform & Configuration Details
Click to expand
xfce4-terminal
The text was updated successfully, but these errors were encountered: