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

Revisit and review the makeup of TabbedContent and its dependant parts #2411

Closed
davep opened this issue Apr 27, 2023 · 2 comments · Fixed by #3059
Closed

Revisit and review the makeup of TabbedContent and its dependant parts #2411

davep opened this issue Apr 27, 2023 · 2 comments · Fixed by #3059
Labels
bug Something isn't working enhancement New feature or request Task

Comments

@davep
Copy link
Contributor

davep commented Apr 27, 2023

After the recent review/revamp of containers, it's looking like ContentSwitcher and related things, such as TabbedContent, might have suffered a wee bit in terms of unintended consequences. See #2408 as an example. To borrow the code from there, this:

from textual.app import App, ComposeResult
from textual.widgets import TabbedContent, TabPane, Label
from textual.containers import Vertical, Horizontal

class ExampleApp(App):

    def compose(self) -> ComposeResult:
        with TabbedContent():

            with TabPane('a'):
                yield Label('1')
                yield Label('2')
                yield Label('3')

            with TabPane('b'):
                with Vertical():
                    yield Label('1')
                    yield Label('2')
                    yield Label('3')

            with TabPane('c'):
                with Vertical():
                    with Horizontal():
                        yield Label('1')
                    with Horizontal():
                        yield Label('2')
                    with Horizontal():
                        yield Label('3')

            with TabPane('d'):
                yield Label('1')
                with Vertical():
                    yield Label('2')
                    yield Label('3')
                yield Label('4')

if __name__ == '__main__':
    app = ExampleApp()
    app.run()

behaves in unexpected ways out of the box. Styling with:

TabbedContent ContentSwitcher {
    height: 1fr;
}

has the code working in a more expected way.

I think we need to go back over the container-oriented parts of this chain of widgets to be totally sure we've now got the best choices of parent classes and widget-specific default styling.

Credit to @ankraft for identifying the problem, creating a nice self-contained example and reporting it.

@davep davep added bug Something isn't working enhancement New feature or request Task labels Apr 27, 2023
@davep
Copy link
Contributor Author

davep commented May 12, 2023

We should probably move this into TODO as soon as possible; this one seems to be biting a lot of people. Seems to be turning into quite an FAQ.

@github-actions
Copy link

github-actions bot commented Aug 7, 2023

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
bug Something isn't working enhancement New feature or request Task
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant