-
Notifications
You must be signed in to change notification settings - Fork 818
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
[Tree] Allow for the complete repopulation of a Tree
.
#1437
Labels
Comments
Maybe add a root label option to |
willmcgugan
changed the title
Consider allowing for the complete repopulation of a
[Tree] Consider allowing for the complete repopulation of a Jan 19, 2023
Tree
.Tree
.
davep
changed the title
[Tree] Consider allowing for the complete repopulation of a
[Tree] Allow for the complete repopulation of a Feb 1, 2023
Tree
.Tree
.
davep
added a commit
to davep/textual
that referenced
this issue
Feb 1, 2023
See Textualize#1437 for background. While it would be ideal to allow for the complete emptying of a Tree, the root node is required (and it's part of the construction of a Tree). So, here, when clearing the Tree we optionally allow for a new label to be given. Ideally we'll also allow for fresh data to be provided too; but there's a wrinkle there in knowing the difference between the data being None, and no data being provided (so the current root's data being carried over). Following the method of defaulting used in __init__ would cause problems. As such, rather than roll all of this into one commit, this goes with the basic requirement and the solution for data will follow. Note this also starts some unit tests for the clearing of a Tree.
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
Slightly related to #1396 in that to do it now the ability to change a
TreeNode.label
would be required. At the moment it is possible to useTree.clear
to clear all the nodes under the root node, but there appears to be no public interface for totally clearing aTree
and repopulating it from scratch -- other that performing aremove
on the widget itself and then amount
of a fresh instance.A use case for this would be if the
Tree
is being used to view the content of a file in a structured way, and you want the user to be able to load in a new file.The text was updated successfully, but these errors were encountered: