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


Python QListWidgetItem.setFlags方法代码示例

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


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

示例1: insertItems

# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setFlags [as 别名]
    def insertItems(self, row, items, setAsDefault = True):
        """
        Insert the <items> specified items in this list widget.
        The list widget shows item name string , as a QListwidgetItem.

        This QListWidgetItem object defines a 'key' of a dictionary
        (self._itemDictionary) and the 'value' of this key is the object
        specified by the 'item' itself.
        Example: self._itemDictionary['C6'] = instance of class Atom.

        @param row: The row number for the item.
        @type row: int

        @param items: A list of objects. These objects are treated as values in
                      the self._itemDictionary
        @type items: list

        @param setAsDefault: Not used here. See PM_ListWidget.insertItems where
                             it is used.

        @see: self.renameItemValue() for a comment about
              self._suppress_itemChanged_signal

        """

        #delete unused argument. Should this be provided as an argument in this
        #class method ?
        del setAsDefault

        #self.__init__ for a comment about this flag
        self._suppress_itemChanged_signal = True

        #Clear the previous contents of the self._itemDictionary
        self._itemDictionary.clear()

        #Clear the contents of this list widget, using QListWidget.clear()
        #See U{<http://doc.trolltech.com/4.2/qlistwidget.html>} for details
        self.clear()

        for item in items:
            if hasattr(item.__class__, 'name'):
                itemName = item.name
            else:
                itemName = str(item)
            listWidgetItem = QListWidgetItem(itemName, self)

            #When we support editing list widget items , uncomment out the
            #following line . See also self.editItems -- Ninad 2008-01-16
            listWidgetItem.setFlags( listWidgetItem.flags()| Qt.ItemIsEditable)

            if hasattr(item.__class__, 'iconPath'):
                try:
                    listWidgetItem.setIcon(geticon(item.iconPath))
                except:
                    print_compact_traceback()

            self._itemDictionary[listWidgetItem] = item

        #Reset the flag that temporarily suppresses itemChange signal.
        self._suppress_itemChanged_signal = False
开发者ID:alaindomissy,项目名称:nanoengineer,代码行数:62,代码来源:PM_SelectionListWidget.py

示例2: link_stylesheets

# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setFlags [as 别名]
    def link_stylesheets(self, names):
        s = self.categories['styles']
        sheets = [unicode(s.child(i).data(0, NAME_ROLE).toString()) for i in xrange(s.childCount())]
        if not sheets:
            return error_dialog(self, _('No stylesheets'), _(
                'This book currently has no stylesheets. You must first create a stylesheet'
                ' before linking it.'), show=True)
        d = QDialog(self)
        d.l = l = QVBoxLayout(d)
        d.setLayout(l)
        d.setWindowTitle(_('Choose stylesheets'))
        d.la = la = QLabel(_('Choose the stylesheets to link. Drag and drop to re-arrange'))

        la.setWordWrap(True)
        l.addWidget(la)
        d.s = s = QListWidget(d)
        l.addWidget(s)
        s.setDragEnabled(True)
        s.setDropIndicatorShown(True)
        s.setDragDropMode(self.InternalMove)
        s.setAutoScroll(True)
        s.setDefaultDropAction(Qt.MoveAction)
        for name in sheets:
            i = QListWidgetItem(name, s)
            flags = Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsDragEnabled | Qt.ItemIsSelectable
            i.setFlags(flags)
            i.setCheckState(Qt.Checked)
        d.bb = bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        bb.accepted.connect(d.accept), bb.rejected.connect(d.reject)
        l.addWidget(bb)
        if d.exec_() == d.Accepted:
            sheets = [unicode(s.item(i).text()) for i in xrange(s.count()) if s.item(i).checkState() == Qt.Checked]
            if sheets:
                self.link_stylesheets_requested.emit(names, sheets)
开发者ID:CharlesSong,项目名称:calibre,代码行数:36,代码来源:file_list.py

示例3: __init__

# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setFlags [as 别名]
 def __init__(self, parent, duplicates, loc):
     QDialog.__init__(self, parent)
     l = QVBoxLayout()
     self.setLayout(l)
     self.la = la = QLabel(_('Books with the same title and author as the following already exist in the library %s.'
                             ' Select which books you want copied anyway.') %
                           os.path.basename(loc))
     la.setWordWrap(True)
     l.addWidget(la)
     self.setWindowTitle(_('Duplicate books'))
     self.books = QListWidget(self)
     self.items = []
     for book_id, (title, authors) in duplicates.iteritems():
         i = QListWidgetItem(_('{0} by {1}').format(title, ' & '.join(authors[:3])), self.books)
         i.setData(Qt.UserRole, book_id)
         i.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
         i.setCheckState(Qt.Checked)
         self.items.append(i)
     l.addWidget(self.books)
     self.bb = bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
     bb.accepted.connect(self.accept)
     bb.rejected.connect(self.reject)
     self.a = b = bb.addButton(_('Select &all'), bb.ActionRole)
     b.clicked.connect(self.select_all), b.setIcon(QIcon(I('plus.png')))
     self.n = b = bb.addButton(_('Select &none'), bb.ActionRole)
     b.clicked.connect(self.select_none), b.setIcon(QIcon(I('minus.png')))
     self.ctc = b = bb.addButton(_('&Copy to clipboard'), bb.ActionRole)
     b.clicked.connect(self.copy_to_clipboard), b.setIcon(QIcon(I('edit-copy.png')))
     l.addWidget(bb)
     self.resize(600, 400)
开发者ID:BatteringRam,项目名称:calibre,代码行数:32,代码来源:copy_to_library.py

示例4: initialize

# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setFlags [as 别名]
 def initialize(self):
     self.devices.blockSignals(True)
     self.devices.clear()
     for dev in self.gui.device_manager.devices:
         for d, name in dev.get_user_blacklisted_devices().iteritems():
             item = QListWidgetItem('%s [%s]'%(name, d), self.devices)
             item.setData(Qt.UserRole, (dev, d))
             item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsUserCheckable|Qt.ItemIsSelectable)
             item.setCheckState(Qt.Checked)
     self.devices.blockSignals(False)
开发者ID:yeyanchao,项目名称:calibre,代码行数:12,代码来源:ignored_devices.py

示例5: setter

# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setFlags [as 别名]
 def setter(w, val):
     order_map = {x:i for i, x in enumerate(val)}
     items = list(w.defaults)
     limit = len(items)
     items.sort(key=lambda x:order_map.get(x, limit))
     w.clear()
     for x in items:
         i = QListWidgetItem(w)
         i.setText(x)
         i.setFlags(i.flags() | Qt.ItemIsDragEnabled)
开发者ID:HaraldGustafsson,项目名称:calibre,代码行数:12,代码来源:preferences.py

示例6: set_bookmarks

# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setFlags [as 别名]
 def set_bookmarks(self, bookmarks=None):
     if bookmarks is None:
         bookmarks = self.original_bookmarks
     self.bookmarks_list.clear()
     for bm in bookmarks:
         i = QListWidgetItem(bm['title'])
         i.setData(Qt.UserRole, self.bm_to_item(bm))
         i.setFlags(i.flags() | Qt.ItemIsEditable)
         self.bookmarks_list.addItem(i)
     if len(bookmarks) > 0:
         self.bookmarks_list.setCurrentItem(self.bookmarks_list.item(0), QItemSelectionModel.ClearAndSelect)
开发者ID:089git,项目名称:calibre,代码行数:13,代码来源:bookmarkmanager.py

示例7: init_input_order

# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setFlags [as 别名]
 def init_input_order(self, defaults=False):
     if defaults:
         input_map = prefs.defaults['input_format_order']
     else:
         input_map = prefs['input_format_order']
     all_formats = set()
     self.opt_input_order.clear()
     for fmt in all_input_formats().union(set(['ZIP', 'RAR'])):
         all_formats.add(fmt.upper())
     for format in input_map + list(all_formats.difference(input_map)):
         item = QListWidgetItem(format, self.opt_input_order)
         item.setData(Qt.UserRole, QVariant(format))
         item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsSelectable)
