Skip to content

rich formatting in custom widget #1002

Answered by davep
nschloe asked this question in Q&A
Discussion options

You must be logged in to vote

Hi! I've checked with @willmcgugan and, as of now, Textual won't render markup that is within a renderable, but will render markup when the render method returns a string with markup in it. This is by design but we're going to have a rethink of this. Meanwhile, to make your code work as you were intending, you can use Rich's Text.from_markup on your string data. For example, taking your Info.Render method above:

    def render(self):
        table = Table(show_header=False, expand=True, box=None, padding=0)
        table.add_column(justify="left", no_wrap=True)
        table.add_column(justify="right", no_wrap=True)
        table.add_row(
            Text.from_markup("[b]abc[/]"),
       …

Replies: 1 comment 1 reply

Comment options

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

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