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


Python Qt.QTreeWidgetItem类代码示例

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


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

示例1: create_folder

 def create_folder(self, item):
     text, ok = QInputDialog.getText(self, _('Folder name'), _('Enter a name for the new folder'))
     if ok and unicode_type(text):
         c = QTreeWidgetItem(item, (unicode_type(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:JimmXinu,项目名称:calibre,代码行数:9,代码来源:insert_resource.py

示例2: __init__

 def __init__(self, parent, device):
     QTreeWidgetItem.__init__(self, parent)
     self._device = device
     self.setText(0, device.lvname)
     mountpoint = getattr(device.format, "mountpoint", "")
     if not mountpoint:
         mountpoint = ""
     elif not (device.format and device.format.mountable):
         mountpoint = "N/A"
     self.setText(1, mountpoint)
     self.setText(2, "%Ld" % device.size)
开发者ID:MusaSakizci,项目名称:yali-family,代码行数:11,代码来源:lvm_gui.py

示例3: create_item

 def create_item(self, f, parent):
     name = f.name
     ans = QTreeWidgetItem(parent, [name])
     ans.setData(0, Qt.UserRole, '/'.join(f.full_path[1:]))
     ans.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
     ans.setCheckState(0,
         Qt.Unchecked if self.dev.is_folder_ignored(f.storage_id, f.full_path[1:]) else Qt.Checked)
     ans.setData(0, Qt.DecorationRole, file_icon_provider().icon_from_ext('dir'))
     return ans
开发者ID:davidfor,项目名称:calibre,代码行数:9,代码来源:mtp_folder_browser.py

示例4: update_widget

    def update_widget(self, services):
        """
        Update the QTreeWidget and its items

        :param services: list of :class:`Services <alignak_app.items.service.Service>` items
        :type services: list
        """

        self.services = services

        # Update services dashboard
        self.services_dashboard.update_widget(self.services)

        # Clear QTreeWidget
        self.services_tree_widget.clear()
        self.services_tree_widget.setIconSize(QSize(16, 16))

        if self.services:
            # Set as "Global" aggregation who are empty
            for service in self.services:
                if not service.data['aggregation']:
                    service.data['aggregation'] = 'Global'

            # First sort list by state then by aggregation
            newlist = sorted(
                self.services,
                key=lambda s: itemgetter('ls_state', 'ls_acknowledged', 'aggregation')(s.data)
            )
            self.services = newlist

            # Get list of aggregations
            aggregations = []
            for service in self.services:
                if service.data['aggregation'] not in aggregations:
                    aggregations.append(service.data['aggregation'])

            # Add QTreeWidgetItems
            for aggregation in aggregations:
                main_tree = QTreeWidgetItem()
                main_tree.setText(0, aggregation)
                main_tree.setIcon(0, QIcon(settings.get_image('tree')))
                main_tree.setToolTip(0, aggregation)
                for service in self.services:
                    if service.data['aggregation'] == aggregation:
                        service_tree = ServiceTreeItem()
                        service_tree.initialize(service)
                        service_tree.setToolTip(0, service.get_tooltip())
                        self.services_tree_widget.clicked.connect(self.update_service_data)
                        main_tree.addChild(service_tree)

                self.services_tree_widget.addTopLevelItem(main_tree)

            self.service_data_widget.hide()
        else:
            # If no services, reset service item to None and hide data widget
            self.service_data_widget.service_item = None
            self.service_data_widget.hide()
开发者ID:Alignak-monitoring-contrib,项目名称:alignak-app,代码行数:57,代码来源:services.py

示例5: browser_item

def browser_item(f, parent):
    name = f.name
    if not f.is_folder:
        name += ' [%s]'%f.last_mod_string
    ans = QTreeWidgetItem(parent, [name])
    ans.setData(0, Qt.UserRole, f.full_path)
    if f.is_folder:
        ext = 'dir'
    else:
        ext = f.name.rpartition('.')[-1]
    ans.setData(0, Qt.DecorationRole, file_icon_provider().icon_from_ext(ext))

    return ans
开发者ID:davidfor,项目名称:calibre,代码行数:13,代码来源:mtp_folder_browser.py

示例6: setup_ui

    def setup_ui(self):
        self.l = l = QVBoxLayout(self)
        self.setLayout(l)

        self.msg = m = QLabel(self.msg or _(
        'Choose the folder into which the files will be placed'))
        l.addWidget(m)
        m.setWordWrap(True)

        self.folders = f = QTreeWidget(self)
        f.setHeaderHidden(True)
        f.itemDoubleClicked.connect(self.accept)
        l.addWidget(f)
        f.setContextMenuPolicy(Qt.CustomContextMenu)
        f.customContextMenuRequested.connect(self.show_context_menu)
        self.root = QTreeWidgetItem(f, ('/',))

        def process(node, parent):
            parent.setIcon(0, QIcon(I('mimetypes/dir.png')))
            for child in sorted(node, key=numeric_sort_key):
                c = QTreeWidgetItem(parent, (child,))
                process(node[child], c)
        process(create_folder_tree(current_container()), self.root)
        self.root.setSelected(True)
        f.expandAll()

        l.addWidget(self.bb)
开发者ID:JimmXinu,项目名称:calibre,代码行数:27,代码来源:insert_resource.py

示例7: process_node

 def process_node(toc, parent):
     for child in toc:
         node = QTreeWidgetItem(parent)
         node.setText(0, child.title or '')
         node.setData(0, DEST_ROLE, child.dest or '')
         node.setData(0, FRAG_ROLE, child.frag or '')
         tt = _('File: {0}\nAnchor: {1}').format(
             child.dest or '', child.frag or _('Top of file'))
         node.setData(0, Qt.ToolTipRole, tt)
         process_node(child, node)
开发者ID:JimmXinu,项目名称:calibre,代码行数:10,代码来源:toc.py

示例8: process_duplicates

    def process_duplicates(self, db, duplicates):
        ta = _('%(title)s by %(author)s [%(formats)s]')
        bf = QFont(self.dup_list.font())
        bf.setBold(True)
        itf = QFont(self.dup_list.font())
        itf.setItalic(True)

        for mi, cover, formats in duplicates:
            # formats is a list of file paths
            # Grab just the extension and display to the user
            # Based only off the file name, no file type tests are done.
            incoming_formats = ', '.join(os.path.splitext(path)[-1].replace('.', '').upper() for path in formats)
            item = QTreeWidgetItem([ta%dict(
                title=mi.title, author=mi.format_field('authors')[1],
                formats=incoming_formats)] , 0)
            item.setCheckState(0, Qt.Checked)
            item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsUserCheckable)
            item.setData(0, Qt.FontRole, bf)
            item.setData(0, Qt.UserRole, (mi, cover, formats))
            matching_books = db.books_with_same_title(mi)

            def add_child(text):
                c = QTreeWidgetItem([text], 1)
                c.setFlags(Qt.ItemIsEnabled)
                item.addChild(c)
                return c

            add_child(_('Already in calibre:')).setData(0, Qt.FontRole, itf)

            for book_id in matching_books:
                aut = [a.replace('|', ',') for a in (db.authors(book_id,
                    index_is_id=True) or '').split(',')]
                add_child(ta%dict(
                    title=db.title(book_id, index_is_id=True),
                    author=authors_to_string(aut),
                    formats=db.formats(book_id, index_is_id=True,
                                       verify_formats=False)))
            add_child('')

            yield item
开发者ID:JimmXinu,项目名称:calibre,代码行数:40,代码来源:duplicates.py

示例9: ChooseFolder

class ChooseFolder(Dialog):  # {{{

    def __init__(self, msg=None, parent=None):
        self.msg = msg
        Dialog.__init__(self, _('Choose folder'), 'choose-folder', parent=parent)

    def setup_ui(self):
        self.l = l = QVBoxLayout(self)
        self.setLayout(l)

        self.msg = m = QLabel(self.msg or _(
        'Choose the folder into which the files will be placed'))
        l.addWidget(m)
        m.setWordWrap(True)

        self.folders = f = QTreeWidget(self)
        f.setHeaderHidden(True)
        f.itemDoubleClicked.connect(self.accept)
        l.addWidget(f)
        f.setContextMenuPolicy(Qt.CustomContextMenu)
        f.customContextMenuRequested.connect(self.show_context_menu)
        self.root = QTreeWidgetItem(f, ('/',))

        def process(node, parent):
            parent.setIcon(0, QIcon(I('mimetypes/dir.png')))
            for child in sorted(node, key=numeric_sort_key):
                c = QTreeWidgetItem(parent, (child,))
                process(node[child], c)
        process(create_folder_tree(current_container()), self.root)
        self.root.setSelected(True)
        f.expandAll()

        l.addWidget(self.bb)

    def show_context_menu(self, point):
        item = self.folders.itemAt(point)
        if item is None:
            return
        m = QMenu(self)
        m.addAction(QIcon(I('mimetypes/dir.png')), _('Create new folder'), partial(self.create_folder, item))
        m.popup(self.folders.mapToGlobal(point))

    def create_folder(self, item):
        text, ok = QInputDialog.getText(self, _('Folder name'), _('Enter a name for the new folder'))
        if ok and unicode_type(text):
            c = QTreeWidgetItem(item, (unicode_type(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)

    def folder_path(self, item):
        ans = []
        while item is not self.root:
            ans.append(unicode_type(item.text(0)))
            item = item.parent()
        return tuple(reversed(ans))

    @property
    def chosen_folder(self):
        try:
            return '/'.join(self.folder_path(self.folders.selectedItems()[0]))
        except IndexError:
            return ''
开发者ID:JimmXinu,项目名称:calibre,代码行数:65,代码来源:insert_resource.py

示例10: unserialize_node

 def unserialize_node(dict_node, parent):
     n = QTreeWidgetItem(parent)
     n.setData(0, Qt.DisplayRole, dict_node['title'])
     n.setData(0, Qt.UserRole, dict_node['toc_node'])
     n.setFlags(NODE_FLAGS)
     n.setData(0, Qt.DecorationRole, dict_node['icon'])
     n.setData(0, Qt.ToolTipRole, dict_node['tooltip'])
     self.update_status_tip(n)
     n.setExpanded(dict_node['is_expanded'])
     n.setSelected(dict_node['is_selected'])
     for c in dict_node['children']:
         unserialize_node(c, n)
开发者ID:j-howell,项目名称:calibre,代码行数:12,代码来源:main.py

示例11: add_child

 def add_child(text):
     c = QTreeWidgetItem([text], 1)
     c.setFlags(Qt.ItemIsEnabled)
     item.addChild(c)
     return c
开发者ID:JimmXinu,项目名称:calibre,代码行数:5,代码来源:duplicates.py

示例12: __init__

 def __init__(self, parent, device=None):
     QTreeWidgetItem.__init__(self, parent)
     self.device = device
开发者ID:MusaSakizci,项目名称:yali-family,代码行数:3,代码来源:ScrPartitionManual.py

示例13: __init__

    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:MarioJC,项目名称:calibre,代码行数:31,代码来源:choose_format_device.py


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