Giter Club home page Giter Club logo

Comments (4)

TomJGooding avatar TomJGooding commented on July 24, 2024

I assume you mean when focusing a widget programmatically. Is my quick attempt at an example below a fair representation of this issue, where you would expect the tabs to switch automatically?

from textual.app import App, ComposeResult
from textual.widgets import Button, Footer, TabbedContent, TabPane


class ExampleApp(App):
    BINDINGS = [("space", "focus_button_2_2", "Focus button 2.2")]

    def compose(self) -> ComposeResult:
        with TabbedContent(id="tabbed-root"):
            with TabPane("[red]Parent 1[/]"):
                with TabbedContent():
                    with TabPane("[red]Child 1.1[/]"):
                        yield Button("Button 1.1", variant="error")
                    with TabPane("[red]Child 1.2[/]"):
                        yield Button("Button 1.2", variant="error")

            with TabPane("[green]Parent 2[/]", id="parent-2"):
                with TabbedContent(id="tabbed-parent-2"):
                    with TabPane("[green]Child 2.1[/]"):
                        yield Button("Button 2.1", variant="success")
                    with TabPane("[green]Child 2.2[/]", id="child-2-2"):
                        yield Button(
                            "Button 2.2",
                            variant="success",
                            id="button-2-2",
                        )

        yield Footer()

    def action_focus_button_2_2(self) -> None:
        # self.query_one("#tabbed-root", TabbedContent).active = "parent-2"
        # self.query_one("#tabbed-parent-2", TabbedContent).active = "child-2-2"

        self.query_one("#button-2-2", Button).focus()


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

from textual.

darrenburns avatar darrenburns commented on July 24, 2024

@TomJGooding Yes - I mean programmatically. Looks like your example captures it :)

from textual.

willmcgugan avatar willmcgugan commented on July 24, 2024

That's for the MRE Tom!

from textual.

github-actions avatar github-actions commented on July 24, 2024

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

from textual.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.