当前位置: 首页>>代码示例>>Python>>正文


Python QStandardItem.appendRow方法代码示例

本文整理汇总了Python中PyQt5.QtGui.QStandardItem.appendRow方法的典型用法代码示例。如果您正苦于以下问题:Python QStandardItem.appendRow方法的具体用法?Python QStandardItem.appendRow怎么用?Python QStandardItem.appendRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtGui.QStandardItem的用法示例。


在下文中一共展示了QStandardItem.appendRow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _show_attrs

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import appendRow [as 别名]
 def _show_attrs(self, node):
     try:
         attrs = self.uaclient.get_all_attrs(node)
     except Exception as ex:
         self.window.show_error(ex)
         raise
     self.model.setHorizontalHeaderLabels(['Attribute', 'Value', 'DataType'])
     for name, dv in attrs:
         if name == "DataType":
             if isinstance(dv.Value.Value.Identifier, int) and dv.Value.Value.Identifier < 63:
                 string = ua.DataType_to_VariantType(dv.Value.Value).name
             elif dv.Value.Value.Identifier in ua.ObjectIdNames:
                 string = ua.ObjectIdNames[dv.Value.Value.Identifier]
             else:
                 string = dv.Value.Value.to_string()
         elif name in ("AccessLevel", "UserAccessLevel"):
             string = ",".join([e.name for e in ua.int_to_AccessLevel(dv.Value.Value)])
         elif name in ("WriteMask", "UserWriteMask"):
             string = ",".join([e.name for e in ua.int_to_WriteMask(dv.Value.Value)])
         elif name in ("EventNotifier"):
             string = ",".join([e.name for e in ua.int_to_EventNotifier(dv.Value.Value)])
         else:
             string = variant_to_string(dv.Value)
         name_item = QStandardItem(name)
         vitem = QStandardItem(string)
         vitem.setData(dv.Value)
         self.model.appendRow([name_item, vitem, QStandardItem(dv.Value.VariantType.name)])
         if name == "Value":
             string = val_to_string(dv.ServerTimestamp)
             name_item.appendRow([QStandardItem("Server Timestamp"), QStandardItem(string), QStandardItem(ua.VariantType.DateTime.name)])
             string = val_to_string(dv.SourceTimestamp)
             name_item.appendRow([QStandardItem("Source Timestamp"), QStandardItem(string), QStandardItem(ua.VariantType.DateTime.name)])
开发者ID:lavstudia,项目名称:opcua-client-gui,代码行数:34,代码来源:mainwindow.py

示例2: test_completion_item_next_prev

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import appendRow [as 别名]
def test_completion_item_next_prev(tree, count, expected, completionview):
    """Test that on_next_prev_item moves the selection properly.

    Args:
        tree: Each list represents a completion category, with each string
              being an item under that category.
        count: Number of times to go forward (or back if negative).
        expected: item data that should be selected after going back/forward.
    """
    model = base.BaseCompletionModel()
    for catdata in tree:
        cat = QStandardItem()
        model.appendRow(cat)
        for name in catdata:
            cat.appendRow(QStandardItem(name))
    filtermodel = sortfilter.CompletionFilterModel(model,
                                                   parent=completionview)
    completionview.set_model(filtermodel)
    if count < 0:
        for _ in range(-count):
            completionview.completion_item_prev()
    else:
        for _ in range(count):
            completionview.completion_item_next()
    idx = completionview.selectionModel().currentIndex()
    assert filtermodel.data(idx) == expected
开发者ID:tjanson,项目名称:qutebrowser,代码行数:28,代码来源:test_completionwidget.py

示例3: _show_attrs

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import appendRow [as 别名]
    def _show_attrs(self):
        attrs = self.get_all_attrs()
        self.model.setHorizontalHeaderLabels(['Attribute', 'Value', 'DataType'])
        for attr, dv in attrs:
            if attr == ua.AttributeIds.DataType:
                string = data_type_to_string(dv)
            elif attr in (ua.AttributeIds.AccessLevel,
                          ua.AttributeIds.UserAccessLevel,
                          ua.AttributeIds.WriteMask,
                          ua.AttributeIds.UserWriteMask,
                          ua.AttributeIds.EventNotifier):
                attr_name = attr.name
                if attr_name.startswith("User"):
                    attr_name = attr_name[4:]
                attr_enum = getattr(ua, attr_name)
                string = ", ".join([e.name for e in attr_enum.parse_bitfield(dv.Value.Value)])
            else:
                string = variant_to_string(dv.Value)
            name_item = QStandardItem(attr.name)
            vitem = QStandardItem(string)
            vitem.setData((attr, dv), Qt.UserRole)
            self.model.appendRow([name_item, vitem, QStandardItem(dv.Value.VariantType.name)])

            # special case for Value, we want to show timestamps
            if attr == ua.AttributeIds.Value:
                string = val_to_string(dv.ServerTimestamp)
                name_item.appendRow([QStandardItem("Server Timestamp"), QStandardItem(string), QStandardItem(ua.VariantType.DateTime.name)])
                string = val_to_string(dv.SourceTimestamp)
                name_item.appendRow([QStandardItem("Source Timestamp"), QStandardItem(string), QStandardItem(ua.VariantType.DateTime.name)])
开发者ID:davorcizmok,项目名称:opcua-widgets,代码行数:31,代码来源:attrs_widget.py

示例4: test_completion_item_focus

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import appendRow [as 别名]
def test_completion_item_focus(which, tree, expected, completionview, qtbot):
    """Test that on_next_prev_item moves the selection properly.

    Args:
        which: the direction in which to move the selection.
        tree: Each list represents a completion category, with each string
              being an item under that category.
        expected: expected argument from on_selection_changed for each
                  successive movement. None implies no signal should be
                  emitted.
    """
    model = base.BaseCompletionModel()
    for catdata in tree:
        cat = QStandardItem()
        model.appendRow(cat)
        for name in catdata:
            cat.appendRow(QStandardItem(name))
    filtermodel = sortfilter.CompletionFilterModel(model,
                                                   parent=completionview)
    completionview.set_model(filtermodel)
    for entry in expected:
        if entry is None:
            with qtbot.assertNotEmitted(completionview.selection_changed):
                completionview.completion_item_focus(which)
        else:
            with qtbot.waitSignal(completionview.selection_changed) as sig:
                completionview.completion_item_focus(which)
                assert sig.args == [entry]
开发者ID:michaelbeaumont,项目名称:qutebrowser,代码行数:30,代码来源:test_completionwidget.py

示例5: test_completion_show

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import appendRow [as 别名]
def test_completion_show(show, rows, quick_complete, completionview,
                         config_stub):
    """Test that the completion widget is shown at appropriate times.

    Args:
        show: The completion show config setting.
        rows: Each entry represents a completion category with only one item.
        quick_complete: The completion quick-complete config setting.
    """
    config_stub.data['completion']['show'] = show
    config_stub.data['completion']['quick-complete'] = quick_complete

    model = base.BaseCompletionModel()
    for name in rows:
        cat = QStandardItem()
        model.appendRow(cat)
        cat.appendRow(QStandardItem(name))
    filtermodel = sortfilter.CompletionFilterModel(model,
                                                   parent=completionview)

    assert not completionview.isVisible()
    completionview.set_model(filtermodel)
    assert completionview.isVisible() == (show == 'always' and len(rows) > 0)
    completionview.completion_item_focus('next')
    expected = (show != 'never' and len(rows) > 0 and
                not (quick_complete and len(rows) == 1))
    assert completionview.isVisible() == expected
    completionview.set_model(None)
    completionview.completion_item_focus('next')
    assert not completionview.isVisible()
开发者ID:shioyama,项目名称:qutebrowser,代码行数:32,代码来源:test_completionwidget.py

示例6: addItems

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import appendRow [as 别名]
 def addItems(self, parent, elements):
     for k in sorted(elements.keys()):
         item = QStandardItem(k)
         parent.appendRow(item)
         if type(elements[k]) == dict:
             self.addItems(item, elements[k])
         else:
             child = QStandardItem(str(elements[k]))
             item.appendRow(child)
开发者ID:liulimin90,项目名称:pySPM,代码行数:11,代码来源:GUI.py

示例7: build_custom_tree

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import appendRow [as 别名]
 def build_custom_tree(result, index_item):
     if type(result) is not ParsedCustom:
         return
     parent_item = index_item.child(index_item.rowCount() - 1)
     # Custom nodes have tree representation of their data
     # For the size of custom node, add an index indicator (e.g. [1])
     for i, array_index in enumerate(result.data):
         index_item = QStandardItem("[%d]" % i)
         parent_item.appendRow([index_item])
         # In a level under index indicator, show data types
         for sub_result in array_index:
             index_item.appendRow(build_row(sub_result))
             build_custom_tree(sub_result, index_item)
         if i == 0:
             self.setExpanded(index_item.index(), True)
     self.setExpanded(parent_item.index(), True)
开发者ID:bwrsandman,项目名称:ReconStruct,代码行数:18,代码来源:DeconstructTreeView.py

示例8: addComment

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import appendRow [as 别名]
 def addComment(self, HNComment):
     self.currentCommentCount += 1
     if not 'deleted' in HNComment:
         authorItem = QStandardItem(
             '<style>#author { color: gray; font-size: 11pt; '
             'margin-bottom: 5px } </style><p id="author">' +
             HNComment['by'] + ' ' +
             format_time(HNComment['time']) + '</p>')
         authorItem.setData(HNComment['pos'], Qt.UserRole + 1337)
         textItem = QStandardItem(unescape(HNComment['text']))
         textItem.setData(HNComment['pos'], Qt.UserRole + 1337)
         authorItem.appendRow(textItem)
         self.commentsTree.rootItem.appendRow(authorItem)
     if self.currentCommentCount == self.maxCommentCount:
         self.commentsTree.sortByColumn(0, Qt.AscendingOrder)
         self.commentsTree.expandAll()
         self.stackedWidget.setCurrentWidget(self.commentsTree)
开发者ID:Longhanks,项目名称:QHN,代码行数:19,代码来源:storywidget.py

示例9: update_debug_inspector

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import appendRow [as 别名]
 def update_debug_inspector(self, locals_dict):
     """
     Given the contents of a dict representation of the locals in the
     current stack frame, update the debug inspector with the new values.
     """
     excluded_names = ['__builtins__', '__debug_code__',
                       '__debug_script__', ]
     names = sorted([x for x in locals_dict if x not in excluded_names])
     self.debug_model.clear()
     self.debug_model.setHorizontalHeaderLabels([_('Name'), _('Value'), ])
     for name in names:
         try:
             # DANGER!
             val = eval(locals_dict[name])
         except Exception:
             val = None
         if isinstance(val, list):
             # Show a list consisting of rows of position/value
             list_item = QStandardItem(name)
             for i, i_val in enumerate(val):
                 list_item.appendRow([
                     QStandardItem(str(i)),
                     QStandardItem(repr(i_val))
                 ])
             self.debug_model.appendRow([
                 list_item,
                 QStandardItem(_('(A list of {} items.)').format(len(val)))
             ])
         elif isinstance(val, dict):
             # Show a dict consisting of rows of key/value pairs.
             dict_item = QStandardItem(name)
             for k, k_val in val.items():
                 dict_item.appendRow([
                     QStandardItem(repr(k)),
                     QStandardItem(repr(k_val))
                 ])
             self.debug_model.appendRow([
                 dict_item,
                 QStandardItem(_('(A dict of {} items.)').format(len(val)))
             ])
         else:
             self.debug_model.appendRow([
                 QStandardItem(name),
                 QStandardItem(locals_dict[name]),
             ])
开发者ID:lordmauve,项目名称:mu,代码行数:47,代码来源:main.py

示例10: populate

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import appendRow [as 别名]
 def populate(self, file_info=None, db_file=None):
     if file_info is not None:
         self.file_info = file_info
         db_file = FileInspectorHelper.get_or_insert_file(file_info)
     self.model.clear()
     if db_file:
         for classe in db_file.classes:
             parent = QStandardItem("{0}:".format(classe.name))
             for method in classe.methods:
                 parent.appendRow(QStandardItem("{0}()".\
                     format(method.name)))
             self.model.appendRow(parent)
         for function in db_file.functions:
             self.model.appendRow(QStandardItem("{0}()".\
                 format(function.name)))
     
     name = db_file.name if db_file else file_info.fileName()
     header = QStandardItem(name)
     self.model.setHorizontalHeaderItem(0, header)
     self.expandAll()
开发者ID:lheido,项目名称:Mojuru,代码行数:22,代码来源:file_inspector.py

示例11: fill_tree

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import appendRow [as 别名]
    def fill_tree(self, children: List[FsFileInfo]) -> None:

        self.item.removeRows(0, self.item.rowCount())
        for child in self.tree.sort_children(children):
            subitem = QStandardItem(child.get_label())
            if child.checkable():
                subitem.setCheckable(True)
                subitem.setCheckState(True)
                subitem.setTristate(True)
                subitem.setCheckState(child.state)
            subitem.setEnabled(child.enable())
            subitem.setSelectable(child.selectable())
            subitem.setEditable(False)
            subitem.setData(QVariant(child), Qt.UserRole)

            if child.folderish():
                # Add "Loading..." entry in advance for when the user
                # will click to expand it.
                loaditem = QStandardItem(Translator.get("LOADING"))
                loaditem.setSelectable(False)
                subitem.appendRow(loaditem)

            self.item.appendRow(subitem)
开发者ID:nuxeo,项目名称:nuxeo-drive,代码行数:25,代码来源:folders_treeview.py

示例12: fillParameterTree

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import appendRow [as 别名]
 def fillParameterTree(self):
     rows = self.parameterModel.rowCount()
     if rows:
         while self.parameterModel.rowCount() > 0:
             self.parameterModel.removeRow(0)
     self.parameterList = []
     parameterStr = 'self.stack['
     
     for i, layer in enumerate(self.stack):
         parameterStr += '{}].'.format(i)
         layerBranch = QStandardItem(layer.name)
         self.root.appendRow(layerBranch)
         self.addTreeEntry(layerBranch, 'thickness (nm)',  layer.thickness, self.changeThickness)
         if layer.srough:
             self.addTreeEntry(layerBranch, 'thickness roughness layer (nm)', layer.sroughThickness, self.changeSroughThickness)
             self.addTreeEntry(layerBranch, 'Haze R', layer.sroughHazeR, self.changeSroughHazeR)
             self.addTreeEntry(layerBranch, 'Haze T', layer.sroughHazeT, self.changeSroughHazeT)
         if layer.criSource=='constant':
             self.addTreeEntry(layerBranch, 'constant n', layer.criConstant[0], self.changeConstantn)
             self.addTreeEntry(layerBranch, 'constant k', layer.criConstant[1], self.changeConstantk)
         if layer.criSource=='graded' and layer.criGrading['mode']=='constant':
             self.addTreeEntry(layerBranch, 'constant grading', layer.criGrading['value'], self.changeConstantGrading)
         if layer.criSource=='dielectric function':
             criBranch = QStandardItem('dielectric function parameters')
             layerBranch.appendRow(criBranch)
             self.addTreeEntry(criBranch, 'e0', layer.dielectricFunction['e0'],  self.changeConstante, level = 2)
             for idx, oscillator in enumerate(layer.dielectricFunction['oscillators']):
                 osciBranch = QStandardItem('{} {}'.format(idx, oscillator['name']))
                 criBranch.appendRow(osciBranch)
                 parameterNames = MODELS[oscillator['name']]['parameter']
                 for i, value in enumerate(oscillator['values']):
                     self.addTreeEntry(osciBranch, parameterNames[i], value, self.changeOscillator, level = 3)
         if layer.collection['source'] == 'from collection function' and layer.collection['mode'] == 'constant':
             self.addTreeEntry(layerBranch, 'constant collection efficiency', layer.collection['value'], self.changeConstantCollection)
         if layer.collection['source'] == 'from diffusion length':
             collectionBranch = QStandardItem('collection model')
             layerBranch.appendRow(collectionBranch)
             self.addTreeEntry(collectionBranch, 'space charge region width (nm)', layer.collection['SCRwidth'],  self.changeSCR, level = 2)
             self.addTreeEntry(collectionBranch, 'diffusion length (nm)', layer.collection['diffLength'], self.changeDiffL, level = 2)
             self.addTreeEntry(collectionBranch, 'recombination velocity (cm/s)', layer.collection['recVel'], self.changerecVel, level = 2)
     
     self.parameterTreeView.setColumnWidth(1, 80)
     self.parameterTreeView.header().setSectionResizeMode(QHeaderView.ResizeToContents)
     self.parameterTreeView.expandAll()
开发者ID:MiRichter,项目名称:OptiSim,代码行数:46,代码来源:fitting_advanced.py

示例13: populate

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import appendRow [as 别名]
    def populate(self, data):
        """Populate the data model using the data passed
        from the extensions object.

        The data model has up to three root-level items:
        - Invalid metadata
        - Failed to load
        - Failed dependencies
        """

        # font for use in various Items
        bold = QFont()
        bold.setWeight(QFont.Bold)

        root = self.invisibleRootItem()
        infos = data['infos']
        if infos:
            # Handle extensions with metadata errors
            infos_item = QStandardItem()
            infos_item.setFont(bold)
            infos_item.setText(_("Invalid metadata:"))
            infos_tooltip = (
                _("Extensions whose extension.cnf file has errors.\n"
                  "They will be loaded nevertheless."))
            infos_item.setToolTip(infos_tooltip)

            root.appendRow(infos_item)
            for info in infos:
                name_item = QStandardItem(info)
                name_item.setToolTip(infos_tooltip)
                icon = self.extensions.icon(info)
                if icon:
                    name_item.setIcon(icon)
                details_item = QStandardItem(infos[info])
                details_item.setToolTip(infos_tooltip)
                infos_item.appendRow([name_item, details_item])

        exceptions = data['exceptions']
        if exceptions:
            # Handle extensions that failed to load properly
            import traceback
            exceptions_item = self.exceptions_item = QStandardItem()
            exceptions_item.setFont(bold)
            exceptions_item.setText(_("Failed to load:"))
            extensions_tooltip = (
                _("Extensions that failed to load properly.\n"
                  "Double click on name to show the stacktrace.\n"
                  "Please contact the extension maintainer."))
            exceptions_item.setToolTip(extensions_tooltip)

            root.appendRow(exceptions_item)
            for ext in exceptions:
                extension_info = self.extensions.infos(ext)
                name = (extension_info.get('extension-name', ext)
                    if extension_info
                    else ext)
                name_item = QStandardItem(name)
                name_item.setToolTip(extensions_tooltip)
                icon = self.extensions.icon(ext)
                if icon:
                    name_item.setIcon(icon)
                exc_info = exceptions[ext]
                # store exception information in the first item
                name_item.exception_info = exc_info
                message = '{}: {}'.format(exc_info[0].__name__, exc_info[1])
                details_item = QStandardItem(message)
                details_item.setToolTip(extensions_tooltip)
                exceptions_item.appendRow([name_item, details_item])

        dependencies = data['dependencies']
        if dependencies:
            # Handle extensions with dependency issues
            dep_item = QStandardItem(_("Failed dependencies:"))
            dep_item.setFont(bold)
            dep_tooltip = (
                _("Extensions with failed or circular dependencies.\n"
                  "They are not loaded."))
            dep_item.setToolTip(dep_tooltip)

            root.appendRow(dep_item)
            missing = dependencies.get('missing', None)
            if missing:
                missing_item = QStandardItem(_("Missing:"))
                missing_item.setFont(bold)
                missing_item.setToolTip(dep_tooltip)
                dep_item.appendRow(missing_item)
                for m in missing:
                    item = QStandardItem(m)
                    item.setToolTip(dep_item)
                    missing_item.appendRow(item)
            inactive = dependencies.get('inactive', None)
            if inactive:
                inactive_item = QStandardItem(_("Inactive:"))
                inactive_item.setFont(bold)
                inactive_item.setToolTip(dep_tooltip)
                dep_item.appendRow(inactive_item)
                for i in inactive:
                    item = QStandardItem(i)
                    item.setToolTip(dep_tooltip)
                    inactive_item.appendRow(item)
#.........这里部分代码省略.........
开发者ID:wbsoft,项目名称:frescobaldi,代码行数:103,代码来源:__init__.py

示例14: loadProject

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import appendRow [as 别名]
def loadProject(project, zip=None):
    """
    Loads a project.
    @param project: the filename of the project to open.
    @param zip: whether the project is a zipped or not.
    @return: an array of errors, empty if None.
    """

    mw = mainWindow()
    errors = []

    ####################################################################################################################
    # Read and store everything in a dict

    log("\nLoading {} ({})".format(project, "ZIP" if zip else "not zip"))
    if zip:
        files = loadFilesFromZip(project)

        # Decode files
        for f in files:
            if f[-4:] not in [".xml", "opml"]:
                files[f] = files[f].decode("utf-8")

    else:
        # Project path
        dir = os.path.dirname(project)

        # Folder containing file: name of the project file (without .msk extension)
        folder = os.path.splitext(os.path.basename(project))[0]

        # The full path towards the folder containing files
        path = os.path.join(dir, folder, "")

        files = {}
        for dirpath, dirnames, filenames in os.walk(path):
            p = dirpath.replace(path, "")
            for f in filenames:
                # mode = "r" + ("b" if f[-4:] in [".xml", "opml"] else "")
                if f[-4:] in [".xml", "opml"]:
                    with open(os.path.join(dirpath, f), "rb") as fo:
                        files[os.path.join(p, f)] = fo.read()
                else:
                    with open(os.path.join(dirpath, f), "r", encoding="utf8") as fo:
                        files[os.path.join(p, f)] = fo.read()

        # Saves to cache (only if we loaded from disk and not zip)
        global cache
        cache = files
        
        # FIXME: watch directory for changes

    # Sort files by keys
    files = OrderedDict(sorted(files.items()))

    ####################################################################################################################
    # Settings

    if "settings.txt" in files:
        settings.load(files["settings.txt"], fromString=True, protocol=0)
    else:
        errors.append("settings.txt")

    # Just to be sure
    settings.saveToZip = zip

    ####################################################################################################################
    # Labels

    mdl = mw.mdlLabels
    mdl.appendRow(QStandardItem(""))  # Empty = No labels
    if "labels.txt" in files:
        log("\nReading labels:")
        for s in files["labels.txt"].split("\n"):
            if not s:
                continue

            m = re.search(r"^(.*?):\s*(.*)$", s)
            txt = m.group(1)
            col = m.group(2)
            log("* Add status: {} ({})".format(txt, col))
            icon = iconFromColorString(col)
            mdl.appendRow(QStandardItem(icon, txt))

    else:
        errors.append("labels.txt")

    ####################################################################################################################
    # Status

    mdl = mw.mdlStatus
    mdl.appendRow(QStandardItem(""))  # Empty = No status
    if "status.txt" in files:
        log("\nReading Status:")
        for s in files["status.txt"].split("\n"):
            if not s:
                continue
            log("* Add status:", s)
            mdl.appendRow(QStandardItem(s))
    else:
        errors.append("status.txt")
#.........这里部分代码省略.........
开发者ID:TenKeyAngle,项目名称:manuskript,代码行数:103,代码来源:version_1.py

