class TreeSegmentWidget(CanvasWidget): (source)
Constructor: TreeSegmentWidget(canvas, label, subtrees, **attribs)
A canvas widget that displays a single segment of a hierarchical tree. Each TreeSegmentWidget connects a single "node widget" to a sequence of zero or more "subtree widgets". By default, the bottom of the node is connected to the top of each subtree by a single line. However, if the roof attribute is set, then a single triangular "roof" will connect the node to all of its children.
- Attributes:
- roof: What sort of connection to draw between the node and its subtrees. If roof is true, draw a single triangular "roof" over the subtrees. If roof is false, draw a line between each subtree and the node. Default value is false.
- 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.
- color: The color of the lines connecting the node to its subtrees; and of the outline of the triangular roof. Default value is '#006060'.
- fill: The fill color for the triangular roof. Default value is '' (no fill).
- width: The width of the lines connecting the node to its subtrees; and of the outline of the triangular roof. Default value is 1.
- orientation: Determines whether the tree branches downwards or rightwards. Possible values are 'horizontal' and 'vertical'. The default value is 'vertical' (i.e., branch downwards).
- draggable: whether the widget can be dragged by the user.
Method | __getitem__ |
No summary |
Method | __init__ |
No summary |
Method | __repr__ |
No summary |
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 | insert |
Undocumented |
Method | label |
Undocumented |
Method | remove |
Undocumented |
Method | replace |
Replace the child oldchild with newchild. |
Method | set |
Set the node label to label. |
Method | subtrees |
Undocumented |
Method | _maintain |
Undocumented |
Method | _maintain |
Undocumented |
Method | _maintain |
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 | _manage |
Undocumented |
Method | _manage |
Undocumented |
Method | _node |
Undocumented |
Method | _subtree |
Undocumented |
Method | _tags |
No summary |
Method | _update |
Update this canvas widget in response to a change in one of its children. |
Instance Variable | _horizontal |
Undocumented |
Instance Variable | _label |
Undocumented |
Instance Variable | _lines |
Undocumented |
Instance Variable | _managing |
Undocumented |
Instance Variable | _ordered |
Undocumented |
Instance Variable | _polygon |
Undocumented |
Instance Variable | _roof |
Undocumented |
Instance Variable | _subtrees |
Undocumented |
Instance Variable | _xspace |
Undocumented |
Instance Variable | _yspace |
Undocumented |
Inherited from CanvasWidget
:
Method | bbox |
No summary |
Method | bind |
Register a new callback that will be called whenever this CanvasWidget is clicked on. |
Method | bind |
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 |
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 |
Remove a callback that was registered with bind_click. |
Method | unbind |
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 |
move this object to the new location |
Method | __press |
record the button press event in self.__press |
Method | __release |
unregister motion & button release callbacks. |
Method | __start |
register a motion callback |
Method | _add |
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 |
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: |
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 |
Where it's been moved to (to find dx) |
Instance Variable | __drag |
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. |
nltk.draw.util.CanvasWidget.__getitem__
Returns | |
(any) | the value of the attribute attr. See the class documentation for a list of attributes supported by this canvas widget. |
nltk.draw.util.CanvasWidget.__init__
Parameters | |
canvas | Undocumented |
label | Undocumented |
subtrees:list(CanvasWidgetI) | Undocumented |
node: | Undocumented |
**attribs | Undocumented |
nltk.draw.util.CanvasWidget.__repr__
Returns | |
str | a string representation of this canvas widget. |
nltk.draw.util.CanvasWidget.__setitem__
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 | Undocumented |
nltk.draw.util.CanvasWidget._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.
Returns | |
None | Undocumented |
nltk.draw.util.CanvasWidget._tags
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. |
nltk.draw.util.CanvasWidget._update
Update this canvas widget in response to a change in one of its children.
Parameters | |
child:CanvasWidget | The child that changed. |
Returns | |
None | Undocumented |