Beispiel #1
0
 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)
Beispiel #2
0
    def __init__(self, canvas, label, subtrees, **attribs):
        """
        :type node:
        :type subtrees: list(CanvasWidgetI)
        """
        self._label = label
        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 (label + subtrees)
        self._add_child_widget(label)
        for subtree in subtrees:
            self._add_child_widget(subtree)

        # Are we currently managing?
        self._managing = False

        CanvasWidget.__init__(self, canvas, **attribs)
Beispiel #3
0
    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)
Beispiel #4
0
Datei: tree.py Projekt: gijs/nltk
    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)
Beispiel #5
0
 def __setitem__(self, attr, value):
     if attr[:5] == 'node_':
         for node in self._nodes: node[attr[5:]] = value
     elif attr[:5] == 'leaf_':
         for leaf in self._leaves: leaf[attr[5:]] = value
     elif attr == 'line_color':
         self._line_color = value
         for tseg in list(self._expanded_trees.values()): tseg['color'] = value
     elif attr == 'line_width':
         self._line_width = value
         for tseg in list(self._expanded_trees.values()): tseg['width'] = value
         for tseg in list(self._collapsed_trees.values()): tseg['width'] = value
     elif attr == 'roof_color':
         self._roof_color = value
         for tseg in list(self._collapsed_trees.values()): tseg['color'] = value
     elif attr == 'roof_fill':
         self._roof_fill = value
         for tseg in list(self._collapsed_trees.values()): tseg['fill'] = value
     elif attr == 'shapeable':
         self._shapeable = value
         for tseg in list(self._expanded_trees.values()):
             tseg['draggable'] = value
         for tseg in list(self._collapsed_trees.values()):
             tseg['draggable'] = value
         for leaf in self._leaves: leaf['draggable'] = value
     elif attr == 'xspace':
         self._xspace = value
         for tseg in list(self._expanded_trees.values()):
             tseg['xspace'] = value
         for tseg in list(self._collapsed_trees.values()):
             tseg['xspace'] = value
         self.manage()
     elif attr == 'yspace':
         self._yspace = value
         for tseg in list(self._expanded_trees.values()):
             tseg['yspace'] = value
         for tseg in list(self._collapsed_trees.values()):
             tseg['yspace'] = value
         self.manage()
     elif attr == 'orientation':
         self._orientation = value
         for tseg in list(self._expanded_trees.values()):
             tseg['orientation'] = value
         for tseg in list(self._collapsed_trees.values()):
             tseg['orientation'] = value
         self.manage()
     elif attr == 'ordered':
         self._ordered = value
         for tseg in list(self._expanded_trees.values()):
             tseg['ordered'] = value
         for tseg in list(self._collapsed_trees.values()):
             tseg['ordered'] = value
     else: CanvasWidget.__setitem__(self, attr, value)
Beispiel #6
0
Datei: tree.py Projekt: gijs/nltk
 def __getitem__(self, attr):
     if attr[:5] == "node_":
         return self._nodeattribs.get(attr[5:], None)
     elif attr[:5] == "leaf_":
         return self._leafattribs.get(attr[5:], None)
     elif attr[:4] == "loc_":
         return self._locattribs.get(attr[4:], None)
     elif attr == "line_color":
         return self._line_color
     elif attr == "line_width":
         return self._line_width
     elif attr == "roof_color":
         return self._roof_color
     elif attr == "roof_fill":
         return self._roof_fill
     elif attr == "shapeable":
         return self._shapeable
     elif attr == "xspace":
         return self._xspace
     elif attr == "yspace":
         return self._yspace
     elif attr == "orientation":
         return self._orientation
     else:
         return CanvasWidget.__getitem__(self, attr)
Beispiel #7
0
 def __getitem__(self, attr):
     if attr[:5] == 'node_':
         return self._nodeattribs.get(attr[5:], None)
     elif attr[:5] == 'leaf_':
         return self._leafattribs.get(attr[5:], None)
     elif attr[:4] == 'loc_':
         return self._locattribs.get(attr[4:], None)
     elif attr == 'line_color':
         return self._line_color
     elif attr == 'line_width':
         return self._line_width
     elif attr == 'roof_color':
         return self._roof_color
     elif attr == 'roof_fill':
         return self._roof_fill
     elif attr == 'shapeable':
         return self._shapeable
     elif attr == 'xspace':
         return self._xspace
     elif attr == 'yspace':
         return self._yspace
     elif attr == 'orientation':
         return self._orientation
     else:
         return CanvasWidget.__getitem__(self, attr)
Beispiel #8
0
Datei: tree.py Projekt: gijs/nltk
 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)
