当前位置: 首页>>代码示例>>Python>>正文


Python CanvasWidget.__init__方法代码示例

本文整理汇总了Python中nltk.draw.util.CanvasWidget.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python CanvasWidget.__init__方法的具体用法?Python CanvasWidget.__init__怎么用?Python CanvasWidget.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nltk.draw.util.CanvasWidget的用法示例。


在下文中一共展示了CanvasWidget.__init__方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from nltk.draw.util import CanvasWidget [as 别名]
# 或者: from nltk.draw.util.CanvasWidget import __init__ [as 别名]
    def __init__(
        self, canvas, t, make_node=TextWidget, make_leaf=TextWidget, **attribs
    ):
        # Node & leaf canvas widget constructors
        self._make_node = make_node
        self._make_leaf = make_leaf
        self._tree = t

        # Attributes.
        self._nodeattribs = {}
        self._leafattribs = {}
        self._locattribs = {'color': '#008000'}
        self._line_color = '#008080'
        self._line_width = 1
        self._roof_color = '#008080'
        self._roof_fill = '#c0c0c0'
        self._shapeable = False
        self._xspace = 10
        self._yspace = 10
        self._orientation = 'vertical'
        self._ordered = False

        # Build trees.
        self._keys = {}  # treeseg -> key
        self._expanded_trees = {}
        self._collapsed_trees = {}
        self._nodes = []
        self._leaves = []
        # self._locs = []
        self._make_collapsed_trees(canvas, t, ())
        self._treeseg = self._make_expanded_tree(canvas, t, ())
        self._add_child_widget(self._treeseg)

        CanvasWidget.__init__(self, canvas, **attribs)
开发者ID:prz3m,项目名称:kind2anki,代码行数:36,代码来源:tree.py

示例2: __init__

# 需要导入模块: from nltk.draw.util import CanvasWidget [as 别名]
# 或者: from nltk.draw.util.CanvasWidget import __init__ [as 别名]
    def __init__(self, canvas, node, subtrees, **attribs):
        """
        :type node: 
        :type subtrees: list of C{CanvasWidgetI}
        """
        self._node = node
        self._subtrees = subtrees

        # Attributes
        self._horizontal = 0
        self._roof = 0
        self._xspace = 10
        self._yspace = 15
        self._ordered = False

        # Create canvas objects.
        self._lines = [canvas.create_line(0, 0, 0, 0, fill="#006060") for c in subtrees]
        self._polygon = canvas.create_polygon(0, 0, fill="", state="hidden", outline="#006060")

        # Register child widgets (node + subtrees)
        self._add_child_widget(node)
        for subtree in subtrees:
            self._add_child_widget(subtree)

        # Are we currently managing?
        self._managing = False

        CanvasWidget.__init__(self, canvas, **attribs)
开发者ID:gijs,项目名称:nltk,代码行数:30,代码来源:tree.py


注:本文中的nltk.draw.util.CanvasWidget.__init__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。