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


Python CanvasWidget.__setitem__方法代码示例

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


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

示例1: __setitem__

# 需要导入模块: from nltk.draw.util import CanvasWidget [as 别名]
# 或者: from nltk.draw.util.CanvasWidget import __setitem__ [as 别名]
 def __setitem__(self, attr, value):
     canvas = self.canvas()
     if attr == 'roof':
         self._roof = value
         if self._roof:
             for l in self._lines: canvas.itemconfig(l, state='hidden')
             canvas.itemconfig(self._polygon, state='normal')
         else:
             for l in self._lines: canvas.itemconfig(l, state='normal')
             canvas.itemconfig(self._polygon, state='hidden')
     elif attr == 'orientation':
         if value == 'horizontal': self._horizontal = 1
         elif value == 'vertical': self._horizontal = 0
         else:
             raise ValueError('orientation must be horizontal or vertical')
     elif attr == 'color':
         for l in self._lines: canvas.itemconfig(l, fill=value)
         canvas.itemconfig(self._polygon, outline=value)
     elif isinstance(attr, tuple) and attr[0] == 'color':
         # Set the color of an individual line.
         l = self._lines[int(attr[1])]
         canvas.itemconfig(l, fill=value)
     elif attr == 'fill':
         canvas.itemconfig(self._polygon, fill=value)
     elif attr == 'width':
         canvas.itemconfig(self._polygon, {attr:value})
         for l in self._lines: canvas.itemconfig(l, {attr:value})
     elif attr in ('xspace', 'yspace'):
         if attr == 'xspace': self._xspace = value
         elif attr == 'yspace': self._yspace = value
         self.update(self._label)
     elif attr == 'ordered':
         self._ordered = value
     else:
         CanvasWidget.__setitem__(self, attr, value)
开发者ID:DrDub,项目名称:nltk,代码行数:37,代码来源:tree.py

示例2: __setitem__

# 需要导入模块: from nltk.draw.util import CanvasWidget [as 别名]
# 或者: from nltk.draw.util.CanvasWidget import __setitem__ [as 别名]
 def __setitem__(self, attr, value):
     canvas = self.canvas()
     if attr is "roof":
         self._roof = value
         if self._roof:
             for l in self._lines:
                 canvas.itemconfig(l, state="hidden")
             canvas.itemconfig(self._polygon, state="normal")
         else:
             for l in self._lines:
                 canvas.itemconfig(l, state="normal")
             canvas.itemconfig(self._polygon, state="hidden")
     elif attr == "orientation":
         if value == "horizontal":
             self._horizontal = 1
         elif value == "vertical":
             self._horizontal = 0
         else:
             raise ValueError("orientation must be horizontal or vertical")
     elif attr == "color":
         for l in self._lines:
             canvas.itemconfig(l, fill=value)
         canvas.itemconfig(self._polygon, outline=value)
     elif isinstance(attr, tuple) and attr[0] == "color":
         # Set the color of an individual line.
         l = self._lines[int(attr[1])]
         canvas.itemconfig(l, fill=value)
     elif attr == "fill":
         canvas.itemconfig(self._polygon, fill=value)
     elif attr == "width":
         canvas.itemconfig(self._polygon, {attr: value})
         for l in self._lines:
             canvas.itemconfig(l, {attr: value})
     elif attr in ("xspace", "yspace"):
         if attr == "xspace":
             self._xspace = value
         elif attr == "yspace":
             self._yspace = value
         self.update(self._node)
     elif attr == "ordered":
         self._ordered = value
     else:
         CanvasWidget.__setitem__(self, attr, value)
开发者ID:gijs,项目名称:nltk,代码行数:45,代码来源:tree.py


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