MCPcopy
hub / github.com/nltk/nltk / __init__

Method __init__

nltk/draw/tree.py:854–895  ·  view source on GitHub ↗
(self, *trees)

Source from the content-addressed store, hash-verified

852
853class TreeView:
854 def __init__(self, *trees):
855 from math import ceil, sqrt
856
857 self._trees = trees
858
859 self._top = Tk()
860 self._top.title("NLTK")
861 self._top.bind("<Control-x>", self.destroy)
862 self._top.bind("<Control-q>", self.destroy)
863
864 cf = self._cframe = CanvasFrame(self._top)
865 self._top.bind("<Control-p>", self._cframe.print_to_file)
866
867 # Size is variable.
868 self._size = IntVar(self._top)
869 self._size.set(12)
870 bold = ("helvetica", -self._size.get(), "bold")
871 helv = ("helvetica", -self._size.get())
872
873 # Lay the trees out in a square.
874 self._width = int(ceil(sqrt(len(trees))))
875 self._widgets = []
876 for i in range(len(trees)):
877 widget = TreeWidget(
878 cf.canvas(),
879 trees[i],
880 node_font=bold,
881 leaf_color="#008040",
882 node_color="#004080",
883 roof_color="#004040",
884 roof_fill="white",
885 line_color="#004040",
886 draggable=1,
887 leaf_font=helv,
888 )
889 widget.bind_click_trees(widget.toggle_collapsed)
890 self._widgets.append(widget)
891 cf.add_widget(widget, 0, 0)
892
893 self._layout()
894 self._cframe.pack(expand=1, fill="both")
895 self._init_menubar()
896
897 def _layout(self):
898 i = x = y = ymax = 0

Callers 2

__init__Method · 0.45
__init__Method · 0.45

Calls 12

bind_click_treesMethod · 0.95
_layoutMethod · 0.95
_init_menubarMethod · 0.95
CanvasFrameClass · 0.90
TreeWidgetClass · 0.85
bindMethod · 0.80
add_widgetMethod · 0.80
setMethod · 0.45
getMethod · 0.45
canvasMethod · 0.45
appendMethod · 0.45
packMethod · 0.45

Tested by

no test coverage detected