本文整理汇总了Python中PyQt5.QtGui.QStandardItem方法的典型用法代码示例。如果您正苦于以下问题:Python QtGui.QStandardItem方法的具体用法?Python QtGui.QStandardItem怎么用?Python QtGui.QStandardItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui
的用法示例。
在下文中一共展示了QtGui.QStandardItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QStandardItem [as 别名]
def __init__(self,
name: str,
items: typing.Iterable[_ItemType],
sort: bool = True,
delete_func: util.DeleteFuncType = None,
parent: QWidget = None):
super().__init__(parent)
self.name = name
self.srcmodel = QStandardItemModel(parent=self)
self._pattern = ''
# ListCategory filters all columns
self.columns_to_filter = [0, 1, 2]
self.setFilterKeyColumn(-1)
for item in items:
self.srcmodel.appendRow([QStandardItem(x) for x in item])
self.setSourceModel(self.srcmodel)
self.delete_func = delete_func
self._sort = sort
示例2: generate_annotation_model
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QStandardItem [as 别名]
def generate_annotation_model(self):
# TODO
# Annotation previews will require creation of a
# QStyledItemDelegate
saved_annotations = self.parent.main_window.settings['annotations']
if not saved_annotations:
return
# Create annotation model
for i in saved_annotations:
item = QtGui.QStandardItem()
item.setText(i['name'])
item.setData(i, QtCore.Qt.UserRole)
self.parent.annotationModel.appendRow(item)
self.annotationListView.setModel(self.parent.annotationModel)
示例3: populateTree
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QStandardItem [as 别名]
def populateTree(self, node, parent):
"""Create a QTreeView node under 'parent'.
"""
item = QtGui.QStandardItem(node)
h, s, v = Detector.getDefaultHSVColor(node)
color = QColor()
color.setHsvF(h, s, v)
item.setIcon(self.getIcon(color))
# Unique hash for QStandardItem
key = hash(item)
while key in self.classifiersParameters:
key += 1
item.setData(key)
cp = ClassifierParameters(item.data(), node, node, color,
self.SHAPE_RECT, self.FILL_OUTLINE)
self.classifiersParameters[key] = cp
parent.appendRow(item)
return item
示例4: import_nodeset
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QStandardItem [as 别名]
def import_nodeset(self, path):
print("IMPORT", path)
name = os.path.basename(path)
if name in self.nodesets:
return
try:
self.server_mgr.import_xml(path)
except Exception as ex:
self.error.emit(ex)
raise
item = QStandardItem(name)
self.model.appendRow([item])
self.nodesets.append(name)
self.view.expandAll()
self.nodeset_added.emit(path)
示例5: _make_nonexec_function_time
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QStandardItem [as 别名]
def _make_nonexec_function_time(self, function_name):
"""
Build a tree item for a function name (for a non-executed function)
@type: String
@param function_name: Function name
@return:
"""
item_function = QtGui.QStandardItem(self.die_icons.icon_function, function_name)
item_function_count = QtGui.QStandardItem("0")
item_function_count.setEditable(False)
item_function.setEditable(False)
item_list = [item_function, item_function_count]
return item_list
示例6: addObj
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QStandardItem [as 别名]
def addObj(self):
global Tileset
Tileset.addObject(new=True)
pix = QtGui.QPixmap(24, 24)
pix.fill(Qt.transparent)
painter = QtGui.QPainter(pix)
painter.drawPixmap(0, 0, Tileset.tiles[0].image.scaledToWidth(24, Qt.SmoothTransformation))
painter.end()
del painter
count = len(Tileset.objects)
item = QtGui.QStandardItem(QtGui.QIcon(pix), 'Object {0}'.format(count-1))
item.setFlags(item.flags() & ~Qt.ItemIsEditable)
window.objmodel.appendRow(item)
index = window.objectList.currentIndex()
window.objectList.setCurrentIndex(index)
self.setObject(index)
window.objectList.update()
self.update()
示例7: doAddNode
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QStandardItem [as 别名]
def doAddNode(self, diagram, node):
"""
Add a node in the tree view.
:type diagram: QGraphicsScene
:type node: AbstractItem
"""
if node.type() in {Item.ConceptNode, Item.RoleNode, Item.AttributeNode, Item.IndividualNode}:
parent = self.parentFor(node)
if not parent:
parent = QtGui.QStandardItem(self.parentKey(node))
parent.setIcon(self.iconFor(node))
self.model.appendRow(parent)
self.proxy.sort(0, QtCore.Qt.AscendingOrder)
child = QtGui.QStandardItem(self.childKey(diagram, node))
child.setData(node)
parent.appendRow(child)
self.proxy.sort(0, QtCore.Qt.AscendingOrder)
示例8: _subscribe
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QStandardItem [as 别名]
def _subscribe(self, node=None):
if not isinstance(node, Node):
node = self.window.get_current_node()
if node is None:
return
if node in self._subscribed_nodes:
logger.warning("allready subscribed to node: %s ", node)
return
self.model.setHorizontalHeaderLabels(["DisplayName", "Value", "Timestamp"])
text = str(node.get_display_name().Text)
row = [QStandardItem(text), QStandardItem("No Data yet"), QStandardItem("")]
row[0].setData(node)
self.model.appendRow(row)
self._subscribed_nodes.append(node)
self.window.ui.subDockWidget.raise_()
try:
self.uaclient.subscribe_datachange(node, self._subhandler)
except Exception as ex:
self.window.show_error(ex)
idx = self.model.indexFromItem(row[0])
self.model.takeRow(idx.row())
raise
示例9: addItems
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QStandardItem [as 别名]
def addItems(self):
package = str(self.EditText.text())
try:
pkg = self.cache[package.strip()]
n = pkg.shortname
v = pkg.versions[0].version
desc = pkg.versions[0].description
name = "{}: {}".format(n, v)
if len(package) > 0 and pkg.is_installed is False:
item = QtGui.QStandardItem(name)
item.setCheckable(True)
item.setSelectable(True)
item.setToolTip((textwrap.fill(desc, 70)))
item.setCheckState(QtCore.Qt.Unchecked)
self.model.appendRow(item)
self.list_view.setModel(self.model)
else:
self.alreadyInstalled(name)
self.EditText.clear()
except KeyError:
self.showMessage(package)
示例10: _on_show_results
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QStandardItem [as 别名]
def _on_show_results(self):
if self._search_results:
self.results.clear()
if self._app_window.debug_panel.memory_panel:
self._app_window.debug_panel.memory_panel.remove_highlights('search')
selected_index = self.ranges.selectionModel().currentIndex().row()
if selected_index is not None:
item_txt = self._ranges_model.item(selected_index, 3).text()
if item_txt == '':
return
for result in self._search_results[selected_index]:
self._result_model.appendRow(
QStandardItem(result['address']))
# TODO: fix hexview highlights performance
"""
if self._app_window.memory_panel:
try:
self._app_window.memory_panel.add_highlight(
HighLight('search', utils.parse_ptr(result['address']), self._pattern_length))
except HighlightExistsError:
pass"""
示例11: __init__
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QStandardItem [as 别名]
def __init__(self, *args, **kwargs):
super(ListView, self).__init__(*args, **kwargs)
# 模型
self._model = QStandardItemModel(self)
self.setModel(self._model)
# 循环生成10个自定义控件
for i in range(10):
item = QStandardItem()
self._model.appendRow(item) # 添加item
# 得到索引
index = self._model.indexFromItem(item)
widget = CustomWidget(str(i))
item.setSizeHint(widget.sizeHint()) # 主要是调整item的高度
# 设置自定义的widget
self.setIndexWidget(index, widget)
示例12: addChild
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QStandardItem [as 别名]
def addChild(numChildren, nestingLevel):
result = []
if nestingLevel == 0:
return result
for i in range(numChildren):
child = QStandardItem(
"Child num {}, nesting level {}".format(i + 1, nestingLevel))
if i == 0:
child.appendRow(addChild(numChildren, nestingLevel - 1))
result.append(child)
return result
示例13: generate_toc_model
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QStandardItem [as 别名]
def generate_toc_model(self):
# The toc list is:
# 0: Level
# 1: Title
# 2: Chapter content / page number
# pprint it out to get a better idea of structure
toc = self.metadata['toc']
parent_list = []
for i in toc:
item = QtGui.QStandardItem()
item.setText(i[1])
item.setData(i[2], QtCore.Qt.UserRole)
item.setData(i[1], QtCore.Qt.UserRole + 1)
current_level = i[0]
if current_level == 1:
self.tocModel.appendRow(item)
parent_list.clear()
parent_list.append(item)
else:
parent_list[current_level - 2].appendRow(item)
try:
next_level = toc[toc.index(i) + 1][0]
if next_level > current_level:
parent_list.append(item)
if next_level < current_level:
level_difference = current_level - next_level
parent_list = parent_list[:-level_difference]
except IndexError:
pass
# This is needed to be able to have the toc Combobox
# jump to the correct position in the book when it is
# first opened
self.main_window.bookToolBar.tocBox.setModel(self.tocModel)
self.main_window.bookToolBar.tocTreeView.expandAll()
示例14: ok_pressed
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QStandardItem [as 别名]
def ok_pressed(self):
annotation_name = self.nameEdit.text()
if annotation_name == '':
self.nameEdit.setText('Why do you like bugs? WHY?')
return
annotation_components = {}
if self.foregroundCheck.isChecked():
annotation_components['foregroundColor'] = self.foregroundColor
if self.highlightCheck.isChecked():
annotation_components['highlightColor'] = self.highlightColor
if self.boldCheck.isChecked():
annotation_components['bold'] = True
if self.italicCheck.isChecked():
annotation_components['italic'] = True
if self.underlineCheck.isChecked():
annotation_components['underline'] = (
self.underlineType.currentText(), self.underlineColor)
self.current_annotation = {
'name': annotation_name,
'applicable_to': 'text',
'type': 'text_markup',
'components': annotation_components}
if self.modelIndex:
self.parent.annotationModel.setData(
self.modelIndex, annotation_name, QtCore.Qt.DisplayRole)
self.parent.annotationModel.setData(
self.modelIndex, self.current_annotation, QtCore.Qt.UserRole)
else: # New annotation
new_annotation_item = QtGui.QStandardItem()
new_annotation_item.setText(annotation_name)
new_annotation_item.setData(self.current_annotation, QtCore.Qt.UserRole)
self.parent.annotationModel.appendRow(new_annotation_item)
self.hide()
示例15: generate_annotations
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QStandardItem [as 别名]
def generate_annotations(self):
saved_annotations = self.main_window.settings['annotations']
for i in saved_annotations:
item = QtGui.QStandardItem()
item.setText(i['name'])
item.setData(i, QtCore.Qt.UserRole)
self.annotationModel.appendRow(item)
self.annotationsList.setModel(self.annotationModel)