pyface.viewer.viewer_sorter module

Abstract base class for all viewer sorters.

class pyface.viewer.viewer_sorter.ViewerSorter[source]

Bases: traits.has_traits.HasTraits

Abstract base class for all viewer sorters.

sort(viewer, parent, elements)[source]

Sorts a list of elements IN PLACE.

‘viewer’ is the viewer that we are sorting elements for. ‘parent’ is the parent element. ‘elements’ is the list of elements to sort.

Returns the list that was sorted IN PLACE (for convenience).

key(viewer, parent, element)[source]

Returns the result of comparing two elements.

‘viewer’ is the viewer that we are sorting elements for. ‘parent’ is the parent element. ‘element’ is the the first element being sorted.

category(viewer, parent, element)[source]

Returns the category (an integer) for an element.

‘parent’ is the parent element. ‘elements’ is the element to return the category for.

Categories are used to sort elements into bins. The bins are arranged in ascending numeric order. The elements within a bin are arranged as dictated by the sorter’s ‘compare’ method.

By default all elements are given the same category (0).

is_sorter_trait(element, trait_name)[source]

Is the sorter affected by changes to an element’s trait?

‘element’ is the element. ‘trait_name’ is the name of the trait.

Returns True if the sorter would be affected by changes to the trait named ‘trait_name’ on the specified element.

By default we return False.