开发者ID:Eksmo,项目名称:calibre,代码行数:15,代码来源:behavior.py

示例8: __init__

# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setFlags [as 别名]
    def __init__(self, dev, ignored_folders=None, parent=None):
        QDialog.__init__(self, parent)
        self.l = l = QVBoxLayout()
        self.setLayout(l)
        self.la = la = QLabel(
            "<p>"
            + _("<b>Scanned folders:</b>")
            + " "
            + _("You can select which top level folders calibre will " "scan when searching this device for books.")
        )
        la.setWordWrap(True)
        l.addWidget(la)
        self.tabs = QTabWidget(self)
        l.addWidget(self.tabs)
        self.widgets = []

        for storage in dev.filesystem_cache.entries:
            w = QListWidget(self)
            w.storage = storage
            self.tabs.addTab(w, storage.name)
            self.widgets.append(w)
            for child in sorted(storage.folders, key=attrgetter("name")):
                i = QListWidgetItem(child.name)
                i.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
                i.setCheckState(
                    Qt.Unchecked
                    if dev.is_folder_ignored(storage, child.name, ignored_folders=ignored_folders)
                    else Qt.Checked
                )
                w.addItem(i)

        self.bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        self.bb.accepted.connect(self.accept)
        self.bb.rejected.connect(self.reject)
        self.sab = self.bb.addButton(_("Select &All"), self.bb.ActionRole)
        self.sab.clicked.connect(self.select_all)
        self.snb = self.bb.addButton(_("Select &None"), self.bb.ActionRole)
        self.snb.clicked.connect(self.select_none)
        l.addWidget(self.bb)
        self.setWindowTitle(_("Choose folders to scan"))
        self.setWindowIcon(QIcon(I("devices/tablet.png")))

        self.resize(500, 500)
开发者ID:bjhemens,项目名称:calibre,代码行数:45,代码来源:mtp_folder_browser.py

示例9: __init__

# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setFlags [as 别名]
    def __init__(self, parent, get_option, get_help, db=None, book_id=None):
        Widget.__init__(
            self,
            parent,
            ["paragraph_type", "formatting_type", "markdown_extensions", "preserve_spaces", "txt_in_remove_indents"],
        )
        self.db, self.book_id = db, book_id
        for x in get_option("paragraph_type").option.choices:
            self.opt_paragraph_type.addItem(x)
        for x in get_option("formatting_type").option.choices:
            self.opt_formatting_type.addItem(x)
        self.md_map = {}
        for name, text in MD_EXTENSIONS.iteritems():
            i = QListWidgetItem("%s - %s" % (name, text), self.opt_markdown_extensions)
            i.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
            i.setData(Qt.UserRole, name)
            self.md_map[name] = i

        self.initialize_options(get_option, get_help, db, book_id)
开发者ID:hashken,项目名称:calibre,代码行数:21,代码来源:txt_input.py

示例10: initialize

# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setFlags [as 别名]
    def initialize(self, name):
        '''
        Retrieve plugin-specific settings from general prefs store
        Need to store order of all possible formats, enabled formats
        '''
        self.name = name

        # Supported, enabled formats
        all_formats = self.prefs.get('kindle_supported_formats', KINDLE_SUPPORTED_FORMATS)
        enabled_formats = self.prefs.get('kindle_enabled_formats', KINDLE_ENABLED_FORMATS)

        for format in all_formats:
            item = QListWidgetItem(format, self.columns)
            item.setData(Qt.UserRole, QVariant(format))
            item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsUserCheckable|Qt.ItemIsSelectable)
            item.setCheckState(Qt.Checked if format in enabled_formats else Qt.Unchecked)

        self.column_up.clicked.connect(self.up_column)
        self.column_down.clicked.connect(self.down_column)
开发者ID:r3act10n,项目名称:calibre-ios-reader-applications,代码行数:21,代码来源:kindle.py

示例11: __init__

# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setFlags [as 别名]
    def __init__(self, devs, blacklist):
        QWidget.__init__(self)
        self.l = l = QVBoxLayout()
        self.setLayout(l)
        self.la = la = QLabel('<p>'+_(
            '''Select the devices to be <b>ignored</b>. calibre <b>will not</b>
            connect to devices with a checkmark next to their names.'''))
        la.setWordWrap(True)
        l.addWidget(la)
        self.f = f = QListWidget(self)
        l.addWidget(f)

        devs = [(snum, (x[0], parse_date(x[1]))) for snum, x in
                devs.iteritems()]
        for dev, x in sorted(devs, key=lambda x:x[1][1], reverse=True):
            name = x[0]
            name = '%s [%s]'%(name, dev)
            item = QListWidgetItem(name, f)
            item.setData(Qt.UserRole, dev)
            item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsUserCheckable|Qt.ItemIsSelectable)
            item.setCheckState(Qt.Checked if dev in blacklist else Qt.Unchecked)
开发者ID:BobPyron,项目名称:calibre,代码行数:23,代码来源:mtp_config.py

示例12: init_columns

# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setFlags [as 别名]
 def init_columns(self, defaults=False):
     # Set up columns
     self.opt_columns.blockSignals(True)
     model = self.gui.library_view.model()
     colmap = list(model.column_map)
     state = self.columns_state(defaults)
     hidden_cols = state['hidden_columns']
     positions = state['column_positions']
     colmap.sort(cmp=lambda x,y: cmp(positions[x], positions[y]))
     self.opt_columns.clear()
     for col in colmap:
         item = QListWidgetItem(model.headers[col], self.opt_columns)
         item.setData(Qt.UserRole, QVariant(col))
         flags = Qt.ItemIsEnabled|Qt.ItemIsSelectable
         if col != 'ondevice':
             flags |= Qt.ItemIsUserCheckable
         item.setFlags(flags)
         if col != 'ondevice':
             item.setCheckState(Qt.Unchecked if col in hidden_cols else
                     Qt.Checked)
     self.opt_columns.blockSignals(False)
开发者ID:Eksmo,项目名称:calibre,代码行数:23,代码来源:columns.py

示例13: __init__

# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setFlags [as 别名]
    def __init__(self, all_formats, format_map):
        QWidget.__init__(self)
        self.l = l = QGridLayout()
        self.setLayout(l)

        self.f = f = QListWidget(self)
        l.addWidget(f, 0, 0, 3, 1)
        unchecked_formats = sorted(all_formats - set(format_map))
        for fmt in format_map + unchecked_formats:
            item = QListWidgetItem(fmt, f)
            item.setData(Qt.UserRole, fmt)
            item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsSelectable)
            item.setCheckState(Qt.Checked if fmt in format_map else Qt.Unchecked)

        self.button_up = b = QToolButton(self)
        b.setIcon(QIcon(I("arrow-up.png")))
        l.addWidget(b, 0, 1)
        b.clicked.connect(self.up)

        self.button_down = b = QToolButton(self)
        b.setIcon(QIcon(I("arrow-down.png")))
        l.addWidget(b, 2, 1)
        b.clicked.connect(self.down)
开发者ID:hashken,项目名称:calibre,代码行数:25,代码来源:mtp_config.py

示例14: create_item

# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setFlags [as 别名]
 def create_item(self, alias, key, checked=False):
     i = QListWidgetItem(alias, self.recipients)
     i.setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
     i.setCheckState(Qt.Checked if checked else Qt.Unchecked)
     i.setData(Qt.UserRole, key)
     self.items.append(i)
开发者ID:fraga,项目名称:calibre,代码行数:8,代码来源:email.py

示例15: __init__

# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setFlags [as 别名]
    def __init__(self, settings, all_formats, supports_subdirs,
        must_read_metadata, supports_use_author_sort,
        extra_customization_message, device, extra_customization_choices=None):

        QWidget.__init__(self)
        Ui_ConfigWidget.__init__(self)
        self.setupUi(self)

        self.settings = settings

        all_formats = set(all_formats)
        self.calibre_known_formats = device.FORMATS
        try:
            self.device_name = device.get_gui_name()
        except TypeError:
            self.device_name = getattr(device, 'gui_name', None) or _('Device')
        if device.USER_CAN_ADD_NEW_FORMATS:
            all_formats = set(all_formats) | set(BOOK_EXTENSIONS)

        format_map = settings.format_map
        disabled_formats = list(set(all_formats).difference(format_map))
        for format in format_map + list(sorted(disabled_formats)):
            item = QListWidgetItem(format, self.columns)
            item.setData(Qt.UserRole, QVariant(format))
            item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsUserCheckable|Qt.ItemIsSelectable)
            item.setCheckState(Qt.Checked if format in format_map else Qt.Unchecked)

        self.column_up.clicked.connect(self.up_column)
        self.column_down.clicked.connect(self.down_column)

        if device.HIDE_FORMATS_CONFIG_BOX:
            self.groupBox.hide()

        if supports_subdirs:
            self.opt_use_subdirs.setChecked(self.settings.use_subdirs)
        else:
            self.opt_use_subdirs.hide()
        if not must_read_metadata:
            self.opt_read_metadata.setChecked(self.settings.read_metadata)
        else:
            self.opt_read_metadata.hide()
        if supports_use_author_sort:
            self.opt_use_author_sort.setChecked(self.settings.use_author_sort)
        else:
            self.opt_use_author_sort.hide()
        if extra_customization_message:
            extra_customization_choices = extra_customization_choices or {}
            def parse_msg(m):
                msg, _, tt = m.partition(':::') if m else ('', '', '')
                return msg.strip(), textwrap.fill(tt.strip(), 100)

            if isinstance(extra_customization_message, list):
                self.opt_extra_customization = []
                if len(extra_customization_message) > 6:
                    row_func = lambda x, y: ((x/2) * 2) + y
                    col_func = lambda x: x%2
                else:
                    row_func = lambda x, y: x*2 + y
                    col_func = lambda x: 0

                for i, m in enumerate(extra_customization_message):
                    label_text, tt = parse_msg(m)
                    if not label_text:
                        self.opt_extra_customization.append(None)
                        continue
                    if isinstance(settings.extra_customization[i], bool):
                        self.opt_extra_customization.append(QCheckBox(label_text))
                        self.opt_extra_customization[-1].setToolTip(tt)
                        self.opt_extra_customization[i].setChecked(bool(settings.extra_customization[i]))
                    elif i in extra_customization_choices:
                        cb = QComboBox(self)
                        self.opt_extra_customization.append(cb)
                        l = QLabel(label_text)
                        l.setToolTip(tt), cb.setToolTip(tt), l.setBuddy(cb), cb.setToolTip(tt)
                        for li in sorted(extra_customization_choices[i]):
                            self.opt_extra_customization[i].addItem(li)
                        cb.setCurrentIndex(max(0, cb.findText(settings.extra_customization[i])))
                    else:
                        self.opt_extra_customization.append(QLineEdit(self))
                        l = QLabel(label_text)
                        l.setToolTip(tt)
                        self.opt_extra_customization[i].setToolTip(tt)
                        l.setBuddy(self.opt_extra_customization[i])
                        l.setWordWrap(True)
                        self.opt_extra_customization[i].setText(settings.extra_customization[i])
                        self.opt_extra_customization[i].setCursorPosition(0)
                        self.extra_layout.addWidget(l, row_func(i, 0), col_func(i))
                    self.extra_layout.addWidget(self.opt_extra_customization[i],
                                                row_func(i, 1), col_func(i))
            else:
                self.opt_extra_customization = QLineEdit()
                label_text, tt = parse_msg(extra_customization_message)
                l = QLabel(label_text)
                l.setToolTip(tt)
                l.setBuddy(self.opt_extra_customization)
                l.setWordWrap(True)
                if settings.extra_customization:
                    self.opt_extra_customization.setText(settings.extra_customization)
                    self.opt_extra_customization.setCursorPosition(0)
                self.opt_extra_customization.setCursorPosition(0)
#.........这里部分代码省略.........
开发者ID:HaraldGustafsson,项目名称:calibre,代码行数:103,代码来源:configwidget.py


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