• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python QtGui.QTreeWidgetItem类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: create_dir_item

 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,代码行数:9,代码来源:findinfiles.py


示例2: populate_classes

 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,代码行数:12,代码来源:outlineexplorer.py


示例3: populate_methods

 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,代码行数:16,代码来源:outlineexplorer.py


示例4: __init__

 def __init__(self, name, line, parent, preceding):
     if preceding is None:
         QTreeWidgetItem.__init__(self, parent, QTreeWidgetItem.Type)
     else:
         if preceding is not parent:
             # Preceding must be either the same as item's parent
             # or have the same parent as item
             while preceding.parent() is not parent:
                 preceding = preceding.parent()
                 if preceding is None:
                     break
         if preceding is None:
             QTreeWidgetItem.__init__(self, parent, QTreeWidgetItem.Type)
         else:
             QTreeWidgetItem.__init__(self, parent, preceding, QTreeWidgetItem.Type)
     self.setText(0, name)
     parent_text = from_qvariant(parent.data(0, Qt.UserRole), to_text_string)
     set_item_user_text(self, parent_text + "/" + name)
     self.line = line
开发者ID:MarvinLiu0810,项目名称:spyder,代码行数:19,代码来源:editortools.py


示例5: __init__

 def __init__(self, path, treewidget):
     QTreeWidgetItem.__init__(self, treewidget, QTreeWidgetItem.Type)
     self.path = path
     self.setIcon(0, get_icon('python.png'))
     self.setToolTip(0, path)
     set_item_user_text(self, path)
开发者ID:jromang,项目名称:retina-old,代码行数:6,代码来源:editortools.py


示例6: refresh

    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,代码行数:101,代码来源:findinfiles.py


示例7: populate_tree

    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,代码行数:49,代码来源:profilergui.py


示例8: __init__

 def __init__(self, parent=None):
     QTreeWidgetItem.__init__(self, parent)
开发者ID:ymarfoq,项目名称:outilACVDesagregation,代码行数:2,代码来源:profilergui.py


示例9: refresh

 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,代码行数:56,代码来源:pylintgui.py


示例10: populate_tree

    def populate_tree(self):
        """Create each item (and associated data) in the tree"""
        if not self.stats:
            warn_item = QTreeWidgetItem(self)
            warn_item.setData(
                0, Qt.DisplayRole,
                _('No timings to display. '
                  'Did you forget to add @profile decorators ?')
                .format(url=WEBSITE_URL))
            warn_item.setFirstColumnSpanned(True)
            warn_item.setTextAlignment(0, Qt.AlignCenter)
            font = warn_item.font(0)
            font.setStyle(QFont.StyleItalic)
            warn_item.setFont(0, font)
            return

        try:
            monospace_font = self.window().editor.get_plugin_font()
        except AttributeError:  # If run standalone for testing
            monospace_font = QFont("Courier New")
            monospace_font.setPointSize(10)

        for func_info, func_data in self.stats.items():
            # Function name and position
            filename, start_line_no, func_name = func_info
            func_stats, func_peak_usage = func_data
            func_item = QTreeWidgetItem(self)
            func_item.setData(
                0, Qt.DisplayRole,
                _('{func_name} (peak {peak_usage:.3f} MiB) in file "{filename}", '
                  'line {line_no}').format(
                    filename=filename,
                    line_no=start_line_no,
                    func_name=func_name,
                    peak_usage=func_peak_usage))
            func_item.setFirstColumnSpanned(True)
            func_item.setData(COL_POS, Qt.UserRole,
                              (osp.normpath(filename), start_line_no))

            # For sorting by time
            func_item.setData(COL_USAGE, Qt.DisplayRole, func_peak_usage)
            func_item.setData(COL_INCREMENT, Qt.DisplayRole,
                              func_peak_usage)

            if self.parent().use_colors:
                # Choose deteministic unique color for the function
                md5 = hashlib.md5((filename + func_name).encode("utf8")).hexdigest()
                hue = (int(md5[:2], 16) - 68) % 360  # avoid blue (unreadable)
                func_color = QColor.fromHsv(hue, 200, 255)
            else:
                # Red color only
                func_color = QColor.fromRgb(255, 0, 0)

            # get max increment
            max_increment = 0
            for line_info in func_stats:
                (line_no, code_line, usage, increment) = line_info
                if increment is not None:
                    max_increment = max(max_increment, increment)

            # Lines of code
            for line_info in func_stats:
                line_item = QTreeWidgetItem(func_item)
                (line_no, code_line, usage, increment) = line_info
                self.fill_item(
                    line_item, filename, line_no, code_line,
                    usage, increment)

                # Color background
                if increment is not None:
                    alpha = increment / max_increment if max_increment != 0 else 0
                    color = QColor(func_color)
                    color.setAlphaF(alpha)  # Returns None
                    color = QBrush(color)
                    for col in range(self.columnCount()):
                        line_item.setBackground(col, color)
                else:

                    for col in range(self.columnCount()):
                        line_item.setForeground(col, CODE_NOT_RUN_COLOR)

                # Monospace font for code
                line_item.setFont(COL_LINE, monospace_font)
开发者ID:Nodd,项目名称:spyder_line_profiler,代码行数:83,代码来源:memoryprofilergui.py


示例11: refresh

 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,代码行数:52,代码来源:pylintgui.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python QtGui.QVBoxLayout类代码示例发布时间:2022-05-27
下一篇:
Python QtGui.QToolTip类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap