Should RichLog support colors (and may be other features) on Windows terminal? #3888
-
|
Since version 1909 Windows support ANSI colors in I make But does not see any colors (running sample from https://github.com/davidfokkema/playground-textual/blob/main/console_richlog.py ) Is something wrong with my setup, or RichLog should not support Windows at all? |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 10 replies
-
|
Is your question about the What do you see if you run this example below? from rich.text import Text
from textual.app import App, ComposeResult
from textual.widgets import RichLog
class ExampleApp(App):
def compose(self) -> ComposeResult:
yield RichLog()
def on_mount(self) -> None:
rich_log = self.query_one(RichLog)
red_text = Text.from_ansi("\033[31mRed Text\033[0m")
green_bkgd = Text.from_ansi("\033[42mGreen Background\033[0m")
rich_log.write(red_text)
rich_log.write(green_bkgd)
if __name__ == "__main__":
app = ExampleApp()
app.run() |
Beta Was this translation helpful? Give feedback.
-
|
Hmm. I see colors Even But then I run |
Beta Was this translation helpful? Give feedback.
-
|
Same story in standard Windows Terminal |
Beta Was this translation helpful? Give feedback.
-
|
Same picture on new official Windows Terminal (not «cmd»)
|
Beta Was this translation helpful? Give feedback.
-
|
Hi, original author of the Regarding this issue: RichLog does support colour, both with the ansi roundtrip as shown by @TomJGooding, and also simply with |
Beta Was this translation helpful? Give feedback.
-
|
Thanks all for answers, thanks @davidfokkema for My intent is simple idea:
Yes, But on first sight, looks, like
But unfortunately, as you see, dont work on Windows.
Yes, it is the answer. :( So, may be an issue/RFE about "cross-platform/Windows support of RichLog" exists? I would like to subscribe to it. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.










Hi, original author of the
console_richlog.pyscript here. Some context: this was a test to see if I could get coloured output from a subprocess into RichLog. This was not intended to be cross-platform at the moment, just trying out what pieces were in place and what was still missing. So, Rich (?) would detect it was not running in a terminal and would not output colour at all. Fixed with the environment variable, but that does not work on Windows like that. Then, RichLog does understand Rich markup, but not ansi codes. So, had to useText.from_ansi()which did work: on MacOS, I see coloured log entries in my RichLog! However, the Rich example moves the cursor back and you see updating p…