Beispiel #9
0
    def __init__(self,
                 canvas,
                 t,
                 make_node=TextWidget,
                 make_leaf=TextWidget,
                 activation=0,
                 minmax=(0, 10),
                 **attribs):
        # Node & leaf canvas widget constructors
        self._make_node = make_node
        self._make_leaf = make_leaf
        self._tree = t
        self._activation = activation
        self._minmax = minmax

        # 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)
Beispiel #10
0
 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)
Beispiel #11
0
    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)
Beispiel #12
0
    def __init__(self, canvas, label, subtrees, activation=0, **attribs):
        """
        :type node:
        :type subtrees: list(CanvasWidgetI)
        """
        self._label = label
        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 (label + subtrees)
        self._add_child_widget(label)
        for subtree in subtrees:
            self._add_child_widget(subtree)

        # Are we currently managing?
        self._managing = False

        self._activation = activation

        CanvasWidget.__init__(self, canvas, **attribs)
Beispiel #13
0
 def __getitem__(self, attr):
     if attr[:5] == 'node_':
         return self._nodeattribs.get(attr[5:], None)
     elif attr[:5] == 'leaf_':
         return self._leafattribs.get(attr[5:], None)
     elif attr[:4] == 'loc_':
         return self._locattribs.get(attr[4:], None)
     elif attr == 'line_color': return self._line_color
     elif attr == 'line_width': return self._line_width
     elif attr == 'roof_color': return self._roof_color
     elif attr == 'roof_fill': return self._roof_fill
     elif attr == 'shapeable': return self._shapeable
     elif attr == 'xspace': return self._xspace
     elif attr == 'yspace': return self._yspace
     elif attr == 'orientation': return self._orientation
     else: return CanvasWidget.__getitem__(self, attr)
Beispiel #14
0
 def __getitem__(self, attr):
     if attr == 'roof': return self._roof
     elif attr == 'width':
         return self.canvas().itemcget(self._polygon, attr)
     elif attr == 'color':
         return self.canvas().itemcget(self._polygon, 'outline')
     elif isinstance(attr, tuple) and attr[0] == 'color':
         l = self._lines[int(attr[1])]
         return self.canvas().itemcget(l, 'fill')
     elif attr == 'xspace': return self._xspace
     elif attr == 'yspace': return self._yspace
     elif attr == 'orientation':
         if self._horizontal: return 'horizontal'
         else: return 'vertical'
     elif attr == 'ordered':
         return self._ordered
     else:
         return CanvasWidget.__getitem__(self, attr)
Beispiel #15
0
 def __getitem__(self, attr):
     if attr == 'roof': return self._roof
     elif attr == 'width':
         return self.canvas().itemcget(self._polygon, attr)
     elif attr == 'color':
         return self.canvas().itemcget(self._polygon, 'outline')
     elif isinstance(attr, tuple) and attr[0] == 'color':
         l = self._lines[int(attr[1])]
         return self.canvas().itemcget(l, 'fill')
     elif attr == 'xspace': return self._xspace
     elif attr == 'yspace': return self._yspace
     elif attr == 'orientation':
         if self._horizontal: return 'horizontal'
         else: return 'vertical'
     elif attr == 'ordered':
         return self._ordered
     else:
         return CanvasWidget.__getitem__(self, attr)
Beispiel #16
0
 def __getitem__(self, attr):
     if attr == "roof":
         return self._roof
     elif attr == "width":
         return self.canvas().itemcget(self._polygon, attr)
     elif attr == "color":
         return self.canvas().itemcget(self._polygon, "outline")
     elif isinstance(attr, tuple) and attr[0] == "color":
         l = self._lines[int(attr[1])]
         return self.canvas().itemcget(l, "fill")
     elif attr == "xspace":
         return self._xspace
     elif attr == "yspace":
         return self._yspace
     elif attr == "orientation":
         if self._horizontal:
             return "horizontal"
         else:
             return "vertical"
     elif attr == "ordered":
         return self._ordered
     else:
         return CanvasWidget.__getitem__(self, attr)
Beispiel #17
0
Datei: tree.py Projekt: gijs/nltk
 def __getitem__(self, attr):
     if attr == "roof":
         return self._roof
     elif attr == "width":
         return self.canvas().itemcget(self._polygon, attr)
     elif attr == "color":
         return self.canvas().itemcget(self._polygon, "outline")
     elif isinstance(attr, tuple) and attr[0] == "color":
         l = self._lines[int(attr[1])]
         return self.canvas().itemcget(l, "fill")
     elif attr == "xspace":
         return self._xspace
     elif attr == "yspace":
         return self._yspace
     elif attr == "orientation":
         if self._horizontal:
             return "horizontal"
         else:
             return "vertical"
     elif attr == "ordered":
         return self._ordered
     else:
         return CanvasWidget.__getitem__(self, attr)
