Adding children to ContentSwitcher #4682
-
Hello! QuestionHow can I add a new child to a What I've triedI tried calling I did notice that the content switcher goes back to showing only one child after I've switched Why I'm trying to do thisI'm making a utility to track nodes on a CAN bus. On the left side of my UI, I have a live list of nodes detected. Selecting an item should cause the content switcher on the right show info about the node. Nodes may appear or disappear at any time. Relevant discussion#2751 Allowed Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I found a solution! I can properly add a new child to a content switcher by first setting its display property: new_child = Foo()
new_child.display = False
content_switcher.mount(new_child) Maybe it would be good to mention this in the documentation? |
Beta Was this translation helpful? Give feedback.
-
You can instead use the However I spotted this is missing from the docs as they haven't been deployed for a few weeks. I've opened issue #4685 to flag this! |
Beta Was this translation helpful? Give feedback.
You can instead use the
ContentSwitcher.add_content
method added in Textual v0.68 - see #4642.However I spotted this is missing from the docs as they haven't been deployed for a few weeks. I've opened issue #4685 to flag this!