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


Python Library.book_information_by_title_author方法代码示例

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


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

示例1: update_table

# 需要导入模块: from library import Library [as 别名]
# 或者: from library.Library import book_information_by_title_author [as 别名]
    def update_table(self):
        """
            Update the table after clicking the Search button.
        """
        self.table.setRowCount(0)
        self.table.setColumnCount(0)
        search = self.searchEdit.text()
        if self.author.isChecked():
            results = Library.book_information_by_author(search)
        elif self.title.isChecked():
            results = Library.book_information_by_title(search)
        else:
            results = Library.book_information_by_title_author(search)
        self.table = QtGui.QTableWidget(len(results), 10, self)
        headers = ("Title", "Author's name", "Published in", "Genre",
                   "Rating", "Copies", "Get", "Return", "Like", " Dislike")
        self.table.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
        self.table.setHorizontalHeaderLabels(headers)
        self.table.resizeColumnsToContents()
        self.table.resizeRowsToContents()

        widths = [150, 150, 90, 80, 70, 60, 50, 60, 50, 70]
        for col, width in zip(range(9), widths):
            self.table.setColumnWidth(col, width)

        self.table.horizontalHeader().setStretchLastSection(True)
        for row in range(len(results)):
            book = results[row]
            col = 0
            for column in (book.title, book.author, book.year, book.genre,
                           book.rating, book.number_of_copies):
                item = QtGui.QTableWidgetItem(str(column))
                self.table.setItem(row, col, item)
                col += 1

        for row in range(len(results)):
            get_btn = QtGui.QPushButton("Get")
            get_btn.setMinimumSize(50, 30)
            get_btn.clicked.connect(partial(self.get_a_copy, row))
            self.table.setCellWidget(row, 6, get_btn)
            return_btn = QtGui.QPushButton("Return")
            return_btn.setMinimumSize(50, 30)
            return_btn.clicked.connect(partial(self.return_a_copy, row))
            self.table.setCellWidget(row, 7, return_btn)

            like_btn = QtGui.QPushButton("Like")
            like_btn.setMinimumSize(50, 30)
            like_btn.clicked.connect(partial(self.like_a_book, row))
            self.table.setCellWidget(row, 8, like_btn)
            dislike_btn = QtGui.QPushButton("Dislike")
            dislike_btn.setMinimumSize(50, 30)
            dislike_btn.clicked.connect(partial(self.dislike_a_book, row))
            self.table.setCellWidget(row, 9, dislike_btn)

        self.grid.addWidget(self.table, 1, 0)
开发者ID:Ralitsa-Ts,项目名称:Bookstore_and_Chart,代码行数:57,代码来源:book_information.py


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