Beispiel #18
0
 def __setitem__(self, attr, value):
     if attr[:5] == "node_":
         for node in self._nodes:
             node[attr[5:]] = value
     elif attr[:5] == "leaf_":
         for leaf in self._leaves:
             leaf[attr[5:]] = value
     elif attr == "line_color":
         self._line_color = value
         for tseg in list(self._expanded_trees.values()):
             tseg["color"] = value
     elif attr == "line_width":
         self._line_width = value
         for tseg in list(self._expanded_trees.values()):
             tseg["width"] = value
         for tseg in list(self._collapsed_trees.values()):
             tseg["width"] = value
     elif attr == "roof_color":
         self._roof_color = value
         for tseg in list(self._collapsed_trees.values()):
             tseg["color"] = value
     elif attr == "roof_fill":
         self._roof_fill = value
         for tseg in list(self._collapsed_trees.values()):
             tseg["fill"] = value
     elif attr == "shapeable":
         self._shapeable = value
         for tseg in list(self._expanded_trees.values()):
             tseg["draggable"] = value
         for tseg in list(self._collapsed_trees.values()):
             tseg["draggable"] = value
         for leaf in self._leaves:
             leaf["draggable"] = value
     elif attr == "xspace":
         self._xspace = value
         for tseg in list(self._expanded_trees.values()):
             tseg["xspace"] = value
         for tseg in list(self._collapsed_trees.values()):
             tseg["xspace"] = value
         self.manage()
     elif attr == "yspace":
         self._yspace = value
         for tseg in list(self._expanded_trees.values()):
             tseg["yspace"] = value
         for tseg in list(self._collapsed_trees.values()):
             tseg["yspace"] = value
         self.manage()
     elif attr == "orientation":
         self._orientation = value
         for tseg in list(self._expanded_trees.values()):
             tseg["orientation"] = value
         for tseg in list(self._collapsed_trees.values()):
             tseg["orientation"] = value
         self.manage()
     elif attr == "ordered":
         self._ordered = value
         for tseg in list(self._expanded_trees.values()):
             tseg["ordered"] = value
         for tseg in list(self._collapsed_trees.values()):
             tseg["ordered"] = value
     else:
         CanvasWidget.__setitem__(self, attr, value)
Beispiel #19
0
Datei: tree.py Projekt: gijs/nltk
 def __setitem__(self, attr, value):
     if attr[:5] == "node_":
         for node in self._nodes:
             node[attr[5:]] = value
     elif attr[:5] == "leaf_":
         for leaf in self._leaves:
             leaf[attr[5:]] = value
     elif attr == "line_color":
         self._line_color = value
         for tseg in self._expanded_trees.values():
             tseg["color"] = value
     elif attr == "line_width":
         self._line_width = value
         for tseg in self._expanded_trees.values():
             tseg["width"] = value
         for tseg in self._collapsed_trees.values():
             tseg["width"] = value
     elif attr == "roof_color":
         self._roof_color = value
         for tseg in self._collapsed_trees.values():
             tseg["color"] = value
     elif attr == "roof_fill":
         self._roof_fill = value
         for tseg in self._collapsed_trees.values():
             tseg["fill"] = value
     elif attr == "shapeable":
         self._shapeable = value
         for tseg in self._expanded_trees.values():
             tseg["draggable"] = value
         for tseg in self._collapsed_trees.values():
             tseg["draggable"] = value
         for leaf in self._leaves:
             leaf["draggable"] = value
     elif attr == "xspace":
         self._xspace = value
         for tseg in self._expanded_trees.values():
             tseg["xspace"] = value
         for tseg in self._collapsed_trees.values():
             tseg["xspace"] = value
         self.manage()
     elif attr == "yspace":
         self._yspace = value
         for tseg in self._expanded_trees.values():
             tseg["yspace"] = value
         for tseg in self._collapsed_trees.values():
             tseg["yspace"] = value
         self.manage()
     elif attr == "orientation":
         self._orientation = value
         for tseg in self._expanded_trees.values():
             tseg["orientation"] = value
         for tseg in self._collapsed_trees.values():
             tseg["orientation"] = value
         self.manage()
     elif attr == "ordered":
         self._ordered = value
         for tseg in self._expanded_trees.values():
             tseg["ordered"] = value
         for tseg in self._collapsed_trees.values():
             tseg["ordered"] = value
     else:
         CanvasWidget.__setitem__(self, attr, value)
