Skip to content

Is it possible to create TabbedContent widget in on_mount? #5709

Closed Answered by python-and-novella
python-and-novella asked this question in Q&A
Discussion options

You must be logged in to vote

I get a solution which is compatible to all ways:

from textual.app import App
from textual.widgets import TabbedContent,TabPane,Static

# 补丁 TabbedContent
from textual.widgets import TabbedContent,TabPane
from textual.content import ContentType,Content
from textual.widget import Widget
class TabbedContent(TabbedContent):
    def __init__(self,*children:list[TabPane|Widget]|list[ContentType], initial = '', name = None, id = None, classes = None, disabled = False):
        super().__init__(initial=initial, name=name, id=id, classes=classes, disabled=disabled)
        self.titles = []
        if all(isinstance(child,Widget) for child in children):
            self._tab_content = list(children)…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by python-and-novella
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #5708 on April 06, 2025 14:56.