示例15: __updateSlotsModel

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import appendRow [as 别名]
 def __updateSlotsModel(self):
     """
     Private slot to update the slots tree display.
     """
     self.filterEdit.clear()
     
     try:
         dlg = uic.loadUi(
             self.formFile, package=self.project.getProjectPath())
         objects = dlg.findChildren(QWidget) + dlg.findChildren(QAction)
         
         signatureList = self.__signatures()
         
         self.slotsModel.clear()
         self.slotsModel.setHorizontalHeaderLabels([""])
         for obj in objects:
             name = obj.objectName()
             if not name or name.startswith("qt_"):
                 # ignore un-named or internal objects
                 continue
             
             metaObject = obj.metaObject()
             className = metaObject.className()
             itm = QStandardItem("{0} ({1})".format(name, className))
             self.slotsModel.appendRow(itm)
             for index in range(metaObject.methodCount()):
                 metaMethod = metaObject.method(index)
                 if metaMethod.methodType() == QMetaMethod.Signal:
                     if qVersion() >= "5.0.0":
                         itm2 = QStandardItem("on_{0}_{1}".format(
                             name,
                             bytes(metaMethod.methodSignature()).decode()))
                     else:
                         itm2 = QStandardItem("on_{0}_{1}".format(
                             name, metaMethod.signature()))
                     itm.appendRow(itm2)
                     if self.__module is not None:
                         if qVersion() >= "5.0.0":
                             method = "on_{0}_{1}".format(
                                 name,
                                 bytes(metaMethod.methodSignature())
                                 .decode().split("(")[0])
                         else:
                             method = "on_{0}_{1}".format(
                                 name, metaMethod.signature().split("(")[0])
                         method2 = "{0}({1})".format(
                             method, ", ".join(
                                 [self.__mapType(t)
                                  for t in metaMethod.parameterTypes()]))
                         
                         if method2 in signatureList or \
                                 method in signatureList:
                             itm2.setFlags(Qt.ItemFlags(Qt.ItemIsEnabled))
                             itm2.setCheckState(Qt.Checked)
                             itm2.setForeground(QBrush(Qt.blue))
                             continue
                     
                     returnType = self.__mapType(
                         metaMethod.typeName().encode())
                     if returnType == 'void':
                         returnType = ""
                     parameterTypesList = [
                         self.__mapType(t)
                         for t in metaMethod.parameterTypes()]
                     pyqtSignature = ", ".join(parameterTypesList)
                     
                     parameterNames = metaMethod.parameterNames()
                     if parameterNames:
                         for index in range(len(parameterNames)):
                             if not parameterNames[index]:
                                 parameterNames[index] = \
                                     QByteArray("p{0:d}".format(index)
                                                .encode("utf-8"))
                     parameterNamesList = [bytes(n).decode()
                                           for n in parameterNames]
                     methNamesSig = ", ".join(parameterNamesList)
                     
                     if methNamesSig:
                         if qVersion() >= "5.0.0":
                             pythonSignature = \
                                 "on_{0}_{1}(self, {2})".format(
                                     name,
                                     bytes(metaMethod.methodSignature())
                                     .decode().split("(")[0],
                                     methNamesSig)
                         else:
                             pythonSignature = \
                                 "on_{0}_{1}(self, {2})".format(
                                     name,
                                     metaMethod.signature().split("(")[0],
                                     methNamesSig)
                     else:
                         if qVersion() >= "5.0.0":
                             pythonSignature = "on_{0}_{1}(self)".format(
                                 name,
                                 bytes(metaMethod.methodSignature())
                                 .decode().split("(")[0])
                         else:
                             pythonSignature = "on_{0}_{1}(self)".format(
                                 name,
#.........这里部分代码省略.........
开发者ID:testmana2,项目名称:test,代码行数:103,代码来源:CreateDialogCodeDialog.py


注:本文中的PyQt5.QtGui.QStandardItem.appendRow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。