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


Python QTreeWidgetItem.setIcon方法代码示例

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


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

示例1: create_dir_item

# 需要导入模块: from spyderlib.qt.QtGui import QTreeWidgetItem [as 别名]
# 或者: from spyderlib.qt.QtGui.QTreeWidgetItem import setIcon [as 别名]
 def create_dir_item(dirname, parent):
     if dirname not in root_path_list:
         displayed_name = osp.basename(dirname)
     else:
         displayed_name = dirname
     item = QTreeWidgetItem(parent, [displayed_name],
                            QTreeWidgetItem.Type)
     item.setIcon(0, ima.icon('DirClosedIcon'))
     return item
开发者ID:AminJamalzadeh,项目名称:spyder,代码行数:11,代码来源:findinfiles.py

示例2: populate_classes

# 需要导入模块: from spyderlib.qt.QtGui import QTreeWidgetItem [as 别名]
# 或者: from spyderlib.qt.QtGui.QTreeWidgetItem import setIcon [as 别名]
 def populate_classes(self):
     """Populate classes"""
     self.lines = {}
     for lineno, c_name, methods in self.classes:
         item = QTreeWidgetItem(self, [c_name], QTreeWidgetItem.Type)
         self.lines[item] = lineno
         if methods is None:
             item.setIcon(0, get_icon('function.png'))
         else:
             item.setIcon(0, get_icon('class.png'))
         if methods:
             self.populate_methods(item, c_name, methods)
开发者ID:jromang,项目名称:retina-old,代码行数:14,代码来源:outlineexplorer.py

示例3: populate_tree

# 需要导入模块: from spyderlib.qt.QtGui import QTreeWidgetItem [as 别名]
# 或者: from spyderlib.qt.QtGui.QTreeWidgetItem import setIcon [as 别名]
    def populate_tree(self, parentItem, children_list):
        """Recursive method to create each item (and associated data) in the tree."""
        for child_key in children_list:
            self.item_depth += 1
            (filename, line_number, function_name, file_and_line, node_type
             ) = self.function_info(child_key)
            (primcalls, total_calls, loc_time, cum_time, callers
             ) = self.stats[child_key]
            child_item = QTreeWidgetItem(parentItem)
            self.item_list.append(child_item)
            self.set_item_data(child_item, filename, line_number)

            # FIXME: indexes to data should be defined by a dictionary on init
            child_item.setToolTip(0, 'Function or module name')
            child_item.setData(0, Qt.DisplayRole, function_name)
            child_item.setIcon(0, get_icon(self.icon_list[node_type]))

            child_item.setToolTip(1, _('Time in function '\
                                       '(including sub-functions)'))
            #child_item.setData(1, Qt.DisplayRole, cum_time)
            child_item.setData(1, Qt.DisplayRole, '%.3f' % cum_time)
            child_item.setTextAlignment(1, Qt.AlignCenter)

            child_item.setToolTip(2, _('Local time in function '\
                                      '(not in sub-functions)'))
            #child_item.setData(2, Qt.DisplayRole, loc_time)
            child_item.setData(2, Qt.DisplayRole, '%.3f' % loc_time)
            child_item.setTextAlignment(2, Qt.AlignCenter)

            child_item.setToolTip(3, _('Total number of calls '\
                                       '(including recursion)'))
            child_item.setData(3, Qt.DisplayRole, total_calls)
            child_item.setTextAlignment(3, Qt.AlignCenter)

            child_item.setToolTip(4, _('File:line '\
                                       'where function is defined'))
            child_item.setData(4, Qt.DisplayRole, file_and_line)
            #child_item.setExpanded(True)
            if self.is_recursive(child_item):
                child_item.setData(4, Qt.DisplayRole, '(%s)' % _('recursion'))
                child_item.setDisabled(True)
            else:
                callees = self.find_callees(child_key)
                if self.item_depth < 3:
                    self.populate_tree(child_item, callees)
                elif callees:
                    child_item.setChildIndicatorPolicy(child_item.ShowIndicator)
                    self.items_to_be_shown[id(child_item)] = callees
            self.item_depth -= 1
开发者ID:alfonsodiecko,项目名称:PYTHON_DIST,代码行数:51,代码来源:profilergui.py

示例4: populate_methods

# 需要导入模块: from spyderlib.qt.QtGui import QTreeWidgetItem [as 别名]
# 或者: from spyderlib.qt.QtGui.QTreeWidgetItem import setIcon [as 别名]
 def populate_methods(self, parent, c_name, methods):
     """Populate methods"""
     for lineno, m_name in methods:
         decorator = m_name.startswith('@')
         if decorator:
             m_name = m_name[1:]
         item = QTreeWidgetItem(parent, [m_name], QTreeWidgetItem.Type)
         self.lines[item] = lineno
         if m_name.startswith('__'):
             item.setIcon(0, get_icon('private2.png'))
         elif m_name.startswith('_'):
             item.setIcon(0, get_icon('private1.png'))
         elif decorator:
             item.setIcon(0, get_icon('decorator.png'))
         else:
             item.setIcon(0, get_icon('method.png'))
开发者ID:jromang,项目名称:retina-old,代码行数:18,代码来源:outlineexplorer.py

示例5: refresh

# 需要导入模块: from spyderlib.qt.QtGui import QTreeWidgetItem [as 别名]
# 或者: from spyderlib.qt.QtGui.QTreeWidgetItem import setIcon [as 别名]
 def refresh(self):
     title = _('Results for ')+self.filename
     self.set_title(title)
     self.clear()
     self.data = {}
     # Populating tree
     results = ((_('Convention'),
                ima.icon('convention'), self.results['C:']),
                (_('Refactor'),
                ima.icon('refactor'), self.results['R:']),
                (_('Warning'),
                ima.icon('warning'), self.results['W:']),
                (_('Error'),
                ima.icon('error'), self.results['E:']))
     for title, icon, messages in results:
         title += ' (%d message%s)' % (len(messages),
                                       's' if len(messages)>1 else '')
         title_item = QTreeWidgetItem(self, [title], QTreeWidgetItem.Type)
         title_item.setIcon(0, icon)
         if not messages:
             title_item.setDisabled(True)
         modules = {}
         for module, lineno, message, msg_id in messages:
             basename = osp.splitext(osp.basename(self.filename))[0]
             if not module.startswith(basename):
                 # Pylint bug
                 i_base = module.find(basename)
                 module = module[i_base:]
             dirname = osp.dirname(self.filename)
             if module.startswith('.') or module == basename:
                 modname = osp.join(dirname, module)
             else:
                 modname = osp.join(dirname, *module.split('.'))
             if osp.isdir(modname):
                 modname = osp.join(modname, '__init__')
             for ext in ('.py', '.pyw'):
                 if osp.isfile(modname+ext):
                     modname = modname + ext
                     break
             if osp.isdir(self.filename):
                 parent = modules.get(modname)
                 if parent is None:
                     item = QTreeWidgetItem(title_item, [module],
                                            QTreeWidgetItem.Type)
                     item.setIcon(0, ima.icon('python'))
                     modules[modname] = item
                     parent = item
             else:
                 parent = title_item
             if len(msg_id) > 1:
                 text = "[%s] %d : %s" % (msg_id, lineno, message)
             else:
                 text = "%d : %s" % (lineno, message)
             msg_item = QTreeWidgetItem(parent, [text], QTreeWidgetItem.Type)
             msg_item.setIcon(0, ima.icon('arrow'))
             self.data[id(msg_item)] = (modname, lineno)
开发者ID:gyenney,项目名称:Tools,代码行数:58,代码来源:pylintgui.py

示例6: refresh

# 需要导入模块: from spyderlib.qt.QtGui import QTreeWidgetItem [as 别名]
# 或者: from spyderlib.qt.QtGui.QTreeWidgetItem import setIcon [as 别名]
 def refresh(self):
     title = _("Results for ") + self.filename
     self.set_title(title)
     self.clear()
     self.data = {}
     # Populating tree
     results = (
         (_("Convention"), ima.icon("convention"), self.results["C:"]),
         (_("Refactor"), ima.icon("refactor"), self.results["R:"]),
         (_("Warning"), ima.icon("warning"), self.results["W:"]),
         (_("Error"), ima.icon("error"), self.results["E:"]),
     )
     for title, icon, messages in results:
         title += " (%d message%s)" % (len(messages), "s" if len(messages) > 1 else "")
         title_item = QTreeWidgetItem(self, [title], QTreeWidgetItem.Type)
         title_item.setIcon(0, icon)
         if not messages:
             title_item.setDisabled(True)
         modules = {}
         for module, lineno, message, msg_id in messages:
             basename = osp.splitext(osp.basename(self.filename))[0]
             if not module.startswith(basename):
                 # Pylint bug
                 i_base = module.find(basename)
                 module = module[i_base:]
             dirname = osp.dirname(self.filename)
             if module.startswith(".") or module == basename:
                 modname = osp.join(dirname, module)
             else:
                 modname = osp.join(dirname, *module.split("."))
             if osp.isdir(modname):
                 modname = osp.join(modname, "__init__")
             for ext in (".py", ".pyw"):
                 if osp.isfile(modname + ext):
                     modname = modname + ext
                     break
             if osp.isdir(self.filename):
                 parent = modules.get(modname)
                 if parent is None:
                     item = QTreeWidgetItem(title_item, [module], QTreeWidgetItem.Type)
                     item.setIcon(0, ima.icon("python"))
                     modules[modname] = item
                     parent = item
             else:
                 parent = title_item
             if len(msg_id) > 1:
                 text = "[%s] %d : %s" % (msg_id, lineno, message)
             else:
                 text = "%d : %s" % (lineno, message)
             msg_item = QTreeWidgetItem(parent, [text], QTreeWidgetItem.Type)
             msg_item.setIcon(0, ima.icon("arrow"))
             self.data[id(msg_item)] = (modname, lineno)
开发者ID:ftsiadimos,项目名称:spyder,代码行数:54,代码来源:pylintgui.py

示例7: refresh

# 需要导入模块: from spyderlib.qt.QtGui import QTreeWidgetItem [as 别名]
# 或者: from spyderlib.qt.QtGui.QTreeWidgetItem import setIcon [as 别名]
    def refresh(self):
        """
        Refreshing search results panel
        """
        title = "'%s' - " % self.search_text
        if self.results is None:
            text = _('Search canceled')
        else:
            nb_files = len(self.results)
            if nb_files == 0:
                text = _('String not found')
            else:
                text_matches = _('matches in')
                text_files = _('file')
                if nb_files > 1:
                    text_files += 's'
                text = "%d %s %d %s" % (self.nb, text_matches,
                                        nb_files, text_files)
        if self.error_flag:
            text += ' (' + self.error_flag + ')'
        elif self.results is not None and not self.completed:
            text += ' (' + _('interrupted') + ')'
        self.set_title(title+text)
        self.clear()
        self.data = {}
        
        if not self.results: # First search interrupted *or* No result
            return

        # Directory set
        dir_set = set()
        for filename in sorted(self.results.keys()):
            dirname = osp.abspath(osp.dirname(filename))
            dir_set.add(dirname)
                
        # Root path
        root_path_list = None
        _common = get_common_path(list(dir_set))
        if _common is not None:
            root_path_list = [_common]
        else:
            _common = get_common_path(self.pathlist)
            if _common is not None:
                root_path_list = [_common]
            else:
                root_path_list = self.pathlist
        if not root_path_list:
            return
        for _root_path in root_path_list:
            dir_set.add(_root_path)
        # Populating tree: directories
        def create_dir_item(dirname, parent):
            if dirname not in root_path_list:
                displayed_name = osp.basename(dirname)
            else:
                displayed_name = dirname
            item = QTreeWidgetItem(parent, [displayed_name],
                                   QTreeWidgetItem.Type)
            item.setIcon(0, ima.icon('DirClosedIcon'))
            return item
        dirs = {}
        for dirname in sorted(list(dir_set)):
            if dirname in root_path_list:
                parent = self
            else:
                parent_dirname = abspardir(dirname)
                parent = dirs.get(parent_dirname)
                if parent is None:
                    # This is related to directories which contain found
                    # results only in some of their children directories
                    if osp.commonprefix([dirname]+root_path_list):
                        # create new root path
                        pass
                    items_to_create = []
                    while dirs.get(parent_dirname) is None:
                        items_to_create.append(parent_dirname)
                        parent_dirname = abspardir(parent_dirname)
                    items_to_create.reverse()
                    for item_dir in items_to_create:
                        item_parent = dirs[abspardir(item_dir)]
                        dirs[item_dir] = create_dir_item(item_dir, item_parent)
                    parent_dirname = abspardir(dirname)
                    parent = dirs[parent_dirname]
            dirs[dirname] = create_dir_item(dirname, parent)
        self.root_items = [dirs[_root_path] for _root_path in root_path_list]
        # Populating tree: files
        for filename in sorted(self.results.keys()):
            parent_item = dirs[osp.dirname(filename)]
            file_item = QTreeWidgetItem(parent_item, [osp.basename(filename)],
                                        QTreeWidgetItem.Type)
            file_item.setIcon(0, get_filetype_icon(filename))
            colno_dict = {}
            fname_res = []
            for lineno, colno, line in self.results[filename]:
                if lineno not in colno_dict:
                    fname_res.append((lineno, colno, line))
                colno_dict[lineno] = colno_dict.get(lineno, [])+[str(colno)]
            for lineno, colno, line in fname_res:
                colno_str = ",".join(colno_dict[lineno])
                item = QTreeWidgetItem(file_item,
#.........这里部分代码省略.........
开发者ID:AminJamalzadeh,项目名称:spyder,代码行数:103,代码来源:findinfiles.py


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