Class Tree
About :
OGL Tree is a graphic node visualizing a tree of items with icons. it is a classical widget with a max number of item displayed, but to left arrow button let slide along the tree.
The tree is defined as a nested list of items
The tree is defined as a nested list of items, ie An item is a list.
- Item[0] is the item name
- Item[1] is the key of the texture
- Item[2] is the list of children
- Item[3] if item[3] exists it refers a list of properties by a dictionary
[ [property_name,property_icon_key_on,property_icon_key_off,property_type,property_value], ]
- type : str , float, int, bool, act
Functions
Function | summury |
---|---|
__init__(self, obj=None, root=[], nb_max=8, multiple=False, almost_one=False, line_width=1.3, textures={}) | OGL Tree Node (more…) |
__add_item_button__(self, i) | add an item widget (more…) |
set_nb_max(self, nb_max=100) | set the max number of visible items in a page (more…) |
add_texture(self, key, texture, trim, layout=False) | add an image for item icons (more…) |
remove_texture(self, key) | remove an icon (more…) |
has_button(self, button) | check if button belongs to the tree widget (more…) |
__select_all__(self, path=[], item=None) | |
select_all(self, path=[], layout=True) | |
select(self, path=[], layout=True) | select an item from a path (more…) |
unselect(self, path=[], recursive=False, layout=True) | ubselect an item from a path (more…) |
unselect_all(self, layout=False) | |
get_selected(self) | scan the tree to provide all the selected paths (more…) |
is_selected(self, path) | check if path is selected (more…) |
__expand_all__(self, path=[], item=None) | |
expand_all(self, path=[], layout=True) | |
expand(self, path=[], layout=True) | expand an item from a path (more…) |
expand_to_path(self, path, layout=True) | |
collapse(self, path=[], layout=True) | ubexpand an item from a path (more…) |
__collapse_all__(self, path=[], item=None) | |
collapse_all(self, path=[], layout=True) | |
get_expanded(self) | scan the tree to provide all the expanded paths (more…) |
is_expanded(self, path) | check if path is expanded (more…) |
set_start(self, start=[0]) | set current top position item (more…) |
get_start(self) | get current top position item (more…) |
__set_layout__(self, item, father, i=0, indent=0, path=[], start=False, itemcount=0) | Recursive set_layout function (more…) |
set_layout(self) | refresh the tree state (more…) |
set_multiple(self, multiple=True, almost_one=False) | set the tree for multiple or single selection (more…) |
on_shot(self, device=None, picked={}) | callback to apply when any subitem or button is activated (more…) |
on_unshot_(self, device=None, picked={}) | callback to apply when any subitem or button activation is released (more…) |
set_root(self, root) | set root tree (more…) |
set_root_from_string(self, tree) | set root tree from string (more…) |
get_root(self) | get the list of root items (more…) |
Methods desciption :
init
def __init__(self, obj=None, root=[], nb_max=8, multiple=False, almost_one=False, line_width=1.3, textures={})
OGL Tree Node A graphical node to handle a tree of information
- → obj: reference node obj in ogl
- → root: a nested list of items root: A nested list items. An item is a list.
- Item[0] is the item name
- Item[1] is the key of the texture
- Item[2] is the list of children TODO
- Item[3] if item[3] exists it refers a list of properties by a dictionary
- [ [property_name,property_icon_key_on,property_icon_key_off,property_type,property_value], ]
- type : str , float, int, bool, act
- → nb_max:int=8 max number of visible nodes
- → multiple:bool=True True for multiple selection, False for single selection only
- → line_width:float=1.3
add_item_button
def __add_item_button__(self, i)
add an item widget
- → i: index of the added widget
- ←
set_nb_max
def set_nb_max(self, nb_max=100)
set the max number of visible items in a page
create new buttons if needed does not remove extra button when nb_max is decreased
- → nb_max: max number
- ←
add_texture
def add_texture(self, key, texture, trim, layout=False)
add an image for item icons
- → key: whatever key string you expect to refer an image
- → texture: the corresponding texture
- → trim: the trim parameters (u,v,U,V)
remove_texture
def remove_texture(self, key)
remove an icon
- → key: icon key
has_button
def has_button(self, button)
check if button belongs to the tree widget
- → button: a button
- ← a 3 tuple
select_all
def __select_all__(self, path=[], item=None)
select_all
def select_all(self, path=[], layout=True)
select
def select(self, path=[], layout=True)
select an item from a path
- → path: path to be selected
- → layout: refresh the layout or not
unselect
def unselect(self, path=[], recursive=False, layout=True)
ubselect an item from a path
- → path: path to be selected
- → layout: refresh the layout or not
unselect_all
def unselect_all(self, layout=False)
get_selected
def get_selected(self)
scan the tree to provide all the selected paths
- → self:
- ← a list of selected paths
is_selected
def is_selected(self, path)
check if path is selected
- → self:
- → path: a list defining a path
- ← bool
expand_all
def __expand_all__(self, path=[], item=None)
expand_all
def expand_all(self, path=[], layout=True)
expand
def expand(self, path=[], layout=True)
expand an item from a path
- → path: path to be expanded
- → layout: refresh the layout or not
expand_to_path
def expand_to_path(self, path, layout=True)
collapse
def collapse(self, path=[], layout=True)
ubexpand an item from a path
- → path: path to be expanded
- → layout: refresh the layout or not
collapse_all
def __collapse_all__(self, path=[], item=None)
collapse_all
def collapse_all(self, path=[], layout=True)
get_expanded
def get_expanded(self)
scan the tree to provide all the expanded paths
- → self:
- ← a list of expanded paths
is_expanded
def is_expanded(self, path)
check if path is expanded
- → self:
- → path: a list defining a path
- ← bool
set_start
def set_start(self, start=[0])
set current top position item
- → self:
- → start: a path to the top position item
- ←
get_start
def get_start(self)
get current top position item
- ←
set_layout
def __set_layout__(self, item, father, i=0, indent=0, path=[], start=False, itemcount=0)
Recursive set_layout function
- → self: tree
- → item: item to set
- → father: item father
- → i: current visible item count
- → indent: level of indentation
- → path: current path
- → start: visible items are started
- → itemcount: current item count from root
- ← i,start,itemcount : new values of this parameters
set_layout
def set_layout(self)
refresh the tree state
- → self:
- ←
set_multiple
def set_multiple(self, multiple=True, almost_one=False)
set the tree for multiple or single selection
- → self:
- → multiple: bool: True to get a multiple selection mode
- ←
on_shot
def on_shot(self, device=None, picked={})
callback to apply when any subitem or button is activated
- → self:
- → device: the activation device
- → picked: activation/picking data
- ← a dictionary of events to propagate
on_unshot_
def on_unshot_(self, device=None, picked={})
callback to apply when any subitem or button activation is released
- → self:
- → device: the activation device
- → picked: activation/picking data
- ← a dictionary of events to propagate
set_root
def set_root(self, root)
set root tree
- → self:
- → root: a nested tree of items
- ←
set_root_from_string
def set_root_from_string(self, tree)
set root tree from string
- → self:
- → root: a nested tree of items in a string format
- ←
get_root
def get_root(self)
get the list of root items
- → self:
- ← the list of root items