hscommon.gui.tree¶
| Tree() | Cross-toolkit GUI-enabled tree view. |
| Node(name) | Pretty bland node implementation to be used in a Tree. |
- class hscommon.gui.tree.Tree¶
Cross-toolkit GUI-enabled tree view.
This class is a bit too thin to be used as a tree view controller out of the box and HS apps that subclasses it each add quite a bit of logic to it to make it workable. Making this more usable out of the box is a work in progress.
This class is here (in addition to being a Node) mostly to handle selection.
Subclasses Node (it is the root node of all its children) and GUIObject.
- _select_nodes(nodes)¶
(Virtual) Customize node selection behavior.
By default, simply set _selected_nodes.
- selected_node¶
Currently selected node.
:class:`Node`. get/set.
First of selected_nodes. None if empty.
- selected_nodes¶
List of selected nodes in the tree.
List of :class:`Node`. get/set.
We use nodes instead of indexes to store selection because it’s simpler when it’s time to manage selection of multiple node levels.
- selected_path¶
Currently selected path.
:attr:`Node.path`. get/set.
First of selected_paths. None if empty.
- selected_paths¶
List of selected paths in the tree.
List of :attr:`Node.path`. get/set
Computed from selected_nodes.
- class hscommon.gui.tree.Node(name)¶
Pretty bland node implementation to be used in a Tree.
It has a parent, behaves like a list, its content being its children. Link integrity is somewhat enforced (adding a child to a node will set the child’s parent, but that’s pretty much as far as we go, integrity-wise. Nodes don’t tend to move around much in a GUI tree). We don’t even check for infinite node loops. Don’t play around these grounds too much.
Nodes are designed to be subclassed and given meaningful attributes (those you’ll want to display in your tree view), but they all have a name, which is given on initialization.
- clear()¶
Clears the node of all its children.
- findall(predicate, include_self=True)¶
Yield all children matching predicate.
Parameters: - predicate – f(node) --> bool
- include_self – Whether we can return self or we return only children.
- get_node(index_path)¶
Returns the node at index_path.
Parameters: index_path – a list of int indexes leading to our node. See path.
- children_count¶
Same as len(self).
- name¶
Name for the node, supplied on init.
- parent¶
Parent of the node.
If None, we have a root node.