A new form of Checkbox will be arriving in Textual soon, working in
conjunction with a RadioButton. What was called Checkbox is perhaps a wee
bit heavyweight in terms of visual design, but is a style of widget that
should remain.
With this in mind we're renaming the current Checkbox to Switch. In all
other respects its workings remains the same, only the name has changed.
Things for people to watch out for:
- Imports will need to be updated.
- Queries will need to be updated; special attention will need to be paid to
any queries that are string-based.
- CSS will need to be changed if any Checkbox styling is happening, or if
any Checkbox component styles are being used.
See #1725 as the initial motivation and #1746 as the issue for this
particular change.
After some internal discussion we've decided to keep `Tree.clear` as it was,
and add a `Tree.reset`, which does a `Tree.clear` but resets the label and
data of `Tree.root` to the values given, while mirroring how `Tree.__init__`
takes those parameters.
Just before doing the commit I decided to rename the test tree in the new
unit test for clearing down a tree. Of course I managed to name it in such a
way that it becomes special to pytest.
This fixes that.
See #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.
There are actions that relate to editing the input too, which I also want to
test, but I'm not minded to lump them all in the same file. So here I'm
renaming to make it clear these tests are just about movement. The editing
ones will come next in their own file.