textual icon indicating copy to clipboard operation
textual copied to clipboard

Add index to Tree widget's add

Open davetapley opened this issue 5 months ago • 3 comments

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

Would you accept an optional indexhere? https://github.com/Textualize/textual/blob/ce962196c73b2b87c9f812f66a6f6ded3f2aaf4b/src/textual/widgets/_tree.py#L320-L327

If set it would change this from append to insert and pass index: https://github.com/Textualize/textual/blob/ce962196c73b2b87c9f812f66a6f6ded3f2aaf4b/src/textual/widgets/_tree.py#L344

davetapley avatar Jan 20 '24 00:01 davetapley

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

github-actions[bot] avatar Jan 20 '24 00:01 github-actions[bot]

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.

willmcgugan avatar Feb 27 '24 13:02 willmcgugan

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

davetapley avatar Feb 28 '24 22:02 davetapley