Beispiel #20
0
    def __setitem__(self, attr, value):
        if attr[:5] == 'node_':
            for node in self._nodes:
                #FMZ change
                #                if len(node._text.split(":"))==2 and attr[5:] == "color":
                #                    node["color"] = node._text.split(":")[1]
                #                    node._text = node._text.split(":")[0]
                #                    print(node._text)
                #                else:
                #print(attr[5:] + " --- " + node[attr[5:]])
                if attr[5:] == "color":
                    if node[attr[5:]] == "black":
                        node[attr[5:]] = value
                else:
                    node[attr[5:]] = value

        elif attr[:5] == 'leaf_':
            for leaf in self._leaves:
                leaf[attr[5:]] = value
        elif attr == 'line_color':
            self._line_color = value
            #for tseg in list(self._expanded_trees.values()): tseg['color'] = value
        elif attr == 'line_width':
            self._line_width = value
            for tseg in list(self._expanded_trees.values()):
                tseg['width'] = value
            for tseg in list(self._collapsed_trees.values()):
                tseg['width'] = value
        elif attr == 'roof_color':
            self._roof_color = value
            for tseg in list(self._collapsed_trees.values()):
                tseg['color'] = value
        elif attr == 'roof_fill':
            self._roof_fill = value
            for tseg in list(self._collapsed_trees.values()):
                tseg['fill'] = value
        elif attr == 'shapeable':
            self._shapeable = value
            for tseg in list(self._expanded_trees.values()):
                tseg['draggable'] = value
            for tseg in list(self._collapsed_trees.values()):
                tseg['draggable'] = value
            for leaf in self._leaves:
                leaf['draggable'] = value
        elif attr == 'xspace':
            self._xspace = value
            for tseg in list(self._expanded_trees.values()):
                tseg['xspace'] = value
            for tseg in list(self._collapsed_trees.values()):
                tseg['xspace'] = value
            self.manage()
        elif attr == 'yspace':
            self._yspace = value
            for tseg in list(self._expanded_trees.values()):
                tseg['yspace'] = value
            for tseg in list(self._collapsed_trees.values()):
                tseg['yspace'] = value
            self.manage()
        elif attr == 'orientation':
            self._orientation = value
            for tseg in list(self._expanded_trees.values()):
                tseg['orientation'] = value
            for tseg in list(self._collapsed_trees.values()):
                tseg['orientation'] = value
            self.manage()
        elif attr == 'ordered':
            self._ordered = value
            for tseg in list(self._expanded_trees.values()):
                tseg['ordered'] = value
            for tseg in list(self._collapsed_trees.values()):
                tseg['ordered'] = value
        else:
            CanvasWidget.__setitem__(self, attr, value)
Beispiel #21
0
 def __setitem__(self, attr, value):
     if attr[:5] == 'node_':
         for node in self._nodes:
             node[attr[5:]] = value
     elif attr[:5] == 'leaf_':
         for leaf in self._leaves:
             leaf[attr[5:]] = value
     elif attr == 'line_color':
         self._line_color = value
         for tseg in list(self._expanded_trees.values()):
             tseg['color'] = value
     elif attr == 'line_width':
         self._line_width = value
         for tseg in list(self._expanded_trees.values()):
             tseg['width'] = value
         for tseg in list(self._collapsed_trees.values()):
             tseg['width'] = value
     elif attr == 'roof_color':
         self._roof_color = value
         for tseg in list(self._collapsed_trees.values()):
             tseg['color'] = value
     elif attr == 'roof_fill':
         self._roof_fill = value
         for tseg in list(self._collapsed_trees.values()):
             tseg['fill'] = value
     elif attr == 'shapeable':
         self._shapeable = value
         for tseg in list(self._expanded_trees.values()):
             tseg['draggable'] = value
         for tseg in list(self._collapsed_trees.values()):
             tseg['draggable'] = value
         for leaf in self._leaves:
             leaf['draggable'] = value
     elif attr == 'xspace':
         self._xspace = value
         for tseg in list(self._expanded_trees.values()):
             tseg['xspace'] = value
         for tseg in list(self._collapsed_trees.values()):
             tseg['xspace'] = value
         self.manage()
     elif attr == 'yspace':
         self._yspace = value
         for tseg in list(self._expanded_trees.values()):
             tseg['yspace'] = value
         for tseg in list(self._collapsed_trees.values()):
             tseg['yspace'] = value
         self.manage()
     elif attr == 'orientation':
         self._orientation = value
         for tseg in list(self._expanded_trees.values()):
             tseg['orientation'] = value
         for tseg in list(self._collapsed_trees.values()):
             tseg['orientation'] = value
         self.manage()
     elif attr == 'ordered':
         self._ordered = value
         for tseg in list(self._expanded_trees.values()):
             tseg['ordered'] = value
         for tseg in list(self._collapsed_trees.values()):
             tseg['ordered'] = value
     else:
         CanvasWidget.__setitem__(self, attr, value)