Python PySide.QtGui.QTreeWidgetItem() Examples

The following are 21 code examples of PySide.QtGui.QTreeWidgetItem(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PySide.QtGui , or try the search function .
Example #1
Source File: SheetMetalCmd.py    From FreeCAD_SheetMetal with GNU General Public License v3.0 6 votes vote down vote up
def update(self):
      'fills the treewidget'
      self.tree.clear()
      if self.obj:
        f = self.obj.baseObject
        if isinstance(f[1],list):
          for subf in f[1]:
            #FreeCAD.Console.PrintLog("item: " + subf + "\n")
            item = QtGui.QTreeWidgetItem(self.tree)
            item.setText(0,f[0].Name)
            item.setIcon(0,QtGui.QIcon(":/icons/Tree_Part.svg"))
            item.setText(1,subf)  
        else:
          item = QtGui.QTreeWidgetItem(self.tree)
          item.setText(0,f[0].Name)
          item.setIcon(0,QtGui.QIcon(":/icons/Tree_Part.svg"))
          item.setText(1,f[1][0])
      self.retranslateUi(self.form) 
Example #2
Source File: SheetMetalRelief.py    From FreeCAD_SheetMetal with GNU General Public License v3.0 6 votes vote down vote up
def update(self):
      'fills the treewidget'
      self.tree.clear()
      if self.obj:
        f = self.obj.baseObject
        if isinstance(f[1],list):
          for subf in f[1]:
            #FreeCAD.Console.PrintLog("item: " + subf + "\n")
            item = QtGui.QTreeWidgetItem(self.tree)
            item.setText(0,f[0].Name)
            item.setIcon(0,QtGui.QIcon(":/icons/Tree_Part.svg"))
            item.setText(1,subf)  
        else:
          item = QtGui.QTreeWidgetItem(self.tree)
          item.setText(0,f[0].Name)
          item.setIcon(0,QtGui.QIcon(":/icons/Tree_Part.svg"))
          item.setText(1,f[1][0])
      self.retranslateUi(self.form) 
Example #3
Source File: SheetMetalJunction.py    From FreeCAD_SheetMetal with GNU General Public License v3.0 6 votes vote down vote up
def update(self):
      'fills the treewidget'
      self.tree.clear()
      if self.obj:
        f = self.obj.baseObject
        if isinstance(f[1],list):
          for subf in f[1]:
            #FreeCAD.Console.PrintLog("item: " + subf + "\n")
            item = QtGui.QTreeWidgetItem(self.tree)
            item.setText(0,f[0].Name)
            item.setIcon(0,QtGui.QIcon(":/icons/Tree_Part.svg"))
            item.setText(1,subf)  
        else:
          item = QtGui.QTreeWidgetItem(self.tree)
          item.setText(0,f[0].Name)
          item.setIcon(0,QtGui.QIcon(":/icons/Tree_Part.svg"))
          item.setText(1,f[1][0])
      self.retranslateUi(self.form) 
Example #4
Source File: SheetMetalBend.py    From FreeCAD_SheetMetal with GNU General Public License v3.0 6 votes vote down vote up
def update(self):
      'fills the treewidget'
      self.tree.clear()
      if self.obj:
        f = self.obj.baseObject
        if isinstance(f[1],list):
          for subf in f[1]:
            #FreeCAD.Console.PrintLog("item: " + subf + "\n")
            item = QtGui.QTreeWidgetItem(self.tree)
            item.setText(0,f[0].Name)
            item.setIcon(0,QtGui.QIcon(":/icons/Tree_Part.svg"))
            item.setText(1,subf)  
        else:
          item = QtGui.QTreeWidgetItem(self.tree)
          item.setText(0,f[0].Name)
          item.setIcon(0,QtGui.QIcon(":/icons/Tree_Part.svg"))
          item.setText(1,f[1][0])
      self.retranslateUi(self.form) 
Example #5
Source File: universal_tool_template_1116.py    From universal_tool_template.py with MIT License 6 votes vote down vote up
def DataToTree(self, tree, cur_node, data, filter='', col=0):
        node_info = data[0]
        node_info_child = data[1]
        [cur_node.setText(i, node_info[i]) for i in range(len(node_info))]
        # re filter
        if filter != '' and isinstance(filter, (str, unicode)):
            filter = re.compile(filter, re.IGNORECASE)
        for sub_data in node_info_child:
            if filter == '':
                new_node = QtWidgets.QTreeWidgetItem()
                cur_node.addChild(new_node)
                self.DataToTree(tree, new_node, sub_data)
            else:
                if not filter.search(sub_data[0][col]) and not self.DataChildCheck(sub_data[1], filter, col):
                    pass
                else:
                    new_node = QtWidgets.QTreeWidgetItem()
                    cur_node.addChild(new_node)
                    new_node.setExpanded(1)
                    self.DataToTree(tree, new_node, sub_data, filter, col) 
Example #6
Source File: universal_tool_template_1020.py    From universal_tool_template.py with MIT License 6 votes vote down vote up
def DataToTree(self, tree, cur_node, data, filter=''):
        node_info = data[0]
        node_info_child = data[1]
        [cur_node.setText(i, node_info[i]) for i in range(len(node_info))]
        target = re.compile(filter, re.IGNORECASE)
        for sub_data in node_info_child:
            if filter == '':
                new_node = QtWidgets.QTreeWidgetItem()
                cur_node.addChild(new_node)
                self.DataToTree(tree, new_node, sub_data)
            else:
                if not target.search(sub_data[0][0]) and not self.DataChildCheck(sub_data[1], filter):
                    pass
                else:
                    new_node = QtWidgets.QTreeWidgetItem()
                    cur_node.addChild(new_node)
                    new_node.setExpanded(1)
                    self.DataToTree(tree, new_node, sub_data, filter) 
Example #7
Source File: GearBox_template_1010.py    From universal_tool_template.py with MIT License 6 votes vote down vote up
def DataToTree_old_2LevelSearch(self, tree, cur_node, data, filter=''):
        node_info = data[0]
        node_info_child = data[1]
        [cur_node.setText(i, node_info[i]) for i in range(len(node_info))]
        target = re.compile(filter, re.IGNORECASE)
        for sub_data in node_info_child:
            if filter == '':
                new_node = QtWidgets.QTreeWidgetItem()
                cur_node.addChild(new_node)
                self.DataToTree(tree, new_node, sub_data)
            else:
                if not target.search(sub_data[0][0]) and len(sub_data[1]) == 0:
                    #print(sub_data[0][0]) print(sub_data[1])
                    pass    
                else:
                    new_node = QtWidgets.QTreeWidgetItem()
                    cur_node.addChild(new_node)
                    new_node.setExpanded(1)
                    self.DataToTree(tree, new_node, sub_data, filter) 
Example #8
Source File: GearBox_template_1010.py    From universal_tool_template.py with MIT License 6 votes vote down vote up
def DataToTree(self, tree, cur_node, data, filter=''):
        node_info = data[0]
        node_info_child = data[1]
        [cur_node.setText(i, node_info[i]) for i in range(len(node_info))]
        target = re.compile(filter, re.IGNORECASE)
        for sub_data in node_info_child:
            if filter == '':
                new_node = QtWidgets.QTreeWidgetItem()
                cur_node.addChild(new_node)
                self.DataToTree(tree, new_node, sub_data)
            else:
                if not target.search(sub_data[0][0]) and not self.DataChildCheck(sub_data[1], filter):
                    pass
                else:
                    new_node = QtWidgets.QTreeWidgetItem()
                    cur_node.addChild(new_node)
                    new_node.setExpanded(1)
                    self.DataToTree(tree, new_node, sub_data, filter) 
Example #9
Source File: universal_tool_template_1112.py    From universal_tool_template.py with MIT License 6 votes vote down vote up
def DataToTree(self, tree, cur_node, data, filter='', col=0):
        node_info = data[0]
        node_info_child = data[1]
        [cur_node.setText(i, node_info[i]) for i in range(len(node_info))]
        # re filter
        if filter != '' and isinstance(filter, (str, unicode)):
            filter = re.compile(filter, re.IGNORECASE)
        for sub_data in node_info_child:
            if filter == '':
                new_node = QtWidgets.QTreeWidgetItem()
                cur_node.addChild(new_node)
                self.DataToTree(tree, new_node, sub_data)
            else:
                if not filter.search(sub_data[0][col]) and not self.DataChildCheck(sub_data[1], filter, col):
                    pass
                else:
                    new_node = QtWidgets.QTreeWidgetItem()
                    cur_node.addChild(new_node)
                    new_node.setExpanded(1)
                    self.DataToTree(tree, new_node, sub_data, filter, col) 
Example #10
Source File: universal_tool_template_1100.py    From universal_tool_template.py with MIT License 6 votes vote down vote up
def DataToTree(self, tree, cur_node, data, filter=''):
        node_info = data[0]
        node_info_child = data[1]
        [cur_node.setText(i, node_info[i]) for i in range(len(node_info))]
        target = re.compile(filter, re.IGNORECASE)
        for sub_data in node_info_child:
            if filter == '':
                new_node = QtWidgets.QTreeWidgetItem()
                cur_node.addChild(new_node)
                self.DataToTree(tree, new_node, sub_data)
            else:
                if not target.search(sub_data[0][0]) and not self.DataChildCheck(sub_data[1], filter):
                    pass
                else:
                    new_node = QtWidgets.QTreeWidgetItem()
                    cur_node.addChild(new_node)
                    new_node.setExpanded(1)
                    self.DataToTree(tree, new_node, sub_data, filter) 
Example #11
Source File: universal_tool_template_1110.py    From universal_tool_template.py with MIT License 6 votes vote down vote up
def DataToTree(self, tree, cur_node, data, filter='', col=0):
        node_info = data[0]
        node_info_child = data[1]
        [cur_node.setText(i, node_info[i]) for i in range(len(node_info))]
        # re filter
        if filter != '' and isinstance(filter, (str, unicode)):
            filter = re.compile(filter, re.IGNORECASE)
        for sub_data in node_info_child:
            if filter == '':
                new_node = QtWidgets.QTreeWidgetItem()
                cur_node.addChild(new_node)
                self.DataToTree(tree, new_node, sub_data)
            else:
                if not filter.search(sub_data[0][col]) and not self.DataChildCheck(sub_data[1], filter, col):
                    pass
                else:
                    new_node = QtWidgets.QTreeWidgetItem()
                    cur_node.addChild(new_node)
                    new_node.setExpanded(1)
                    self.DataToTree(tree, new_node, sub_data, filter, col) 
Example #12
Source File: universal_tool_template_1010.py    From universal_tool_template.py with MIT License 6 votes vote down vote up
def DataToTree_old_2LevelSearch(self, tree, cur_node, data, filter=''):
        node_info = data[0]
        node_info_child = data[1]
        [cur_node.setText(i, node_info[i]) for i in range(len(node_info))]
        target = re.compile(filter, re.IGNORECASE)
        for sub_data in node_info_child:
            if filter == '':
                new_node = QtWidgets.QTreeWidgetItem()
                cur_node.addChild(new_node)
                self.DataToTree(tree, new_node, sub_data)
            else:
                if not target.search(sub_data[0][0]) and len(sub_data[1]) == 0:
                    #print(sub_data[0][0]) print(sub_data[1])
                    pass    
                else:
                    new_node = QtWidgets.QTreeWidgetItem()
                    cur_node.addChild(new_node)
                    new_node.setExpanded(1)
                    self.DataToTree(tree, new_node, sub_data, filter) 
Example #13
Source File: universal_tool_template_1010.py    From universal_tool_template.py with MIT License 6 votes vote down vote up
def DataToTree(self, tree, cur_node, data, filter=''):
        node_info = data[0]
        node_info_child = data[1]
        [cur_node.setText(i, node_info[i]) for i in range(len(node_info))]
        target = re.compile(filter, re.IGNORECASE)
        for sub_data in node_info_child:
            if filter == '':
                new_node = QtWidgets.QTreeWidgetItem()
                cur_node.addChild(new_node)
                self.DataToTree(tree, new_node, sub_data)
            else:
                if not target.search(sub_data[0][0]) and not self.DataChildCheck(sub_data[1], filter):
                    pass
                else:
                    new_node = QtWidgets.QTreeWidgetItem()
                    cur_node.addChild(new_node)
                    new_node.setExpanded(1)
                    self.DataToTree(tree, new_node, sub_data, filter) 
Example #14
Source File: __init__.py    From dpa-pipe with MIT License 5 votes vote down vote up
def add_category(self, category):

        category_item = QtGui.QTreeWidgetItem([category])
        category_item.setFlags(QtCore.Qt.ItemIsEnabled)
        self.addTopLevelItem(category_item)
        category_item.setExpanded(True)
        self._category_items[category] = category_item

    # ------------------------------------------------------------------------- 
Example #15
Source File: treewindow.py    From MARA_Framework with GNU Lesser General Public License v3.0 5 votes vote down vote up
def fill(self):
        '''Parse all the paths (['Lcom/example/myclass/MyActivity$1;', ...])
           and build a tree using the QTreeWidgetItem insertion method.'''
        androconf.debug("Fill classes tree")

        for idx, filename, digest, classes in self.session.get_classes():
            for c in sorted(classes, key=lambda c: c.name):
                sig = Signature(c)
                path_node = self.root_path_node

                path = None
                if sig.class_path == []:
                    path = '.'
                    if path not in path_node[0]:
                        path_node[0][path] = ({}, QtGui.QTreeWidgetItem(path_node[1]))
                        path_node[0][path][1].setText(0, path)
                    path_node = path_node[0][path]
                else:
                    # Namespaces
                    for path in sig.class_path:
                        if path not in path_node[0]:
                            path_node[0][path] = ({}, QtGui.QTreeWidgetItem(path_node[1]))
                            path_node[0][path][1].setText(0, path)
                        path_node = path_node[0][path]

                # Class
                path_node[0][path] = ({}, QtGui.QTreeWidgetItem(path_node[1]))

                class_name = sig.class_name

                if idx > 0:
                    class_name += "@%d" % idx

                c.current_title = class_name
                self._reverse_cache[path_node[0][path][1]] = (c,
                                                              filename,
                                                              digest)


                path_node[0][path][1].setText(0, class_name) 
Example #16
Source File: universal_tool_template_1116.py    From universal_tool_template.py with MIT License 5 votes vote down vote up
def quickTree(self, cur_node, node_data, editable=0):
        # not per-column control on editable
        if not isinstance(node_data, (list, tuple)):
            node_data = [node_data]
        # 1. create a new node
        new_node = QtWidgets.QTreeWidgetItem()
        for i,name in enumerate(node_data):
            new_node.setText(i, name)
        if editable == 1:
            new_node.setFlags(new_node.flags()|QtCore.Qt.ItemIsEditable)
        # 2. add it
        cur_node.addChild(new_node)
        # 3. expand it
        cur_node.setExpanded(1) 
Example #17
Source File: treewindow.py    From AndroBugs_Framework with GNU General Public License v3.0 5 votes vote down vote up
def fill(self):
        '''Parse all the paths (['Lcom/example/myclass/MyActivity$1;', ...])
           and build a tree using the QTreeWidgetItem insertion method.'''
        androconf.debug("Fill classes tree")

        for idx, filename, digest, classes in self.session.get_classes():
            for c in sorted(classes, key=lambda c: c.name):
                sig = Signature(c)
                path_node = self.root_path_node

                path = None
                if sig.class_path == []:
                    path = '.'
                    if path not in path_node[0]:
                        path_node[0][path] = ({}, QtGui.QTreeWidgetItem(path_node[1]))
                        path_node[0][path][1].setText(0, path)
                    path_node = path_node[0][path]
                else:
                    # Namespaces
                    for path in sig.class_path:
                        if path not in path_node[0]:
                            path_node[0][path] = ({}, QtGui.QTreeWidgetItem(path_node[1]))
                            path_node[0][path][1].setText(0, path)
                        path_node = path_node[0][path]

                # Class
                path_node[0][path] = ({}, QtGui.QTreeWidgetItem(path_node[1]))

                class_name = sig.class_name

                if idx > 0:
                    class_name += "@%d" % idx

                c.current_title = class_name
                self._reverse_cache[path_node[0][path][1]] = (c,
                                                              filename,
                                                              digest)


                path_node[0][path][1].setText(0, class_name) 
Example #18
Source File: treewindow.py    From TimeMachine with GNU Lesser General Public License v3.0 5 votes vote down vote up
def fill(self):
        '''Parse all the paths (['Lcom/example/myclass/MyActivity$1;', ...])
           and build a tree using the QTreeWidgetItem insertion method.'''
        androconf.debug("Fill classes tree")

        for idx, filename, digest, classes in self.session.get_classes():
            for c in sorted(classes, key=lambda c: c.name):
                sig = Signature(c)
                path_node = self.root_path_node

                path = None
                if sig.class_path == []:
                    path = '.'
                    if path not in path_node[0]:
                        path_node[0][path] = ({}, QtGui.QTreeWidgetItem(path_node[1]))
                        path_node[0][path][1].setText(0, path)
                    path_node = path_node[0][path]
                else:
                    # Namespaces
                    for path in sig.class_path:
                        if path not in path_node[0]:
                            path_node[0][path] = ({}, QtGui.QTreeWidgetItem(path_node[1]))
                            path_node[0][path][1].setText(0, path)
                        path_node = path_node[0][path]

                # Class
                path_node[0][path] = ({}, QtGui.QTreeWidgetItem(path_node[1]))

                class_name = sig.class_name

                if idx > 0:
                    class_name += "@%d" % idx

                c.current_title = class_name
                self._reverse_cache[path_node[0][path][1]] = (c,
                                                              filename,
                                                              digest)


                path_node[0][path][1].setText(0, class_name) 
Example #19
Source File: QtShim.py    From grap with MIT License 5 votes vote down vote up
def get_QTreeWidgetItem():
    """QTreeWidgetItem getter."""

    try:
        import PySide.QtGui as QtGui
        return QtGui.QTreeWidgetItem
    except ImportError:
        import PyQt5.QtWidgets as QtWidgets
        return QtWidgets.QTreeWidgetItem 
Example #20
Source File: __init__.py    From dpa-pipe with MIT License 5 votes vote down vote up
def add_category(self, category):

        category_item = QtGui.QTreeWidgetItem([category])
        category_item.setFlags(QtCore.Qt.ItemIsEnabled)
        self.addTopLevelItem(category_item)
        category_item.setExpanded(True)
        self._category_items[category] = category_item

    # ------------------------------------------------------------------------- 
Example #21
Source File: VariablesBrowser.py    From PySimulator with GNU Lesser General Public License v3.0 4 votes vote down vote up
def addModel(self, model, treeRoot=None):
        ''' Adds the given model to the variable browser
        '''
        self.itemChanged.disconnect()
        model.setVariableTree()

        if treeRoot is None:
            treeRoot = QtGui.QTreeWidgetItem(self)
            treeRoot.setCheckState(0, QtCore.Qt.Checked)
            treeRoot.setFlags(treeRoot.flags() & ~QtCore.Qt.ItemIsEditable & ~QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsUserCheckable)
            treeRoot.setText(0, model.numberedModelName)
            if model.modelType == 'None':
                treeRoot.setForeground(0, QtGui.QBrush(QtGui.QColor('grey')))
            treeRoot.numberedModelName = model.numberedModelName
            treeRoot.model = model
            treeRoot.isModelRoot = True
            treeRoot.setFirstColumnSpanned(True)
            treeRoot.setExpanded(True)
            model.rootItem = treeRoot
        elif treeRoot.childCount() > 0:
            # Define function that is called when a item of the tree will be checked/unchecked
            self.itemChanged.connect(self.browserItemCheckChanged)
            return

        # Define the tipText displayed when stopping the mouse over the numbered model name in the variable browser
        tipText = 'Model type: ' + model.modelType
        if model.variableTree.rootAttribute is not None:
            if len(model.variableTree.rootAttribute) > 0:
                tipText += '\n\n' + model.variableTree.rootAttribute
        treeRoot.setToolTip(0, tipText)
        # Generate a nice list of model variables
        # variableNames = model.variableTree.variable.keys()
        variableNames = list()
        for name, variable in model.variableTree.variable.iteritems():
            variableNames.append([variable.browserName, name])

        def natsort_key(x1, _nsre=re.compile('([0-9]+)')):
            x = x1[0]
            return [int(text) if text.isdigit() else text.lower() for text in re.split(_nsre, x)]

        # Sort the variables for the tree
        variableNames.sort(key=natsort_key)

        for v in variableNames:
            self.addItemToTree(treeRoot, v[0], v[1], model)

        # Show changed start values in startValueBox given in model.settings
        for variable in model.changedStartValue:
            self.setVariable(model, variable, model.changedStartValue[variable])

        # Define function that is called when a item of the tree will be checked/unchecked
        self.itemChanged.connect(self.browserItemCheckChanged)
        self.itemExpanded.connect(self.dyamicLoadBranch)
        # To set this model as current one
        self.browserItemCheckChanged(treeRoot)