本文整理汇总了Python中PySide.QtGui.QTreeWidgetItem方法的典型用法代码示例。如果您正苦于以下问题:Python QtGui.QTreeWidgetItem方法的具体用法?Python QtGui.QTreeWidgetItem怎么用?Python QtGui.QTreeWidgetItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui
的用法示例。
在下文中一共展示了QtGui.QTreeWidgetItem方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DataToTree
# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.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)
示例2: DataToTree
# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.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)
示例3: DataToTree_old_2LevelSearch
# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.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)
示例4: update
# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QTreeWidgetItem [as 别名]
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)
示例5: add_category
# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QTreeWidgetItem [as 别名]
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
# -------------------------------------------------------------------------
示例6: get_QTreeWidgetItem
# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QTreeWidgetItem [as 别名]
def get_QTreeWidgetItem():
"""QTreeWidgetItem getter."""
try:
import PySide.QtGui as QtGui
return QtGui.QTreeWidgetItem
except ImportError:
import PyQt5.QtWidgets as QtWidgets
return QtWidgets.QTreeWidgetItem
示例7: fill
# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QTreeWidgetItem [as 别名]
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)
示例8: quickTree
# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QTreeWidgetItem [as 别名]
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)
示例9: addModel
# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QTreeWidgetItem [as 别名]
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)