pyface.tree.tree_model module

Model for tree views.

class pyface.tree.tree_model.TreeModel[source]

Bases: HasTraits

Model for tree views.

has_children(node)[source]

Returns True if a node has children, otherwise False.

This method is provided in case the model has an efficient way to determine whether or not a node has any children without having to actually get the children themselves.

get_children(node)[source]

Returns the children of a node.

get_drag_value(node)[source]

Get the value that is dragged for a node.

By default the drag value is the node itself.

can_drop(node, obj)[source]

Returns True if a node allows an object to be dropped onto it.

drop(node, obj)[source]

Drops an object onto a node.

get_image(node, selected, expanded)[source]

Returns the label image for a node.

Return None (the default) if no image is required.

get_key(node)[source]

Generate a unique key for a node.

get_selection_value(node)[source]

Get the value that is used when a node is selected.

By default the selection value is the node itself.

get_text(node)[source]

Returns the label text for a node.

Return None if no text is required. By default we return ‘str(node)’.

can_set_text(node, text)[source]

Returns True if the node’s label can be set.

set_text(node, text)[source]

Sets the label text for a node.

is_collapsible(node)[source]

Returns True if the node is collapsible, otherwise False.

is_draggable(node)[source]

Returns True if the node is draggable, otherwise False.

is_editable(node)[source]

Returns True if the node is editable, otherwise False.

If the node is editable, its text can be set via the UI.

is_expandable(node)[source]

Returns True if the node is expandanble, otherwise False.

add_listener(node)[source]

Adds a listener for changes to a node.

remove_listener(node)[source]

Removes a listener for changes to a node.

fire_nodes_changed(node, children)[source]

Fires the nodes changed event.

fire_nodes_inserted(node, children)[source]

Fires the nodes inserted event.

fire_nodes_removed(node, children)[source]

Fires the nodes removed event.

fire_nodes_replaced(node, old_children, new_children)[source]

Fires the nodes removed event.

fire_structure_changed(node)[source]

Fires the structure changed event.