forked from Textualize/textual
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add public access to a TreeNode's label
This adds public support to reading a TreeNode's label, and also setting it too. See Textualize#1396.
- Loading branch information
Showing
3 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from textual.widgets import Tree, TreeNode | ||
from rich.text import Text | ||
|
||
def test_tree_node_label() -> None: | ||
"""It should be possible to modify a TreeNode's label.""" | ||
node = TreeNode(Tree[None]("Xenomorph Lifecycle"), None, 0, "Facehugger") | ||
assert node.label == Text("Facehugger") | ||
node.label = "Chestbuster" | ||
assert node.label == Text("Chestbuster") | ||
|
||
def test_tree_node_label_via_tree() -> None: | ||
"""It should be possible to modify a TreeNode's label when created via a Tree.""" | ||
tree = Tree[None]("Xenomorph Lifecycle") | ||
node = tree.root.add("Facehugger") | ||
assert node.label == Text("Facehugger") | ||
node.label = "Chestbuster" | ||
assert node.label == Text("Chestbuster") |