mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
10
CHANGELOG.md
10
CHANGELOG.md
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
|
## [0.10.0] - Unreleased
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added `TreeNode.parent` -- a read-only property for accessing a node's parent https://github.com/Textualize/textual/issues/1397
|
||||||
|
|
||||||
## [0.9.1] - 2022-12-30
|
## [0.9.1] - 2022-12-30
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
@@ -23,8 +29,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
|
|
||||||
- Widget.render_line now returns a Strip
|
- Widget.render_line now returns a Strip
|
||||||
- Fix for slow updates on Windows
|
- Fix for slow updates on Windows
|
||||||
- Bumped Rich dependency
|
- Bumped Rich dependency
|
||||||
|
|
||||||
## [0.8.2] - 2022-12-28
|
## [0.8.2] - 2022-12-28
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -121,6 +121,11 @@ class TreeNode(Generic[TreeDataType]):
|
|||||||
"""NodeID: Get the node ID."""
|
"""NodeID: Get the node ID."""
|
||||||
return self._id
|
return self._id
|
||||||
|
|
||||||
|
@property
|
||||||
|
def parent(self) -> TreeNode[TreeDataType] | None:
|
||||||
|
"""TreeNode[TreeDataType] | None: The parent of the node."""
|
||||||
|
return self._parent
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_expanded(self) -> bool:
|
def is_expanded(self) -> bool:
|
||||||
"""bool: Check if the node is expanded."""
|
"""bool: Check if the node is expanded."""
|
||||||
|
|||||||
10
tests/tree/test_tree_node_parent.py
Normal file
10
tests/tree/test_tree_node_parent.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from textual.widgets import TreeNode, Tree
|
||||||
|
|
||||||
|
def test_tree_node_parent() -> None:
|
||||||
|
"""It should be possible to access a TreeNode's parent."""
|
||||||
|
tree = Tree[None]("Anakin")
|
||||||
|
child = tree.root.add("Leia")
|
||||||
|
grandchild = child.add("Ben")
|
||||||
|
assert tree.root.parent is None
|
||||||
|
assert grandchild.parent == child
|
||||||
|
assert child.parent == tree.root
|
||||||
Reference in New Issue
Block a user