本文整理汇总了Python中PyQt5.QtWidgets.QTableView.setWindowIcon方法的典型用法代码示例。如果您正苦于以下问题:Python QTableView.setWindowIcon方法的具体用法?Python QTableView.setWindowIcon怎么用?Python QTableView.setWindowIcon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QTableView
的用法示例。
在下文中一共展示了QTableView.setWindowIcon方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: WishlistForm
# 需要导入模块: from PyQt5.QtWidgets import QTableView [as 别名]
# 或者: from PyQt5.QtWidgets.QTableView import setWindowIcon [as 别名]
class WishlistForm(QDialog):
def __init__(self):
super(WishlistForm, self).__init__()
self.initUI(self)
def initUI(self, WishlistForm):
layout = QGridLayout(self)
self.show_wishlist_button = QPushButton("Show Wishlist")
layout.addWidget(self.show_wishlist_button, 0, 1, 1, 2)
self.setLayout(layout)
self.show_wishlist_button.clicked.connect(self.
show_wishlist_button_click)
self.layout().setSizeConstraint(QLayout.SetFixedSize)
self.setWindowTitle("Wishlist")
self.setWindowIcon(QIcon(QPixmap('../images/whish.png')))
def show_table(self, model):
self.table = QTableView()
self.table.setSizeAdjustPolicy(QAbstractScrollArea.AdjustToContents)
self.model = model
self.table.setWindowTitle("Wishlist")
self.table.setWindowIcon(QIcon(QPixmap('../images/icon.png')))
self.table.setModel(model)
self.table.show()
def show_wishlist_button_click(self):
text = 'Want Тo Read'
books = select_by_status(text)
if books == []:
QMessageBox(QMessageBox.Information, "No results",
"There are no books in the wishlist!").exec_()
return
else:
wishlist_model = BookModel()
books = [Book(*book) for book in books]
wishlist_model.set_books(books)
self.show_table(wishlist_model)
示例2: LibraryForm
# 需要导入模块: from PyQt5.QtWidgets import QTableView [as 别名]
# 或者: from PyQt5.QtWidgets.QTableView import setWindowIcon [as 别名]
class LibraryForm(QDialog):
def __init__(self):
super(LibraryForm, self).__init__()
self.initUI(self)
def initUI(self, LibraryForm):
layout = QGridLayout(self)
self.show_lib_button = QPushButton("Show Library")
layout.addWidget(self.show_lib_button, 0, 1, 1, 2)
self.setLayout(layout)
self.show_lib_button.clicked.connect(self.show_lib_button_click)
self.layout().setSizeConstraint(QLayout.SetFixedSize)
self.setWindowTitle("Library")
self.setWindowIcon(QIcon(QPixmap('../images/library.png')))
def show_table(self, model):
self.table = QTableView()
self.table.setSizeAdjustPolicy(QAbstractScrollArea.AdjustToContents)
self.model = model
self.table.setWindowTitle("Library")
self.table.setWindowIcon(QIcon(QPixmap('../images/icon.png')))
self.table.setModel(model)
self.table.show()
def show_lib_button_click(self):
books = select_all()
if books == []:
QMessageBox(QMessageBox.Information, "No results",
"There are no books in the library!").exec_()
return
else:
book_model = BookModel()
books = [Book(*book) for book in books]
book_model.set_books(books)
self.show_table(book_model)
示例3: ShowItems_Form
# 需要导入模块: from PyQt5.QtWidgets import QTableView [as 别名]
# 或者: from PyQt5.QtWidgets.QTableView import setWindowIcon [as 别名]
class ShowItems_Form(QDialog):
def __init__(self):
super(ShowItems_Form, self).__init__()
self.setupUi(self)
def setupUi(self, ShowItems_Form):
layout = QGridLayout(self)
self.room_number_label = QLabel("Room Number:")
self.room_number_line_edit = QLineEdit()
self.item_label = QLabel("Choose Item:")
self.item_combo_box = QComboBox()
self.show_items = QPushButton("Show Items")
self.item_combo_box.addItems(ITEMS)
layout.addWidget(self.room_number_label, 0, 0)
layout.addWidget(self.room_number_line_edit, 0, 1)
layout.addWidget(self.item_label, 1, 0)
layout.addWidget(self.item_combo_box, 1, 1)
layout.addWidget(self.show_items, 2, 0, 1, 2, Qt.AlignCenter)
self.setLayout(layout)
self.show_items.clicked.connect(self.show_button_click)
self.layout().setSizeConstraint(QLayout.SetFixedSize)
self.setWindowIcon(QIcon(QPixmap('hotel_icon.jpg')))
self.setWindowTitle("Show Items")
def show_table(self, items, model):
self.table = QTableView()
self.table.setSizeAdjustPolicy(QAbstractScrollArea.AdjustToContents)
self.model = model
if type(model) == type(FurnituresModel()):
self.model.set_furnitures(items)
self.table.setWindowTitle("Furnitures")
elif type(model) == type(BathItemsModel()):
self.model.set_bath_items(items)
self.table.setWindowTitle("Bath Items")
elif type(model) == type(FoodModel()):
self.model.set_food(items)
self.table.setWindowTitle("Food")
elif type(model) == type(SleepingFurnituresModel()):
self.model.set_sleeping_furnitures(items)
self.table.setWindowTitle("Sleeping Furnitures")
self.table.setWindowIcon(QIcon(QPixmap(':/images/hotel_icon.jpg')))
self.table.setModel(model)
self.table.show()
def show_button_click(self):
room_number = self.room_number_line_edit.text()
item = self.item_combo_box.currentText()
if not Validations.is_positive_integer(room_number):
QMessageBox(QMessageBox.Critical, "Error",
"Invalid room number. Correct it!!!").exec_()
return
if not int(room_number) in get_all_rooms_number():
QMessageBox(QMessageBox.Critical, "Error",
"There is no room with such number." +
" Correct it!!!").exec_()
return
if item == 'Furnitures':
self.show_table(furnitures_in_room(int(room_number)),
FurnituresModel())
elif item == 'Bath Items':
self.show_table(bath_items_in_room(int(room_number)),
BathItemsModel())
elif item == 'Food':
self.show_table(food_in_room(int(room_number)),
FoodModel())
elif item == 'Sleeping Furnitures':
self.show_table(sleeping_furnitures_in_room(int(room_number)),
SleepingFurnituresModel())
示例4: GoodreadsOptionsForm
# 需要导入模块: from PyQt5.QtWidgets import QTableView [as 别名]
# 或者: from PyQt5.QtWidgets.QTableView import setWindowIcon [as 别名]
class GoodreadsOptionsForm(QDialog):
def __init__(self, user_id):
super(GoodreadsOptionsForm, self).__init__()
self.initUI(self)
self.user_id = user_id
def initUI(self, GoodreadsOptionsForm):
layout = QGridLayout(self)
self.main_label = QLabel("Please choose an option:")
self.search_combo_box = QComboBox()
self.search_combo_box.addItem("Read")
self.search_combo_box.addItem("Currently Reading")
self.search_combo_box.addItem("To-Read")
self.search_button = QPushButton("Search")
layout.addWidget(self.main_label, 0, 0)
layout.addWidget(self.search_combo_box, 0, 1)
layout.addWidget(self.search_button, 0, 2, 1, 2)
self.setLayout(layout)
self.search_button.clicked.connect(self.search_button_click)
self.layout().setSizeConstraint(QLayout.SetFixedSize)
self.setWindowTitle("Search Books")
self.setWindowIcon(QIcon(QPixmap('../images/search.png')))
def show_user_shelf(self, user_id, shelf):
goodreads_shelf = shelf
client = GoodReadsClient(KEY, SECRET)
books = client.get_shelf(user_id, goodreads_shelf)
view_books = []
for book in books:
isbn = book["isbn"]
title = book["title"]
goodreads_url = book["link"]
year = book["published"]
author = book["authors"][0]["name"]
rating = book["average_rating"]
view_books.append((isbn, title, author, year,
rating, goodreads_url))
if view_books != []:
book_model = GoodReadsBookModel()
view_books = [GoodReadsBook(*book) for book in view_books]
book_model.set_books(view_books)
self.show_table(book_model)
else:
QMessageBox(QMessageBox.Information, "No results",
"Sorry. There are no results found!").exec_()
def show_table(self, model):
self.table = QTableView()
self.table.setSizeAdjustPolicy(QAbstractScrollArea.AdjustToContents)
self.model = model
self.table.setWindowTitle("Books")
self.table.setWindowIcon(QIcon(QPixmap('../images/icon.png')))
self.table.setModel(model)
self.table.resizeColumnsToContents()
self.table.show()
def search_button_click(self):
option = self.search_combo_box.currentText()
shelf = ""
if option == 'Read':
shelf = "read"
elif option == 'Currently Reading':
shelf = "currently-reading"
elif option == 'To-Read':
shelf = "to-read"
self.show_user_shelf(self.user_id, shelf)
示例5: ShowClient_Form
# 需要导入模块: from PyQt5.QtWidgets import QTableView [as 别名]
# 或者: from PyQt5.QtWidgets.QTableView import setWindowIcon [as 别名]
class ShowClient_Form(QDialog):
def __init__(self):
super(ShowClient_Form, self).__init__()
self.setupUi(self)
def setupUi(self, ShowClient_Form):
layout = QGridLayout(self)
self.first_name_label = QLabel("First Name:")
self.first_name_line_edit = QLineEdit()
self.last_name_label = QLabel("Last Name:")
self.last_name_line_edit = QLineEdit()
self.show_client = QPushButton("Show Client")
layout.addWidget(self.first_name_label, 0, 0)
layout.addWidget(self.first_name_line_edit, 0, 1)
layout.addWidget(self.last_name_label, 1, 0)
layout.addWidget(self.last_name_line_edit, 1, 1)
layout.addWidget(self.show_client, 2, 0, 1, 2, Qt.AlignCenter)
self.setLayout(layout)
self.show_client.clicked.connect(self.show_button_click)
self.layout().setSizeConstraint(QLayout.SetFixedSize)
self.setWindowIcon(QIcon(QPixmap('hotel_icon.jpg')))
self.setWindowTitle("Show Client")
def show_clients_model(self, clients, is_maid=False):
self.table = QTableView()
self.table.setSizeAdjustPolicy(QAbstractScrollArea.AdjustToContents)
self.model = ClientsModel(is_maid)
self.model.set_clients(clients)
self.table.setModel(self.model)
self.table.setWindowTitle('Show Client')
self.table.setWindowIcon(QIcon(QPixmap(':/images/hotel_icon.jpg')))
self.table.show()
def is_information_invalid(self, first_name, last_name):
return (not Validations.is_name(first_name) or
not Validations.is_name(last_name))
def error_message(self, first_name, last_name):
properties = [Validations.is_name, Validations.is_name]
data = [first_name, last_name]
messages = ['first name', 'last name']
result = []
for i in range(len(data)):
if not properties[i](data[i]):
result.append(messages[i] + ',')
return ' '.join(result)
def show_button_click(self):
first_name = self.first_name_line_edit.text()
last_name = self.last_name_line_edit.text()
if self.is_information_invalid(first_name, last_name):
error_message = self.error_message(first_name, last_name)
QMessageBox(QMessageBox.Critical, "Error",
"Invalid " + error_message[:len(error_message) - 1] +
". Correct it!!!").exec_()
return
if not show_client(first_name.capitalize(), last_name.capitalize()):
QMessageBox(QMessageBox.Warning, "Warning",
"This person is not a Client!!!").exec_()
return
self.show_clients_model(show_client(first_name.capitalize(),
last_name.capitalize()), True)
示例6: SearchForm
# 需要导入模块: from PyQt5.QtWidgets import QTableView [as 别名]
# 或者: from PyQt5.QtWidgets.QTableView import setWindowIcon [as 别名]
class SearchForm(QDialog):
def __init__(self):
super(SearchForm, self).__init__()
self.initUI(self)
def initUI(self, SearchForm):
layout = QGridLayout(self)
self.search_label = QLabel("Search book by:")
self.search_combo_box = QComboBox()
self.search_combo_box.addItem("ISBN")
self.search_combo_box.addItem("Title")
self.search_combo_box.addItem("Author")
self.search_combo_box.addItem("Genre")
self.search_line_edit = QLineEdit()
self.search_button = QPushButton("Search")
layout.addWidget(self.search_label, 0, 0)
layout.addWidget(self.search_combo_box, 0, 1)
layout.addWidget(self.search_line_edit, 0, 2)
layout.addWidget(self.search_button, 0, 3, 1, 2)
self.setLayout(layout)
self.search_button.clicked.connect(self.search_button_click)
self.layout().setSizeConstraint(QLayout.SetFixedSize)
self.setWindowTitle("Search Book")
self.setWindowIcon(QIcon(QPixmap('../images/search.png')))
def show_table(self, model):
self.table = QTableView()
self.table.setSizeAdjustPolicy(QAbstractScrollArea.AdjustToContents)
self.model = model
self.table.setWindowTitle("Books")
self.table.setWindowIcon(QIcon(QPixmap('../images/icon.png')))
self.table.setModel(model)
self.table.show()
def search_button_click(self):
search = self.search_combo_box.currentText()
text = self.search_line_edit.text()
if search == 'ISBN':
if not(Validations.is_valid_isbn(text)):
QMessageBox(QMessageBox.Critical, "Error",
"Invalid ISBN. Please correct it!").exec_()
books = select_by_isbn(string.capwords(text))
elif search == 'Title':
books = select_by_title(string.capwords(text))
elif search == 'Author':
books = select_by_author(string.capwords(text))
elif search == 'Genre':
books = select_by_genre(string.capwords(text))
if books != []:
book_model = BookModel()
books = [Book(*book) for book in books]
book_model.set_books(books)
self.show_table(book_model)
else:
QMessageBox(QMessageBox.Information, "No results",
"Sorry. There are no results found!").exec_()