Package nltk :: Package draw :: Module tree :: Class TreeWidget
[hide private]
[frames] | no frames]

Class TreeWidget

source code

  object --+    
           |    
CanvasWidget --+
               |
              TreeWidget

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

Attributes:

Instance Methods [hide private]
 
__init__(self, canvas, t, make_node=<class 'nltk.draw.TextWidget'>, make_leaf=<class 'nltk.draw.TextWidget'>, **attribs)
Create a new canvas widget.
source code
 
expanded_tree(self, *path_to_tree)
Return the TreeSegmentWidget for the specified subtree.
source code
 
collapsed_tree(self, *path_to_tree)
Return the TreeSegmentWidget for the specified subtree.
source code
 
bind_click_trees(self, callback, button=1)
Add a binding to all tree segments.
source code
 
bind_drag_trees(self, callback, button=1)
Add a binding to all tree segments.
source code
 
bind_click_leaves(self, callback, button=1)
Add a binding to all leaves.
source code
 
bind_drag_leaves(self, callback, button=1)
Add a binding to all leaves.
source code
 
bind_click_nodes(self, callback, button=1)
Add a binding to all nodes.
source code
 
bind_drag_nodes(self, callback, button=1)
Add a binding to all nodes.
source code
 
_make_collapsed_trees(self, canvas, t, key) source code
 
_make_expanded_tree(self, canvas, t, key) source code
None
__setitem__(self, attr, value)
Set the value of the attribute attr to value.
source code
(any)
__getitem__(self, attr)
Returns: the value of the attribute attr.
source code
list of int
_tags(self)
Returns: a list of canvas tags for all graphical elements managed by this canvas widget, not including graphical elements managed by its child widgets.
source code
None
_manage(self)
Arrange the child widgets of this canvas widget.
source code
 
toggle_collapsed(self, treeseg)
Collapse/expand a tree.
source code

Inherited from CanvasWidget: __repr__, bbox, bind_click, bind_drag, canvas, child_widgets, destroy, height, hidden, hide, manage, move, moveto, parent, show, tags, unbind_click, unbind_drag, update, width

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, canvas, t, make_node=<class 'nltk.draw.TextWidget'>, make_leaf=<class 'nltk.draw.TextWidget'>, **attribs)
(Constructor)

source code 

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 - This canvas widget's canvas.
  • parent - This canvas widget's hierarchical parent.
  • attribs - The new canvas widget's attributes.
Overrides: CanvasWidget.__init__
(inherited documentation)

expanded_tree(self, *path_to_tree)

source code 

Return the TreeSegmentWidget for the specified subtree.

Parameters:
  • path_to_tree - A 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 ().

collapsed_tree(self, *path_to_tree)

source code 

Return the TreeSegmentWidget for the specified subtree.

Parameters:
  • path_to_tree - A 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 ().

__setitem__(self, attr, value)
(Index assignment operator)

source code 

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

Returns: None
Overrides: CanvasWidget.__setitem__
(inherited documentation)

__getitem__(self, attr)
(Indexing operator)

source code 
Returns: (any)
the value of the attribute attr. See the class documentation for a list of attributes supported by this canvas widget.
Overrides: CanvasWidget.__getitem__
(inherited documentation)

_tags(self)

source code 
Returns: list of int
a list of canvas tags for all graphical elements managed by this canvas widget, not including graphical elements managed by its child widgets.
Overrides: CanvasWidget._tags
(inherited documentation)

_manage(self)

source code 

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: None
Overrides: CanvasWidget._manage
(inherited documentation)