Skip to content
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

Add index to Tree widget's add #4049

Open
davetapley opened this issue Jan 20, 2024 · 3 comments
Open

Add index to Tree widget's add #4049

davetapley opened this issue Jan 20, 2024 · 3 comments

Comments

@davetapley
Copy link
Contributor

Presently there is no way to add a new tree node except as the last node, accordingly:

Would you accept an optional indexhere?

def add(
self,
label: TextType,
data: TreeDataType | None = None,
*,
expand: bool = False,
allow_expand: bool = True,
) -> TreeNode[TreeDataType]:

If set it would change this from append to insert and pass index:

self._children.append(node)

Copy link

We found the following entries in the FAQ which you may find helpful:

Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review.

This is an automated reply, generated by FAQtory

@willmcgugan
Copy link
Collaborator

Would that cover all use-cases? What if you want to insert before another item, or at the start.

The mount method has a before and after parameter. Maybe we need something similar.

@davetapley
Copy link
Contributor Author

@willmcgugan it would, but the caller would be responsible for figuring out the index.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants