Tree data structure to be used with TreeNavigator widget.
Methods
|
|
__cmp__
__init__
__str__
add_children
children
create_icon
getpath
has_children
resize_icon
|
|
__cmp__
|
__cmp__ ( self, other )
Comparison method for sorting.
Compare names.
|
|
__init__
|
__init__ (
self,
name,
data=None,
parent=None,
children=[],
icon_type=AnimatedFolder.AnimatedFolder,
no_child_icon_type=AnimatedFileIcon.AnimatedFileIcon,
)
Create a NavigableTree, possibly with known children.
Arguments
- name
Name of the root node of the tree.
- data
Data associated with the root node of the tree.
- parent
Parent node, if any.
- children=[]
Child nodes, if any.
- icon_type=AnimatedFolder.AnimatedFolder
Class to
instantiate when an icon is needed to represent this node.
Should support AnimatedIcon interfaces.
- no_child_icon_type=AnimatedFileIcon.AnimatedFileIcon
Class to instantiate when an icon is needed to represent
this node and the node has no children. Should support
AnimatedIcon interfaces.
Attributes
- data
Any piece of data which should be attached to the
node. This is maintained by the data structure, but not used
directly. It is present to make the tree data structure
useful.
- icon_type
A subclass of the PmwContribD.AnimatedIcon
class, this attribute is used to create icons when the tree
is being displayed in a TreeNavigator.
- name
The name of the node. It is usually useful to have a
string displayed in the TreeNavigator to represent the
node. The default __str__ method uses the name attribute.
|
|
__str__
|
__str__ ( self )
Return a string representation of ourself. (our name)
|
|
add_children
|
add_children ( self, new_children=[] )
Add children to the existing children of the node.
Arguments
- new_children=[]
Sequence of child nodes.
|
|
children
|
children ( self )
Returns the children for this node.
|
|
create_icon
|
create_icon (
self,
canvas,
command=None,
state=None,
)
Create the icon for this node.
Given a canvas, and possibly a command to call on ButtonPress,
create an icon for this node. Our icon should be the only
icon on the canvas (although it does not have to be the only
drawing).
Arguments
- canvas
Widget on which to draw.
- command
Callable object to be called on ButtonPress on
the icon.
- state=None
State the icon should be in to start.
|
|
getpath
|
getpath ( self )
Find this node's place in the tree.
Returns the path from the root of the tree containing
this node all the way down to this node.
|
|
has_children
|
has_children ( self )
Returns boolean indicating whether this node has children.
|
|
resize_icon
|
resize_icon ( self, event )
Change the size of the icon based on an event.
Usually resizes the icon for this node when the canvas to
which it is attached is redrawn.
|