本文整理汇总了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
示例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)
示例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()
示例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)
示例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]
示例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)
示例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)
示例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)
示例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']]
) = []
示例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)
示例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
示例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)
示例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")
示例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
示例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)