Tree¶
-
class
guerilla.
Tree
¶ Bases:
guerilla.Window
A simple tree list
This class implements basic behaviour for a tree organized list. It is possible to specialize some part of the tree behaviour to enrich the tree list window. By default, a Tree uses a simple tree of nested table, where children are stored in the array part. Each child might be a string or a table. If a child is a table, then Name must be filled with the child name.
LUA{ local tree = ui.tree (“tree”, parent) tree:settree ( {
“leafA”, “leafB”, “leafC”, { Name = “Node1”,
“leafAA”, { Name = “Node2”,
“leafAAA”, “leafBBB”, “leafCCC”,}, “leafBB”,
}
} ) }
-
canexpanditem
(item)¶ Override This method must return true if the item can be expanded, to display the expand button
Parameters: item – The tree item to query Returns: True iff item can be expanded Return type: bool
-
canselectitem
(item)¶ Override This method must return true if the item can be selected
Parameters: item – The tree item to query Returns: True iff item can be selected Return type: bool
-
getitemcolor
(item)¶ Override This method must return the text color for this item
Parameters: item – The tree item to query Returns: The item displayed color Return type: ui.color
-
getitemcount
(item)¶ Override This method must return the number of children item within a tree node.
Parameters: item – The tree item to query Returns: The number of children in the item Return type: number
-
getitemicon
(item)¶ Override This method must return the icon texture for this item, or nil if no icon is needed
Parameters: item – The tree item to query Returns: The icon name, or None for no icon Return type: str or None
-
getitemtext
(item)¶ Override This method must return the text for this item
Parameters: item – The tree item to query Returns: The item displayed name Return type: str
-
getselection
()¶ Return the selected item
Returns: The selected item Return type: ??
-
selectionchanged
(selection)¶ Override This method is called when the tree list selection has changed
Parameters: selection (table) – The new selection
-
setselection
(item)¶ Set the current selection
Parameters: item – The new selected item
-
setttree
(tree)¶ Update the tree list with the new given tree
Parameters: tree (table) – The tree to be displayed
-