當前位置: 首頁>>代碼示例>>Python>>正文


Python QtGui.QTreeWidgetItem方法代碼示例

本文整理匯總了Python中PyQt4.QtGui.QTreeWidgetItem方法的典型用法代碼示例。如果您正苦於以下問題:Python QtGui.QTreeWidgetItem方法的具體用法?Python QtGui.QTreeWidgetItem怎麽用?Python QtGui.QTreeWidgetItem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt4.QtGui的用法示例。


在下文中一共展示了QtGui.QTreeWidgetItem方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: add_attribute

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QTreeWidgetItem [as 別名]
def add_attribute(self, parent, attribute_name, value, depth=0, index=0):
        item = QtGui.QTreeWidgetItem(parent)
        item.setFlags(QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsUserCheckable)
        item.setExpanded(True)
        # attribute name and type
        item.setText(0, attribute_name)
        item.dataType = type(value)
        item.remove = False  # this is flag for remove item when Layout Refresh
        item.depth = depth
        item.index = index

        # set value
        if item.dataType == bool:  # bool type
            item.setCheckState(1, QtCore.Qt.Checked if value else QtCore.Qt.Unchecked)
            item.setText(1, "True" if item.checkState(1) == QtCore.Qt.Checked else "False")
        elif item.dataType in (tuple, list, numpy.ndarray):  # set list type
            item.setText(1, "")  # set value to None
            for i, itemValue in enumerate(value):  # add child component
                self.add_attribute(item, "[%d]" % i, itemValue, depth + 1, i)
        else:  # set general type value - int, float, string
            item.setText(1, str(value))
        item.oldValue = item.text(1)  # set old value 
開發者ID:ubuntunux,項目名稱:PyEngine3D,代碼行數:24,代碼來源:MainWindow.py

示例2: newScreen

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QTreeWidgetItem [as 別名]
def newScreen(self):
        item = self.treeview_params.currentItem()

        if not item:
            self.logview.append("<font color=red>" + _("Please select a category before creating new screen") + "</font>")
            return

        if item.parent() is not None:
            item = item.parent()

        category = utf8(item.text(0))
        nsn = widgets.QInputDialog.getText(self, 'DDT4All', _('Enter screen name'))

        if not nsn[1]:
            return

        newscreenname = utf8(nsn[0])
        if newscreenname:
            self.paramview.createScreen(newscreenname, category)

            item.addChild(widgets.QTreeWidgetItem([newscreenname]))
            self.screennames.append(newscreenname) 
開發者ID:cedricp,項目名稱:ddt4all,代碼行數:24,代碼來源:ddt4all.py

示例3: childStateChanged

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QTreeWidgetItem [as 別名]
def childStateChanged(self, child, newState):
        if self.checkState(0) == Qt.Unchecked:
            #print "Child Changed while not logging"
            QtGui.QTreeWidgetItem.setData(child, 0, Qt.CheckStateRole, newState)
        elif self.checkState(0) == Qt.PartiallyChecked:
            pass
            #print "Waiting for log callback"
        elif self.checkState(0) == Qt.Checked:
            QtGui.QTreeWidgetItem.setData(child, 0, Qt.CheckStateRole, newState)
            if self.noneSelected():
                #print "Last child unselected, remove logger"
                self.stopLog()
            elif self.allSelected():
                #print "All children selected while logging, update logger"
                self.requestLog()
            else:
                #print "Child Changed while logging, update logger"
                self.requestLog() 
開發者ID:omwdunkley,項目名稱:crazyflieROS,代碼行數:20,代碼來源:logManager.py

示例4: __init__

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QTreeWidgetItem [as 別名]
def __init__(self, param, parent, editable):
        """ A parameter. If editable, the user can edit it. This does not change the value, but
            sends a request to the flie to update the value. The flie returns the new value which
            is then updated in this row
        """
        super(ParamItem, self).__init__(parent, type=1003)

        # Our param data
        self.param = param
        if editable:
            self.setFlags(self.flags() | Qt.ItemIsEditable)

        # Initial Populate
        QtGui.QTreeWidgetItem.setData(self, 0, Qt.DisplayRole, QVariant(param.name))
        QtGui.QTreeWidgetItem.setData(self, 1, Qt.DisplayRole, QVariant(param.ctype))
        QtGui.QTreeWidgetItem.setData(self, 2, Qt.DisplayRole, "Updating...")

        # Flie Updates
        self.cf = self.treeWidget().cf
        self.cf.param.add_update_callback(group=param.group, name=param.name, cb=self.updateValueCB) 
開發者ID:omwdunkley,項目名稱:crazyflieROS,代碼行數:22,代碼來源:paramManager.py

示例5: addProcessAndParents

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QTreeWidgetItem [as 別名]
def addProcessAndParents(proc, procList):
  """ adds a process and its parents to the tree of processes
  """
  global g_mainUi
  
  if g_treeProcesses.has_key(proc): #process already exists, do nothing
    return g_treeProcesses[proc]
    
  g_treeProcesses[proc] = QtGui.QTreeWidgetItem([])
  g_greenTopLevelItems[proc] = g_treeProcesses[proc]
  
  if procList[proc]["PPID"] > 0 and procList.has_key(procList[proc]["PPID"]): #process has a parent
    parent = addProcessAndParents(procList[proc]["PPID"],procList)
    parent.addChild(g_treeProcesses[proc])
  else: #process has no parent, thus it is toplevel. add it to the treewidget
    g_mainUi.processTreeWidget.addTopLevelItem(g_treeProcesses[proc])
    g_toplevelItems[proc] = g_treeProcesses[proc]
  
  return g_treeProcesses[proc] 
開發者ID:wolfc01,項目名稱:procexp,代碼行數:21,代碼來源:procexp.py

示例6: DataToTree

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QTreeWidgetItem [as 別名]
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) 
開發者ID:shiningdesign,項目名稱:universal_tool_template.py,代碼行數:22,代碼來源:universal_tool_template_1116.py

示例7: DataToTree

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QTreeWidgetItem [as 別名]
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) 
開發者ID:shiningdesign,項目名稱:universal_tool_template.py,代碼行數:20,代碼來源:universal_tool_template_1020.py

示例8: DataToTree_old_2LevelSearch

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QTreeWidgetItem [as 別名]
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) 
開發者ID:shiningdesign,項目名稱:universal_tool_template.py,代碼行數:21,代碼來源:GearBox_template_1010.py

示例9: addTreeNode

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QTreeWidgetItem [as 別名]
def addTreeNode(self, parents, children):
        os.path.join(parents)
        pathlist = parents.split(os.sep)
        parentnode = QtGui.QTreeWidgetItem(
            self.treewidget, [pathlist[-1], parents]
        )
        for files in children:
            QtGui.QTreeWidgetItem(
                parentnode, [files, os.path.join(parents, files)]
            )

        (
            self.obj_appconfig.
            proc_dict[self.obj_appconfig.current_project['ProjectName']]
        ) = []
        (
            self.obj_appconfig.
            dock_dict[self.obj_appconfig.current_project['ProjectName']]
        ) = [] 
開發者ID:FOSSEE,項目名稱:eSim,代碼行數:21,代碼來源:ProjectExplorer.py

示例10: updateXSS

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QTreeWidgetItem [as 別名]
def updateXSS(self,list):
		if not list:
			return
		for i in list:
			target=QtCore.QStringList()
			target.append(i[0])
			targetTree=QtGui.QTreeWidgetItem(target)
			self.treeXss.addTopLevelItem(targetTree)
			for j in i[1]:
				target2=QtCore.QStringList()
				target2.append("")
				target2.append(j[2])
				target2.append(j[1])
				str=""
				for l in j[3]:
					str+=l+"\r\n"
				target2.append(str)

				targetTree2=QtGui.QTreeWidgetItem(target2)
				targetTree.addChild(targetTree2) 
開發者ID:tuwid,項目名稱:darkc0de-old-stuff,代碼行數:22,代碼來源:mainform.py

示例11: updateSQLResults

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QTreeWidgetItem [as 別名]
def updateSQLResults(self,list):
		if not list:
			return
		for i in list:
			target=QtCore.QStringList()
			target.append(i[0])
			targetTree=QtGui.QTreeWidgetItem(target)
			self.treeSql.addTopLevelItem(targetTree)
			for j in i[1]:
				target2=QtCore.QStringList()
				target2.append("")
				for k in j:
					if k:
						target2.append(k)
					else:
						target2.append("")
				targetTree2=QtGui.QTreeWidgetItem(target2)
				targetTree.addChild(targetTree2)
			pass 
開發者ID:tuwid,項目名稱:darkc0de-old-stuff,代碼行數:21,代碼來源:mainform.py

示例12: _build_tree

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QTreeWidgetItem [as 別名]
def _build_tree(self, tree_wdgt, tree_def, root):
        parent, children = tree_def.items()[0]

        # empty label /parent is a special case: either inline with the previous, or skip
        if parent == "":
            if isinstance(children, QWidget):
                item = root
                tree_wdgt.setItemWidget(item, 1, children)

            elif isinstance(children, list):
                for c in children:
                    self._build_tree(tree_wdgt, c, root)

        elif parent == "set_expanded":  # a configuration item for the current root
            root.setExpanded(children)
        else:
            item = QTreeWidgetItem(root)
            item.setText(0, parent)

            if isinstance(children, list):
                for c in children:
                    self._build_tree(tree_wdgt, c, item)
            else:
                tree_wdgt.setItemWidget(item, 1, children) 
開發者ID:equinor,項目名稱:segyviewer,代碼行數:26,代碼來源:settingswindow.py

示例13: append

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QTreeWidgetItem [as 別名]
def append(self):

            for proto in self.sc[self.gakidou2].all_protocols():

                ports = self.sc[self.gakidou2][proto].keys()
                sort = sorted(ports)


                for port in sort:

                        self.items = QtGui.QTreeWidgetItem(self.ipachi)


                        self.esc = self.items.setText(0, str(port)+" "+self.sc[self.gakidou2][proto][port]['name'].title())
                        self.items.setText(1, self.sc[self.gakidou2][proto][port]['state'].title())


                        self.items.setText(2, self.sc[self.gakidou2][proto][port]['product'].title()+" "+self.sc[self.gakidou2][proto][port]['version'].title())

                        if "21" in self.items.text(0):
                            if self.items.text(1) == "Open":
                                self.ftptext.append(self.gakidou2)
                        if "22" in self.items.text(0):
                            if self.items.text(1) == "Open":
                                self.sshtext.append(self.gakidou2)
                        if "3389" in self.items.text(0):
                            if self.items.text(1) == "Open":
                                self.rdptext.append(self.gakidou2)
                        if "445" in self.items.text(0):
                            if self.items.text(1) == "Open":
                                self.smbtext.append(self.gakidou2)
                        if "80" in self.items.text(0):
                            if self.items.text(1) == "Open":
                                self.httptext.append(self.gakidou2)

            self.progressBar.setText("Scannig Finish ! "+ "["+str(self.hostcount)+"]" +" Host UP") 
開發者ID:azizaltuntas,項目名稱:Pymap-Scanner,代碼行數:38,代碼來源:pymap.py

示例14: findTreeItem

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QTreeWidgetItem [as 別名]
def findTreeItem(parentItem, findItemName):
    if type(parentItem) == QtGui.QTreeWidget:
        for item in parentItem.findItems("", QtCore.Qt.MatchExactly):
            if item.text(0) == findItemName:
                return item
    elif type(parentItem) == QtGui.QTreeWidgetItem:
        for i in range(parentItem.childCount()):
            item = parentItem.child(i)
            if item.text(0) == findItemName:
                return item
    return None 
開發者ID:ubuntunux,項目名稱:PyEngine3D,代碼行數:13,代碼來源:MainWindow.py

示例15: add_resource_list

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QTreeWidgetItem [as 別名]
def add_resource_list(self, resourceList):
        for resName, resType in resourceList:
            item = QtGui.QTreeWidgetItem(self.resourceListWidget)
            item.setText(0, resName)
            item.setText(1, resType) 
開發者ID:ubuntunux,項目名稱:PyEngine3D,代碼行數:7,代碼來源:MainWindow.py


注:本文中的PyQt4.QtGui.QTreeWidgetItem方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。