-
Notifications
You must be signed in to change notification settings - Fork 876
Tabs widget does not support Rich #5635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 |
It looks like the problem is a mismatch between the expected types for I'm not sure what the correct fix is as it needs a maintainer to confirm the correct update to the types. But here's a workaround in the meantime: from textual.app import App, ComposeResult
from textual.content import Content
from textual.widgets import Tab, Tabs
class ExampleApp(App):
def compose(self) -> ComposeResult:
yield Tabs(
# workaround for https://github.com/Textualize/textual/issues/5635
Tab(Content.from_rich_text("[green]Markup & emoji :smiley:"))
)
if __name__ == "__main__":
app = ExampleApp()
app.run() Footnotes |
Hi @TomJGooding - thanks for looking into this. That does work, but still doesn't support Rich Themes :/ |
There's been some major changes in Textual recently, including its own theming and content system. Since this moves away from rendering with Rich objects, I'm afraid using Rich Themes this way is likely no longer supported (but this really needs a maintainer to confirm). You might want to explore app-specific variables as a possible alternative. This allows mapping a variable name to a value, which can also then be overridden by a Textual theme. |
Yeah, I read about that. The one thing as well is emojis are not natively supported using |
Revert the type of the `Tab` label to `TextType`. Currently there's a mismatch between the expected types for `Tabs` and `Tab`, which can cause the app to crash. While `Tabs` still expects a `TextType`, the `Tab` was recently updated to expect a `ContentType`. Since the tabs documentation is based on using `Text` objects, I think reverting this changes makes sense, especially given that `Tab` seems to be the only widget that now exclusively expects `ContentType`. This might _technically_ be a breaking change, but the current incompatibility of types means that the tabs were broken anyway. Fixes Textualize#5635.
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
Rich theme (and Rich in general) is not being supported with
Tabs
widget usingv2.0.0
. Also, emojis are not working anymore.I tried to use
from_markup
, but it isn't working:Error:
AttributeError: 'Text' object has no attribute 'translate'
MRE:
The text was updated successfully, but these errors were encountered: