Package teamwork :: Package widgets :: Module Tree :: Class Node
[hide private]
[frames] | no frames]

Class Node

source code

Tree helper class that's instantiated for each element in the tree. It has several useful attributes: parent_node - immediate parent node id - id assigned at creation expanded_icon - image displayed when folder is expanded to display children collapsed_icon - image displayed when node is not a folder or folder is collapsed. parent_widget - reference to tree widget that contains node. expandable_flag - is true when node is a folder that may be expanded or collapsed. expanded_flag - true to indicate node is currently expanded. h_line - canvas line to left of node image. v_line - canvas line below node image that connects children. indic - expand/collapse canvas image. label - canvas text label symbol - current canvas image

Please note that methods prefixed PVT_* are not meant to be used by client programs.

Instance Methods [hide private]
 
__init__(self, parent_node, id, collapsed_icon, x, y, parent_widget=None, expanded_icon=None, label=None, expandable_flag=0)
Create node and initialize it.
source code
 
set_collapsed_icon(self, icon)
Set node's collapsed image
source code
 
set_expanded_icon(self, icon)
Set node's expanded image
source code
 
parent(self)
Return node's parent node
source code
 
prev_sib(self)
Return node's previous sibling (the child immediately above it)
source code
 
next_sib(self)
Return node's next sibling (the child immediately below it)
source code
 
next_visible(self)
Return next lower visible node
source code
 
prev_visible(self)
Return next higher visible node
source code
 
children(self)
Return list of node's children
source code
 
get_label(self)
Return string containing text of current label
source code
 
set_label(self, label)
Set current text label
source code
 
expanded(self)
Returns true if node is currently expanded, false otherwise
source code
 
expandable(self)
Returns true if node can be expanded (i.e.
source code
 
full_id(self)
Return list of IDs of all parents and node ID
source code
 
expand(self)
Expand node if possible
source code
 
collapse(self)
Collapse node if possible
source code
 
delete(self, me_too=1)
Delete node from tree.
source code
 
insert_before(self, nodes)
Insert list of nodes as siblings before this node.
source code
 
insert_after(self, nodes)
Insert list of nodes as siblings after this node.
source code
 
insert_children(self, nodes)
Insert list of nodes as children of this node.
source code
 
toggle_state(self)
Toggle node's state between expanded and collapsed, if possible
source code
 
PVT_enter(self, event)
detect mouse hover for drag'n'drop
source code
 
dnd_end(self, target, event)
Notification that dnd processing has been ended.
source code
 
PVT_last(self)
Return bottom-most node in subtree
source code
 
PVT_find(self, search)
Used by searching functions
source code
 
PVT_insert(self, nodes, pos, below)
Create and insert new children.
source code
 
PVT_set_state(self, state)
Common code forexpanding/collapsing folders.
source code
 
PVT_cleanup_lines(self)
Resize connecting lines
source code
 
PVT_update_scrollregion(self)
Update scroll region for new size
source code
 
PVT_delete_subtree(self)
Recursively delete subtree & clean up cyclic references to make garbage collection happy
source code
 
PVT_unbind_all(self)
Unbind callbacks so node gets garbage-collected.
source code
 
PVT_tag_move(self, dist)
Move everything below current icon, to make room for subtree using the Disney magic of item tags.
source code
 
PVT_click(self, event)
Handle mouse clicks by kicking off possible drag'n'drop processing
source code
Method Details [hide private]

__init__(self, parent_node, id, collapsed_icon, x, y, parent_widget=None, expanded_icon=None, label=None, expandable_flag=0)
(Constructor)

source code 

Create node and initialize it. This also displays the node at the given position on the canvas, and binds mouseclicks.

expandable(self)

source code 

Returns true if node can be expanded (i.e. if it's a folder)

delete(self, me_too=1)

source code 

Delete node from tree. ("me_too" is a hack not to be used by external code, please!)

insert_before(self, nodes)

source code 

Insert list of nodes as siblings before this node. Call parent node's add_node() function to generate the list of nodes.

insert_after(self, nodes)

source code 

Insert list of nodes as siblings after this node. Call parent node's add_node() function to generate the list of nodes.

insert_children(self, nodes)

source code 

Insert list of nodes as children of this node. Call node's add_node() function to generate the list of nodes.

dnd_end(self, target, event)

source code 

Notification that dnd processing has been ended. It DOES NOT imply that we've been dropped somewhere useful, we could have just been dropped into deep space and nothing happened to any data structures, or it could have been just a plain mouse-click w/o any dragging.

PVT_insert(self, nodes, pos, below)

source code 

Create and insert new children. "nodes" is list previously created via calls to add_list(). "pos" is index in the list of children where the new nodes are inserted. "below" is node which new children should appear immediately below.

PVT_set_state(self, state)

source code 

Common code forexpanding/collapsing folders. It's not re-entrant, and there are certain cases in which we can be called again before we're done, so we use a mutex.

PVT_unbind_all(self)

source code 

Unbind callbacks so node gets garbage-collected. This wasn't easy to figure out the proper way to do this. See also tag_bind() for the Tree widget itself.

PVT_tag_move(self, dist)

source code 

Move everything below current icon, to make room for subtree using the Disney magic of item tags. This is the secret of making everything as fast as it is.