Skip to content

How to dynamically add child TapPane into TabbedContent #2412

Answered by Ljzd-PRO
Ljzd-PRO asked this question in Q&A
Discussion options

You must be logged in to vote

Add a append method and modify Tabs object and ContentSwitcher object to add TabPane and it works.

class DynamicTabbedContent(TabbedContent):
    def __init__(self, *titles: TextType):
        super().__init__(*titles)
        self.tabs: Optional[Tabs] = None
        self.content_switcher: Optional[ContentSwitcher] = None

    @classmethod
    def _set_id(cls, content: TabPane, new_id: str) -> TabPane:
        """Set an id on the content, if not already present.

        Args:
            content: a TabPane.
            new_id: New `is` attribute, if it is not already set.

        Returns:
            The same TabPane.
        """
        if content.id is None:
            content.id = n…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Ljzd-PRO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant