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


Python Qt.QListWidget类代码示例

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


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

示例1: SelectNames

class SelectNames(QDialog):  # {{{
    def __init__(self, names, txt, parent=None):
        QDialog.__init__(self, parent)
        self.l = l = QVBoxLayout(self)
        self.setLayout(l)

        self.la = la = QLabel(_("Create a Virtual Library based on %s") % txt)
        l.addWidget(la)

        self._names = QListWidget(self)
        self._names.addItems(QStringList(sorted(names, key=sort_key)))
        self._names.setSelectionMode(self._names.ExtendedSelection)
        l.addWidget(self._names)

        self._or = QRadioButton(_("Match any of the selected %s names") % txt)
        self._and = QRadioButton(_("Match all of the selected %s names") % txt)
        self._or.setChecked(True)
        l.addWidget(self._or)
        l.addWidget(self._and)

        self.bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        self.bb.accepted.connect(self.accept)
        self.bb.rejected.connect(self.reject)
        l.addWidget(self.bb)

        self.resize(self.sizeHint())

    @property
    def names(self):
        for item in self._names.selectedItems():
            yield unicode(item.data(Qt.DisplayRole).toString())

    @property
    def match_type(self):
        return " and " if self._and.isChecked() else " or "
开发者ID:jackpinto,项目名称:calibre,代码行数:35,代码来源:search_restriction_mixin.py

示例2: __init__

 def __init__(self, all_authors, parent):
     QListWidget.__init__(self, parent)
     self.setDragEnabled(True)
     self.setSelectionMode(self.ExtendedSelection)
     self.setDropIndicatorShown(True)
     self.setDragDropMode(self.InternalMove)
     self.setAlternatingRowColors(True)
     self.d = ItemDelegate(all_authors, self)
     self.d.edited.connect(self.edited, type=Qt.QueuedConnection)
     self.setItemDelegate(self.d)
开发者ID:089git,项目名称:calibre,代码行数:10,代码来源:authors_edit.py

示例3: setCurrentRow

 def setCurrentRow(self, row, setAsDefault = False ):
     """
     Select new row. 
     
     @param row: The new row to select.
     @type  row: int
     
     @param setAsDefault: If True, I{row} becomes the default row when
                          "Restore Defaults" is clicked.
     """
     if setAsDefault:
         self.setAsDefault = setAsDefault
         self.defaultRow   = row
     QListWidget.setCurrentRow(self, row)
开发者ID:elfion,项目名称:nanoengineer,代码行数:14,代码来源:PM_ListWidget.py

示例4: makeAddDataTab

    def makeAddDataTab(self, grid):
        self.author_label = QLabel("Author")
        self.author_text = QLineEdit()
        self.author_text.setPlaceholderText("Author")
        grid.addWidget(self.author_label, 0, 0)
        grid.addWidget(self.author_text, 1, 0)
        self.title_label = QLabel("Title")
        self.title_text = QLineEdit()
        self.title_text.setPlaceholderText("Title")
        grid.addWidget(self.title_label, 0, 1)
        grid.addWidget(self.title_text, 1, 1)
        
        self.date_label = QLabel("Date Read")
        self.date_text = QtGui.QCalendarWidget()
        self.connect(self.date_text, QtCore.SIGNAL('selectionChanged()'), self.date_changed)

        grid.addWidget(self.date_label, 2, 1)
        grid.addWidget(self.date_text, 3, 1)
        self.grade_label = QLabel("Grade")
        self.grade_text = QLineEdit()
        self.grade_text.setPlaceholderText("Grade 1-5")
        grid.addWidget(self.grade_label, 2, 0)
        grid.addWidget(self.grade_text, 3, 0)
        self.comments_label = QLabel("Comments")
        self.comments_text = QLineEdit()
        self.comments_text.setPlaceholderText("Comments here")
        grid.addWidget(self.comments_label, 4, 0)
        grid.addWidget(self.comments_text, 5, 0)
        self.genre_label = QLabel("Genre")
        self.genre_list = QListWidget(self)
        self.genre_list.addItems(self.genreList)
        self.genre_list.setObjectName('genre_list')
        self.genre_list.itemClicked.connect(self.item_clicked)
        grid.addWidget(self.genre_label, 6, 0)
        grid.addWidget(self.genre_list, 7, 0)
        self.genre2_label = QLabel("Genre2")
        self.genre2_list = QListWidget(self)
        self.genre2_list.setObjectName("genre2")
        self.genre2_list.addItem("Select genre first")
        grid.addWidget(self.genre2_label, 6, 1)
        grid.addWidget(self.genre2_list, 7, 1)
        self.submit = QtGui.QPushButton("Submit Data", self)
        self.submit.clicked.connect(self.buttonClicked)
        grid.addWidget(self.submit, 8, 1)
        self.quit = QtGui.QPushButton("Exit", self)
        self.quit.clicked.connect(self.buttonClicked)
        self.quit.setMaximumWidth(80)
        grid.addWidget(self.quit, 8, 0)
开发者ID:christerjakobsson,项目名称:School-labs,代码行数:48,代码来源:client.py

示例5: ChoosePluginToolbarsDialog

class ChoosePluginToolbarsDialog(QDialog):

    def __init__(self, parent, plugin, locations):
        QDialog.__init__(self, parent)
        self.locations = locations

        self.setWindowTitle(
            _('Add "%s" to toolbars or menus')%plugin.name)

        self._layout = QVBoxLayout(self)
        self.setLayout(self._layout)

        self._header_label = QLabel(
                _('Select the toolbars and/or menus to add <b>%s</b> to:') %
                plugin.name)
        self._layout.addWidget(self._header_label)

        self._locations_list = QListWidget(self)
        self._locations_list.setSelectionMode(QAbstractItemView.MultiSelection)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred,
                QtGui.QSizePolicy.Minimum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        self._locations_list.setSizePolicy(sizePolicy)
        for key, text in locations:
            self._locations_list.addItem(text)
            if key in {'toolbar', 'toolbar-device'}:
                self._locations_list.item(self._locations_list.count()-1
                        ).setSelected(True)
        self._layout.addWidget(self._locations_list)

        self._footer_label = QLabel(
            _('You can also customise the plugin locations '
              'using <b>Preferences -> Customise the toolbar</b>'))
        self._layout.addWidget(self._footer_label)

        button_box = QDialogButtonBox(QDialogButtonBox.Ok |
                QDialogButtonBox.Cancel)
        button_box.accepted.connect(self.accept)
        button_box.rejected.connect(self.reject)
        self._layout.addWidget(button_box)
        self.resize(self.sizeHint())

    def selected_locations(self):
        selected = []
        for row in self._locations_list.selectionModel().selectedRows():
            selected.append(self.locations[row.row()])
        return selected
开发者ID:089git,项目名称:calibre,代码行数:48,代码来源:choose_plugin_toolbars.py

示例6: __init__

 def __init__(self, parent, modal=True, flags=Qt.WindowFlags(), caption="Select Tags", ok_button="Select"):
     QDialog.__init__(self, parent, flags)
     self.setModal(modal)
     self.setWindowTitle(caption)
     lo = QVBoxLayout(self)
     lo.setMargin(10)
     lo.setSpacing(5)
     # tag selector
     self.wtagsel = QListWidget(self)
     lo.addWidget(self.wtagsel)
     #    self.wtagsel.setColumnMode(QListBox.FitToWidth)
     self.wtagsel.setSelectionMode(QListWidget.MultiSelection)
     QObject.connect(self.wtagsel, SIGNAL("itemSelectionChanged()"), self._check_tag)
     # buttons
     lo.addSpacing(10)
     lo2 = QHBoxLayout()
     lo.addLayout(lo2)
     lo2.setContentsMargins(0, 0, 0, 0)
     lo2.setMargin(5)
     self.wokbtn = QPushButton(ok_button, self)
     self.wokbtn.setMinimumWidth(128)
     QObject.connect(self.wokbtn, SIGNAL("clicked()"), self.accept)
     self.wokbtn.setEnabled(False)
     cancelbtn = QPushButton("Cancel", self)
     cancelbtn.setMinimumWidth(128)
     QObject.connect(cancelbtn, SIGNAL("clicked()"), self.reject)
     lo2.addWidget(self.wokbtn)
     lo2.addStretch(1)
     lo2.addWidget(cancelbtn)
     self.setMinimumWidth(384)
     self._tagnames = []
开发者ID:ska-sa,项目名称:tigger,代码行数:31,代码来源:Widgets.py

示例7: __init__

    def __init__(self, parent=None, mm=None):
        SizePersistedDialog.__init__(self, parent, 'casanova plugin:search dialog')
        self.setWindowTitle('Search Casanova:')
        self.gui = parent
        self.mm = mm
        
        layout = QVBoxLayout(self)
        self.setLayout(layout)

        self.search_label = QLabel('Search for:')
        layout.addWidget(self.search_label)
        self.search_str = QLineEdit(self)
        self.search_str.setText('')
        layout.addWidget(self.search_str)
        self.search_label.setBuddy(self.search_str)

        self.find_button = QPushButton("&Find")
        self.search_button_box = QDialogButtonBox(Qt.Horizontal)
        self.search_button_box.addButton(self.find_button, QDialogButtonBox.ActionRole)
        self.search_button_box.clicked.connect(self._find_clicked)
        layout.addWidget(self.search_button_box)        

        self.values_list = QListWidget(self)
        self.values_list.setSelectionMode(QAbstractItemView.ExtendedSelection)
        layout.addWidget(self.values_list)
        
        self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        self.button_box.accepted.connect(self._accept_clicked)
        self.button_box.rejected.connect(self.reject)
        layout.addWidget(self.button_box)

        # Cause our dialog size to be restored from prefs or created on first usage
        self.resize_dialog()
开发者ID:sdockray,项目名称:casanova-plugin,代码行数:33,代码来源:dialogs.py

示例8: __init__

    def __init__(self, names, txt, parent=None):
        QDialog.__init__(self, parent)
        self.l = l = QVBoxLayout(self)
        self.setLayout(l)

        self.la = la = QLabel(_('Create a Virtual Library based on %s') % txt)
        l.addWidget(la)

        self._names = QListWidget(self)
        self._names.addItems(QStringList(sorted(names, key=sort_key)))
        self._names.setSelectionMode(self._names.ExtendedSelection)
        l.addWidget(self._names)

        self._or = QRadioButton(_('Match any of the selected %s names')%txt)
        self._and = QRadioButton(_('Match all of the selected %s names')%txt)
        self._or.setChecked(True)
        l.addWidget(self._or)
        l.addWidget(self._and)

        self.bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        self.bb.accepted.connect(self.accept)
        self.bb.rejected.connect(self.reject)
        l.addWidget(self.bb)

        self.resize(self.sizeHint())
开发者ID:astachecki,项目名称:calibre,代码行数:25,代码来源:search_restriction_mixin.py

示例9: _init_controls

    def _init_controls(self):
        layout = QVBoxLayout(self)
        self.setLayout(layout)

        ml = QHBoxLayout()
        layout.addLayout(ml, 1)

        self.keys_list = QListWidget(self)
        self.keys_list.setSelectionMode(QAbstractItemView.SingleSelection)
        self.keys_list.setFixedWidth(150)
        self.keys_list.setAlternatingRowColors(True)
        ml.addWidget(self.keys_list)
        self.value_text = QTextEdit(self)
        self.value_text.setTabStopWidth(24)
        self.value_text.setReadOnly(False)
        ml.addWidget(self.value_text, 1)

        button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        button_box.accepted.connect(self._apply_changes)
        button_box.rejected.connect(self.reject)
        self.clear_button = button_box.addButton('Clear', QDialogButtonBox.ResetRole)
        self.clear_button.setIcon(get_icon('trash.png'))
        self.clear_button.setToolTip('Clear all settings for this plugin')
        self.clear_button.clicked.connect(self._clear_settings)
        layout.addWidget(button_box)
开发者ID:beeftornado,项目名称:calibre-shelfari-metadata,代码行数:25,代码来源:common_utils.py

示例10: __init__

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

示例11: _loadClipboardGroupbox

    def _loadClipboardGroupbox(self):
        """
        Load the L{self.clipboardListWidget} widget used to display a list of
        clipboard items inside this  clipboard  groupbox.
        """
        self.clipboardListWidget = QListWidget(self)

        self.gridLayout.addWidget(self.clipboardListWidget)
        #Append to the widget list. This is important for expand -collapse
        #functions (of the groupbox) to work properly.
        self._widgetList.append(self.clipboardListWidget)
开发者ID:alaindomissy,项目名称:nanoengineer,代码行数:11,代码来源:PM_Clipboard.py

示例12: SelectTagsDialog

class SelectTagsDialog(QDialog):
    def __init__(self, parent, modal=True, flags=Qt.WindowFlags(), caption="Select Tags", ok_button="Select"):
        QDialog.__init__(self, parent, flags)
        self.setModal(modal)
        self.setWindowTitle(caption)
        lo = QVBoxLayout(self)
        lo.setMargin(10)
        lo.setSpacing(5)
        # tag selector
        self.wtagsel = QListWidget(self)
        lo.addWidget(self.wtagsel)
        #    self.wtagsel.setColumnMode(QListBox.FitToWidth)
        self.wtagsel.setSelectionMode(QListWidget.MultiSelection)
        QObject.connect(self.wtagsel, SIGNAL("itemSelectionChanged()"), self._check_tag)
        # buttons
        lo.addSpacing(10)
        lo2 = QHBoxLayout()
        lo.addLayout(lo2)
        lo2.setContentsMargins(0, 0, 0, 0)
        lo2.setMargin(5)
        self.wokbtn = QPushButton(ok_button, self)
        self.wokbtn.setMinimumWidth(128)
        QObject.connect(self.wokbtn, SIGNAL("clicked()"), self.accept)
        self.wokbtn.setEnabled(False)
        cancelbtn = QPushButton("Cancel", self)
        cancelbtn.setMinimumWidth(128)
        QObject.connect(cancelbtn, SIGNAL("clicked()"), self.reject)
        lo2.addWidget(self.wokbtn)
        lo2.addStretch(1)
        lo2.addWidget(cancelbtn)
        self.setMinimumWidth(384)
        self._tagnames = []

    def setTags(self, tagnames):
        self._tagnames = tagnames
        self.wtagsel.clear()
        self.wtagsel.insertItems(0, list(tagnames))

    def _check_tag(self):
        for i in range(len(self._tagnames)):
            if self.wtagsel.item(i).isSelected():
                self.wokbtn.setEnabled(True)
                return
        else:
            self.wokbtn.setEnabled(False)

    def getSelectedTags(self):
        return [tag for i, tag in enumerate(self._tagnames) if self.wtagsel.item(i).isSelected()]
开发者ID:ska-sa,项目名称:tigger,代码行数:48,代码来源:Widgets.py

示例13: SearchDialog

class SearchDialog(SizePersistedDialog):

    def __init__(self, parent=None, mm=None):
        SizePersistedDialog.__init__(self, parent, 'casanova plugin:search dialog')
        self.setWindowTitle('Search Casanova:')
        self.gui = parent
        self.mm = mm
        
        layout = QVBoxLayout(self)
        self.setLayout(layout)

        self.search_label = QLabel('Search for:')
        layout.addWidget(self.search_label)
        self.search_str = QLineEdit(self)
        self.search_str.setText('')
        layout.addWidget(self.search_str)
        self.search_label.setBuddy(self.search_str)

        self.find_button = QPushButton("&Find")
        self.search_button_box = QDialogButtonBox(Qt.Horizontal)
        self.search_button_box.addButton(self.find_button, QDialogButtonBox.ActionRole)
        self.search_button_box.clicked.connect(self._find_clicked)
        layout.addWidget(self.search_button_box)        

        self.values_list = QListWidget(self)
        self.values_list.setSelectionMode(QAbstractItemView.ExtendedSelection)
        layout.addWidget(self.values_list)
        
        self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        self.button_box.accepted.connect(self._accept_clicked)
        self.button_box.rejected.connect(self.reject)
        layout.addWidget(self.button_box)

        # Cause our dialog size to be restored from prefs or created on first usage
        self.resize_dialog()

    def _display_choices(self, choices):
        self.values_list.clear()
        for id, name in choices.items():
            item = QListWidgetItem(get_icon('images/books.png'), name, self.values_list)
            item.setData(1, (id,))
            self.values_list.addItem(item)

    def _find_clicked(self):
        query = unicode(self.search_str.text())
        self._display_choices(self.mm.search(query))

    def _accept_clicked(self):
        #self._save_preferences()
        self.selected_texts = []
        for item in self.values_list.selectedItems():
            self.selected_texts.append(item.data(1).toPyObject()[0])
        self.accept() 
开发者ID:sdockray,项目名称:casanova-plugin,代码行数:53,代码来源:dialogs.py

示例14: insertItems

 def insertItems(self, row, items, setAsDefault = True):
     """
     Insert items of widget starting at <row>. 
     If <setAsDefault> is True, <items> become the default list of
     items for this widget. "Restore Defaults" will reset 
     the list of items to <items>.
     
     Note: <items> will always replace the list of current items
     in the widget. <row> is ignored. This is considered a bug.
     -- Mark 2007-06-04
     """
     if row <> 0:
         msg = "PM_ListWidget.insertItems(): <row> must be zero."\
             "See docstring for details:"
         print_compact_traceback(msg)
         return
         
     if setAsDefault:
         self.setAsDefault = setAsDefault
         self.defaultItems = items
     
     self.clear()
     QListWidget.insertItems(self, row, items)
开发者ID:elfion,项目名称:nanoengineer,代码行数:23,代码来源:PM_ListWidget.py

示例15: initGui

 def initGui(self):
     layout = QtGui.QVBoxLayout()
     self.label = QtGui.QLabel("<b>Filter by layer</b>")
     layout.addWidget(self.label)
     self.layersList = QListWidget()
     layout.addWidget(self.layersList)
     self.label = QtGui.QLabel("<b>Filter by text</b>")
     layout.addWidget(self.label)
     self.text = QtGui.QLineEdit()
     layout.addWidget(self.text)
     self.button = QtGui.QPushButton("Apply")
     self.button.clicked.connect(self.apply)
     layout.addWidget(self.button)
     self.setLayout(layout)
     self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.Popup)
     self.resize(200, 150)
开发者ID:boundlessgeo,项目名称:qgis-geogig-plugin,代码行数:16,代码来源:layerfilter.py


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