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


Python QListWidget.addItems方法代码示例

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


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

示例1: order_widget

# 需要导入模块: from PyQt4.Qt import QListWidget [as 别名]
# 或者: from PyQt4.Qt.QListWidget import addItems [as 别名]
    def order_widget(self, name, prefs=None):
        prefs = prefs or tprefs
        widget = QListWidget(self)
        widget.addItems(prefs.defaults[name])
        widget.setDragEnabled(True)
        widget.setDragDropMode(widget.InternalMove)
        widget.viewport().setAcceptDrops(True)
        widget.setDropIndicatorShown(True)
        widget.indexesMoved.connect(self.emit_changed)
        widget.setDefaultDropAction(Qt.MoveAction)
        widget.setMovement(widget.Snap)
        widget.setSpacing(5)
        widget.defaults = prefs.defaults[name]

        def getter(w):
            return list(map(unicode, (w.item(i).text() for i in xrange(w.count()))))

        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)

        return self(name, widget=widget, getter=getter, setter=setter, prefs=prefs)
开发者ID:HaraldGustafsson,项目名称:calibre,代码行数:31,代码来源:preferences.py

示例2: SelectNames

# 需要导入模块: from PyQt4.Qt import QListWidget [as 别名]
# 或者: from PyQt4.Qt.QListWidget import addItems [as 别名]
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,代码行数:37,代码来源:search_restriction_mixin.py

示例3: tab_widget

# 需要导入模块: from PyQt4.Qt import QListWidget [as 别名]
# 或者: from PyQt4.Qt.QListWidget import addItems [as 别名]
class tab_widget(QtGui.QTabWidget):
    
    
    # Initiate Widget. 
    def __init__(self, parent=MainWindow):
        super(tab_widget, self).__init__()
        self.initUI()
    
    # Create all object thats in the AddData tab
    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 = QLineEdit()
        self.date_text.setPlaceholderText("yy-mm-dd")
        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)

    # Creates all the object thats in the getData tab
    def makeGetDataTab(self, vbox_inner):
        self.authorData = QLineEdit()
        self.authorData.setPlaceholderText("Author")
        self.authorData.setReadOnly(True)
        vbox_inner.addWidget(self.authorData)
        self.titleData = QLineEdit()
        self.titleData.setPlaceholderText("Title")
        self.titleData.setReadOnly(True)
        vbox_inner.addWidget(self.titleData)
        self.genreData = QLineEdit()
        self.genreData.setPlaceholderText("Genre")
        self.genreData.setReadOnly(True)
        vbox_inner.addWidget(self.genreData)
        self.genre2Data = QLineEdit()
        self.genre2Data.setPlaceholderText("Genre2")
        self.genre2Data.setReadOnly(True)
        vbox_inner.addWidget(self.genre2Data)
        self.dateData = QLineEdit()
        self.dateData.setPlaceholderText("Date read")
        self.dateData.setReadOnly(True)
        vbox_inner.addWidget(self.dateData)
        self.gradeData = QLineEdit()
        self.gradeData.setPlaceholderText("Grade")
        self.gradeData.setReadOnly(True)
        vbox_inner.addWidget(self.gradeData)
        self.commentsData = QLineEdit()
        self.commentsData.setPlaceholderText("Comments")
        self.commentsData.setReadOnly(True)
        vbox_inner.addWidget(self.commentsData)
        self.titles_list = QListWidget(self)
        vbox_inner.addWidget(self.titles_list)
        hbox_inner = QtGui.QHBoxLayout()
        self.getTitleData = QtGui.QPushButton("Get title data", self)
        self.getTitleData.clicked.connect(self.buttonClicked)
        hbox_inner.addWidget(self.getTitleData)
        self.refreshList = QtGui.QPushButton("Refresh list", self)
        self.refreshList.clicked.connect(self.buttonClicked)
        hbox_inner.addWidget(self.refreshList)
        return hbox_inner
    
    # Initiate the widgets gui
    def initUI(self):
        
#.........这里部分代码省略.........
开发者ID:christerjakobsson,项目名称:School-labs,代码行数:103,代码来源:client.py

示例4: addItems

# 需要导入模块: from PyQt4.Qt import QListWidget [as 别名]
# 或者: from PyQt4.Qt.QListWidget import addItems [as 别名]
 def addItems(self, *args):
     try:
         return QListWidget.addItems(self, *args)
     finally:
         self.mark_as_editable()
开发者ID:089git,项目名称:calibre,代码行数:7,代码来源:authors_edit.py

示例5: tab_widget

# 需要导入模块: from PyQt4.Qt import QListWidget [as 别名]
# 或者: from PyQt4.Qt.QListWidget import addItems [as 别名]
class tab_widget(QtGui.QTabWidget):
    
    
    # Initiate Widget. 
    def __init__(self, parent=MainWindow):
        super(tab_widget, self).__init__()
        self.initUI()
    
    # Create interface, and connect buttons to signals.
    def initUI(self):
        vbox_inner = QVBoxLayout()
        grid = QtGui.QGridLayout()
        
        self.genreList = ['Fiction', 'Fact book', 'Poetry']
        
        # Tab 1: Add Data        
        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 = QLineEdit()
        self.date_text.setPlaceholderText("yy-mm-dd")
        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)
        
        
        # Tab 2:Get Data from file
        self.authorData = QLineEdit()
        self.authorData.setPlaceholderText("Author")
        self.authorData.setReadOnly(True)
        vbox_inner.addWidget(self.authorData)
        
        self.titleData = QLineEdit()
        self.titleData.setPlaceholderText("Title")
        self.titleData.setReadOnly(True)
        vbox_inner.addWidget(self.titleData)
        
        self.genreData = QLineEdit()
        self.genreData.setPlaceholderText("Genre")
        self.genreData.setReadOnly(True)
        vbox_inner.addWidget(self.genreData)
        
        self.genre2Data = QLineEdit()
        self.genre2Data.setPlaceholderText("Genre2")
        self.genre2Data.setReadOnly(True)
        vbox_inner.addWidget(self.genre2Data)
        
        self.dateData = QLineEdit()
        self.dateData.setPlaceholderText("Date read")
        self.dateData.setReadOnly(True)
        vbox_inner.addWidget(self.dateData)
        
        self.gradeData = QLineEdit()
        self.gradeData.setPlaceholderText("Grade")
        self.gradeData.setReadOnly(True)
        vbox_inner.addWidget(self.gradeData)
        
        self.commentsData = QLineEdit()
        self.commentsData.setPlaceholderText("Comments")
        self.commentsData.setReadOnly(True)
        vbox_inner.addWidget(self.commentsData)
        
        self.titles_list = QListWidget(self)
#.........这里部分代码省略.........
开发者ID:christerjakobsson,项目名称:School-labs,代码行数:103,代码来源:del3.py


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