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


Python QTreeWidgetItem.setIcon方法代码示例

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


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

示例1: __init__

# 需要导入模块: from PyQt4.Qt import QTreeWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTreeWidgetItem import setIcon [as 别名]
    def __init__(self, window, msg, formats):
        '''
        formats is a list of tuples: [(format, exists, convertible)].
            format: Lower case format identifier. E.G. mobi
            exists: String representing the number of books that
                    exist in the format.
            convertible: True if the format is a convertible format.
        formats should be ordered in the device's preferred format ordering.
        '''
        QDialog.__init__(self, window)
        Ui_ChooseFormatDeviceDialog.__init__(self)
        self.setupUi(self)
        self.formats.activated[QModelIndex].connect(self.activated_slot)

        self.msg.setText(msg)
        for i, (format, exists, convertible) in enumerate(formats):
            t_item = QTreeWidgetItem()
            t_item.setIcon(0, file_icon_provider().icon_from_ext(format.lower()))
            t_item.setText(0, format.upper())
            t_item.setText(1, exists)
            if convertible:
                t_item.setIcon(2, QIcon(I('ok.png')))
            self.formats.addTopLevelItem(t_item)
            if i == 0:
                self.formats.setCurrentItem(t_item)
                t_item.setSelected(True)
        self.formats.resizeColumnToContents(2)
        self.formats.resizeColumnToContents(1)
        self.formats.resizeColumnToContents(0)
        self.formats.header().resizeSection(0, self.formats.header().sectionSize(0) * 2)
        self._format = None
开发者ID:Hainish,项目名称:calibre,代码行数:33,代码来源:choose_format_device.py

示例2: create_folder

# 需要导入模块: from PyQt4.Qt import QTreeWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTreeWidgetItem import setIcon [as 别名]
 def create_folder(self, item):
     text, ok = QInputDialog.getText(self, _('Folder name'), _('Enter a name for the new folder'))
     if ok and unicode(text):
         c = QTreeWidgetItem(item, (unicode(text),))
         c.setIcon(0, QIcon(I('mimetypes/dir.png')))
         for item in self.folders.selectedItems():
             item.setSelected(False)
         c.setSelected(True)
         self.folders.setCurrentItem(c)
开发者ID:FaustXVI,项目名称:calibre,代码行数:11,代码来源:insert_resource.py

示例3: setOpen

# 需要导入模块: from PyQt4.Qt import QTreeWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTreeWidgetItem import setIcon [as 别名]
    def setOpen(self, o):
        if  o: 
            self.setIcon(0, folderOpenIcon)
        else:
            self.setIcon(0, folderClosedIcon)

        if o and not self.childCount():
            s = self.fullName()
            thisDir = QDir(s)
            if not thisDir.isReadable():
                self.readable = 0
                return

            files = thisDir.entryInfoList()
            if files:
                for f in files:
                    # f is a QFileInfo
                    # f.fileName is '.' or '..' or 'bearings' or...
                    fileName = str(f.fileName())
                    if fileName == '.' or fileName == '..':
                        continue
                    elif f.isSymLink():
                        d = QTreeWidgetItem(self, fileName)#, 'Symbolic Link')
                        d.setIcon(0, fileIcon)
                    elif f.isDir():
                        if fileName == 'CVS':
                            #bruce 060319 skip CVS directories, so developers see same set of directories as end-users
                            # (implements NFR I recently reported)
                            # WARNING: this is only legitimate for some applications of this module.
                            # For now that's ok (we only use it in MMKit). Later this feature should be turned on
                            # by an optional argument to __init__, and generalized to a list of files to not show
                            # or to a filter function.
                            continue
                        d = Directory(self, fileName)
                    else:
                        if f.isFile():
                            s = 'File'
                        else:
                            s = 'Special'
                        if not fileName[-3:] in self.filterList:
                            continue
                        d = FileItem(self, f.absFilePath(), fileName)
                        d.setIcon(0, fileIcon)
    
        qt4todo('QTreeWidgetItem.setOpen(self, o)')
开发者ID:ematvey,项目名称:NanoEngineer-1,代码行数:47,代码来源:DirView.py

示例4: build

# 需要导入模块: from PyQt4.Qt import QTreeWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTreeWidgetItem import setIcon [as 别名]
    def build(self, container):
        self.clear()
        self.root = self.invisibleRootItem()
        self.root.setFlags(Qt.ItemIsDragEnabled)
        self.categories = {}
        for category, text, icon in (
            ('text', _('Text'), 'keyboard-prefs.png'),
            ('styles', _('Styles'), 'lookfeel.png'),
            ('images', _('Images'), 'view-image.png'),
            ('fonts', _('Fonts'), 'font.png'),
            ('misc', _('Miscellaneous'), 'mimetypes/dir.png'),
        ):
            self.categories[category] = i = QTreeWidgetItem(self.root, 0)
            i.setText(0, text)
            i.setIcon(0, QIcon(I(icon)))
            f = i.font(0)
            f.setBold(True)
            i.setFont(0, f)
            i.setData(0, NAME_ROLE, category)
            flags = Qt.ItemIsEnabled
            if category == 'text':
                flags |= Qt.ItemIsDropEnabled
            i.setFlags(flags)

        processed, seen = set(), {}

        def get_display_name(name, item):
            parts = name.split('/')
            text = parts[-1]
            while text in seen and parts:
                text = parts.pop() + '/' + text
            seen[text] = item
            return text

        for name, linear in container.spine_names:
            processed.add(name)
            i = QTreeWidgetItem(self.categories['text'], 1)
            prefix = '' if linear else '[nl] '
            if not linear:
                i.setIcon(self.non_linear_icon)
            i.setText(0, prefix + get_display_name(name, i))
            i.setStatusTip(0, _('Full path: ') + name)
            i.setFlags(Qt.ItemIsEnabled | Qt.ItemIsDragEnabled | Qt.ItemIsSelectable)
            i.setData(0, NAME_ROLE, name)

        font_types = {guess_type('a.'+x)[0] for x in ('ttf', 'otf', 'woff')}

        def get_category(mt):
            category = 'misc'
            if mt.startswith('image/'):
                category = 'images'
            elif mt in font_types:
                category = 'fonts'
            elif mt in OEB_STYLES:
                category = 'styles'
            return category

        all_files = list(container.manifest_type_map.iteritems())
        all_files.append((guess_type('a.opf')[0], [container.opf_name]))

        for name in container.name_path_map:
            if name in processed:
                continue
            processed.add(name)
            imt = container.mime_map.get(name, guess_type(name)[0])
            icat = get_category(imt)
            i = QTreeWidgetItem(self.categories[icat], 1)
            i.setText(0, get_display_name(name, i))
            i.setStatusTip(0, _('Full path: ') + name)
            i.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
            i.setData(0, NAME_ROLE, name)

        for c in self.categories.itervalues():
            self.expandItem(c)
开发者ID:shootstar,项目名称:calibre,代码行数:76,代码来源:file_list.py


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