Static widget can't handle [] properly #5582
-
Have you checked closed issues? (https://github.com/Textualize/textual/issues?q=is%3Aissue+is%3Aclosed) Have you checked against the most recent version of Textual? (https://pypi.org/search/?q=textual) The bugMarkupError: Expected markup style value (found '00] foo bar').
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
We found the following entries in the FAQ which you may find helpful: Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review. This is an automated reply, generated by FAQtory |
Beta Was this translation helpful? Give feedback.
-
Hi @tibetsam This fixes your string |
Beta Was this translation helpful? Give feedback.
-
You can also set |
Beta Was this translation helpful? Give feedback.
-
Is there a way to automatically escape a string to make it valid for rich.print("Toggle [1, 2] Me") works as expected, but for widgets, the string causes problems (See example at the bottom). Motivation: I have arbitarty python code, that I want to show as title of a Collapsible. Here a small example, where it fails: import textual.app
import textual.widgets
import textual.markup
class CollapsibleExample(textual.app.App):
def compose(self):
yield textual.widgets.Collapsible(
textual.widgets.Label("Inside!"),
title=textual.markup.escape("Toggle [1, 2] Me"), # <-- The "[" causes the error
# title="Toggle [1, 2] Me", # <-- also fails
)
if __name__ == "__main__":
CollapsibleExample().run() |
Beta Was this translation helpful? Give feedback.
You can also set
markup=False
on the widget to not process markup.https://textual.textualize.io/guide/content/