本文整理汇总了Python中library.Library.book_information_by_author方法的典型用法代码示例。如果您正苦于以下问题:Python Library.book_information_by_author方法的具体用法?Python Library.book_information_by_author怎么用?Python Library.book_information_by_author使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类library.Library
的用法示例。
在下文中一共展示了Library.book_information_by_author方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_book_information_by_author
# 需要导入模块: from library import Library [as 别名]
# 或者: from library.Library import book_information_by_author [as 别名]
def test_book_information_by_author(self):
Library(self.store, ["Fantasy", "Thriller"])
self.add_books(self.books, Library)
book_steven = Library.book_information_by_author("Steve Law")
self.assertEqual([self.books[0]], book_steven)
book_john = Library.book_information_by_author("John White")
self.assertEqual([self.books[1], self.books[4]], book_john)
book_steve = Library.book_information_by_author("Steve Tyler")
self.assertEqual([self.books[2], self.books[3]], book_steve)
self.assertEqual([], Library.book_information_by_author("Haha"))
os.remove(os.path.realpath(self.store))
示例2: update_table
# 需要导入模块: from library import Library [as 别名]
# 或者: from library.Library import book_information_by_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)