1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
# (C) Copyright 2005-2023 Enthought, Inc., Austin, TX
# All rights reserved.
#
# This software is provided without warranty under the terms of the BSD
# license included in LICENSE.txt and may be redistributed only under
# the conditions described in the aforementioned license. The license
# is also available online at http://www.enthought.com/licenses/BSD.txt
#
# Thanks for using Enthought open source!
""" Base class for all tree label providers. """
from .label_provider import LabelProvider
class TreeLabelProvider(LabelProvider):
""" Base class for all tree label providers.
By default an element has no label image, and 'str' is used to generate its
label text.
"""
# ------------------------------------------------------------------------
# 'LabelProvider' interface.
# ------------------------------------------------------------------------
def set_text(self, viewer, element, text):
""" Sets the text representation of a node.
Returns True if setting the text succeeded, otherwise False.
"""
return len(text.strip()) > 0
# ------------------------------------------------------------------------
# 'TreeLabelProvider' interface.
# ------------------------------------------------------------------------
def get_drag_value(self, viewer, element):
""" Get the value that is dragged for an element.
By default the drag value is the element itself.
"""
return element
def is_collapsible(self, viewer, element):
""" Returns True is the element is collapsible, otherwise False. """
return True
def is_expandable(self, viewer, node):
""" Returns True is the node is expandanble, otherwise False. """
return True
|