Skip to content
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

Passing Text as TabPane title causes an exception #5537

Closed
ihabunek opened this issue Feb 16, 2025 · 4 comments
Closed

Passing Text as TabPane title causes an exception #5537

ihabunek opened this issue Feb 16, 2025 · 4 comments

Comments

@ihabunek
Copy link

ihabunek commented Feb 16, 2025

In Textual 2.0, passing rich Text as TabPane title causes an exception:

MarkupError: 'Text' object has no attribute 'splitlines'

This should work since title is typed as TextType = Union[str, "Text"].

To reproduce:

from rich.text import Text
from textual.app import App, ComposeResult
from textual.widgets import Static, TabbedContent, TabPane


class BugApp(App):
    def compose(self) -> ComposeResult:
        with TabbedContent():
            with TabPane(Text("Tab")):
                yield Static("Content")


if __name__ == "__main__":
    app = BugApp()
    app.run()

Textual Diagnostics

Versions

Name Value
Textual 2.0.0
Rich 13.9.4

Python

Name Value
Version 3.12.8
Implementation CPython
Compiler GCC 14.2.1 20240912 (Red Hat 14.2.1-3)
Executable /home/ihabunek/projects/ihabunek/pgtui/.venv/bin/python3

Operating System

Name Value
System Linux
Release 6.12.7-100.fc40.x86_64
Version #1 SMP PREEMPT_DYNAMIC Fri Dec 27 17:00:45 UTC 2024

Terminal

Name Value
Terminal Application Kitty
TERM xterm-kitty
COLORTERM truecolor
FORCE_COLOR Not set
NO_COLOR Not set

Rich Console options

Name Value
size width=182, height=48
legacy_windows False
min_width 1
max_width 182
is_terminal False
encoding utf-8
max_height 48
justify None
overflow None
no_wrap False
highlight None
markup None
height None
Copy link

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

@dominikgehl
Copy link

Latest source code defines title as ContentType (https://github.com/Textualize/textual/blob/main/src/textual/widgets/_tabbed_content.py#L208)

Image

@ihabunek
Copy link
Author

Oh, I must have had a cached version I was looking at somehow. Sorry about the noise.

Copy link

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants