One liner to construct mixed color text for console.print? #1775
-
Is there an easy way to construct a rich text string that has multiple colored components on a single line? For example, I want to construct a string like f"This is a {test} and another {test2} and something" Where test is green and test2 is blue. From what I can tell, in order to do this I'd have to do something like:
Is there a 1 liner that I can accomplish the same thing? |
Beta Was this translation helpful? Give feedback.
Answered by
willmcgugan
Dec 23, 2021
Replies: 1 comment 1 reply
-
Two options: msg = Text.from_markup("This is a [green]test[/] and another [blue]test2[/] and something") msg = Text.assemble(
"This is a ",
("test", "green"),
" and another ",
("test2, blue"),
" and something"
) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
hemna
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Two options: