class documentation

A canvas widget that displays a single Tree. TreeWidget manages a group of TreeSegmentWidgets that are used to display a Tree.

Attributes:

  • node_attr: Sets the attribute attr on all of the node widgets for this TreeWidget.
  • node_attr: Sets the attribute attr on all of the leaf widgets for this TreeWidget.
  • loc_attr: Sets the attribute attr on all of the location widgets for this TreeWidget (if it was built from a Tree). Note that a location widget is a TextWidget.
  • xspace: The amount of horizontal space to leave between subtrees when managing this widget. Default value is 10.
  • yspace: The amount of space to place between the node and its children when managing this widget. Default value is 15.
  • line_color: The color of the lines connecting each expanded node to its subtrees.
  • roof_color: The color of the outline of the triangular roof for collapsed trees.
  • roof_fill: The fill color for the triangular roof for collapsed trees.
  • width
  • orientation: Determines whether the tree branches downwards or rightwards. Possible values are 'horizontal' and 'vertical'. The default value is 'vertical' (i.e., branch downwards).
  • shapeable: whether the subtrees can be independently dragged by the user. THIS property simply sets the DRAGGABLE property on all of the TreeWidget's tree segments.
  • draggable: whether the widget can be dragged by the user.
Method __getitem__ No summary
Method __init__ Create a new canvas widget. This constructor should only be called by subclass constructors; and it should be called only "after" the subclass has constructed all graphical canvas objects and registered all child widgets.
Method __setitem__ Set the value of the attribute attr to value. See the class documentation for a list of attributes supported by this canvas widget.
Method bind_click_leaves Add a binding to all leaves.
Method bind_click_nodes Add a binding to all nodes.
Method bind_click_trees Add a binding to all tree segments.
Method bind_drag_leaves Add a binding to all leaves.
Method bind_drag_nodes Add a binding to all nodes.
Method bind_drag_trees Add a binding to all tree segments.
Method collapsed_tree Return the TreeSegmentWidget for the specified subtree.
Method expanded_tree Return the TreeSegmentWidget for the specified subtree.
Method toggle_collapsed Collapse/expand a tree.
Method _make_collapsed_trees Undocumented
Method _make_expanded_tree Undocumented
Method _manage Arrange the child widgets of this canvas widget. This method is called when the canvas widget is initially created. It is also called if the user calls the manage method on this canvas widget or any of its ancestors.
Method _tags No summary
Instance Variable _collapsed_trees Undocumented
Instance Variable _expanded_trees Undocumented
Instance Variable _keys Undocumented
Instance Variable _leafattribs Undocumented
Instance Variable _leaves Undocumented
Instance Variable _line_color Undocumented
Instance Variable _line_width Undocumented
Instance Variable _locattribs Undocumented
Instance Variable _make_leaf Undocumented
Instance Variable _make_node Undocumented
Instance Variable _nodeattribs Undocumented
Instance Variable _nodes Undocumented
Instance Variable _ordered Undocumented
Instance Variable _orientation Undocumented
Instance Variable _roof_color Undocumented
Instance Variable _roof_fill Undocumented
Instance Variable _shapeable Undocumented
Instance Variable _tree Undocumented
Instance Variable _treeseg Undocumented
Instance Variable _xspace Undocumented
Instance Variable _yspace Undocumented

Inherited from CanvasWidget:

Method __repr__ No summary
Method bbox No summary
Method bind_click Register a new callback that will be called whenever this CanvasWidget is clicked on.
Method bind_drag Register a new callback that will be called after this CanvasWidget is dragged. This implicitly makes this CanvasWidget draggable.
Method canvas No summary
Method child_widgets No summary
Method destroy Remove this CanvasWidget from its Canvas. After a CanvasWidget has been destroyed, it should not be accessed.
Method height No summary
Method hidden No summary
Method hide Temporarily hide this canvas widget.
Method manage Arrange this canvas widget and all of its descendants.
Method move Move this canvas widget by a given distance. In particular, shift the canvas widget right by dx pixels, and down by dy pixels. Both dx and dy may be negative, resulting in leftward or upward movement.
Method moveto Move this canvas widget to the given location. In particular, shift the canvas widget such that the corner or side of the bounding box specified by anchor is at location (x, y).
Method parent No summary
Method show Show a hidden canvas widget.
Method tags No summary
Method unbind_click Remove a callback that was registered with bind_click.
Method unbind_drag Remove a callback that was registered with bind_drag.
Method update Update the graphical display of this canvas widget, and all of its ancestors, in response to a change in one of this canvas widget's children.
Method width No summary
Method __click If this CanvasWidget has a drag callback, then call it; otherwise, find the closest ancestor with a click callback, and call it. If no ancestors have a click callback, do nothing.
Method __drag If this CanvasWidget has a drag callback, then call it; otherwise, find the closest ancestor with a drag callback, and call it. If no ancestors have a drag callback, do nothing.
Method __motion_cb move this object to the new location
Method __press_cb record the button press event in self.__press
Method __release_cb unregister motion & button release callbacks.
Method __start_drag register a motion callback
Method _add_child_widget Register a hierarchical child widget. The child will be considered part of this canvas widget for purposes of user interaction. _add_child_widget has two direct effects:
Method _remove_child_widget Remove a hierarchical child widget. This child will no longer be considered part of this canvas widget for purposes of user interaction. _add_child_widget has two direct effects:
Method _update Update this canvas widget in response to a change in one of its children.
Instance Variable __callbacks Registered callbacks. Currently, four keys are used: 1, 2, 3, and 'drag'. The values are callback functions. Each callback function takes a single argument, which is the CanvasWidget that triggered the callback.
Instance Variable __canvas This CanvasWidget's canvas.
Instance Variable __children This CanvasWidget's hierarchical child widgets.
Instance Variable __drag_x Where it's been moved to (to find dx)
Instance Variable __drag_y Where it's been moved to (to find dy)
Instance Variable __draggable Is this canvas widget draggable?
Instance Variable __hidden Undocumented
Instance Variable __parent This CanvasWidget's hierarchical parent widget.
Instance Variable __press The ButtonPress event that we're currently handling.
Instance Variable __updating Is this canvas widget currently performing an update? If it is, then it will ignore any new update requests from child widgets.
def __getitem__(self, attr): (source)
Returns
(any)the value of the attribute attr. See the class documentation for a list of attributes supported by this canvas widget.
def __init__(self, canvas, t, make_node=TextWidget, make_leaf=TextWidget, **attribs): (source)

Create a new canvas widget. This constructor should only be called by subclass constructors; and it should be called only "after" the subclass has constructed all graphical canvas objects and registered all child widgets.

Parameters
canvas:Tkinter.CanvasThis canvas widget's canvas.
tUndocumented
make_nodeUndocumented
make_leafUndocumented
parent:CanvasWidgetThis canvas widget's hierarchical parent.
**attribsThe new canvas widget's attributes.
def __setitem__(self, attr, value): (source)

Set the value of the attribute attr to value. See the class documentation for a list of attributes supported by this canvas widget.

Returns
NoneUndocumented
def bind_click_leaves(self, callback, button=1): (source)

Add a binding to all leaves.

def bind_click_nodes(self, callback, button=1): (source)

Add a binding to all nodes.

def bind_click_trees(self, callback, button=1): (source)

Add a binding to all tree segments.

def bind_drag_leaves(self, callback, button=1): (source)

Add a binding to all leaves.

def bind_drag_nodes(self, callback, button=1): (source)

Add a binding to all nodes.

def bind_drag_trees(self, callback, button=1): (source)

Add a binding to all tree segments.

def collapsed_tree(self, *path_to_tree): (source)

Return the TreeSegmentWidget for the specified subtree.

Parameters
*path_to_treeA list of indices i1, i2, ..., in, where the desired widget is the widget corresponding to tree.children()[i1].children()[i2]....children()[in]. For the root, the path is ().
def expanded_tree(self, *path_to_tree): (source)

Return the TreeSegmentWidget for the specified subtree.

Parameters
*path_to_treeA list of indices i1, i2, ..., in, where the desired widget is the widget corresponding to tree.children()[i1].children()[i2]....children()[in]. For the root, the path is ().
def toggle_collapsed(self, treeseg): (source)

Collapse/expand a tree.

def _make_collapsed_trees(self, canvas, t, key): (source)

Undocumented

def _make_expanded_tree(self, canvas, t, key): (source)

Undocumented

def _manage(self): (source)

Arrange the child widgets of this canvas widget. This method is called when the canvas widget is initially created. It is also called if the user calls the manage method on this canvas widget or any of its ancestors.

Returns
NoneUndocumented
def _tags(self): (source)
Returns
list of inta list of canvas tags for all graphical elements managed by this canvas widget, not including graphical elements managed by its child widgets.
_collapsed_trees: dict = (source)

Undocumented

_expanded_trees: dict = (source)

Undocumented

_keys: dict = (source)

Undocumented

_leafattribs: dict = (source)

Undocumented

_leaves: list = (source)

Undocumented

_line_color: str = (source)

Undocumented

_line_width: int = (source)

Undocumented

_locattribs: dict[str, str] = (source)

Undocumented

_make_leaf = (source)

Undocumented

_make_node = (source)

Undocumented

_nodeattribs: dict = (source)

Undocumented

_nodes: list = (source)

Undocumented

_ordered: bool = (source)

Undocumented

_orientation: str = (source)

Undocumented

_roof_color: str = (source)

Undocumented

_roof_fill: str = (source)

Undocumented

_shapeable: bool = (source)

Undocumented

Undocumented

_treeseg = (source)

Undocumented

_xspace: int = (source)

Undocumented

_yspace: int = (source)

Undocumented