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


Python QTableView.setWindowTitle方法代码示例

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


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

示例1: MyWin

# 需要导入模块: from PyQt5.QtWidgets import QTableView [as 别名]
# 或者: from PyQt5.QtWidgets.QTableView import setWindowTitle [as 别名]
class MyWin(QWidget):
    def __init__(self, mydb):
        super(MyWin, self).__init__()
        main_lt = QVBoxLayout()
        self.view = QTableView()
        main_lt.addWidget(self.view)
        self.view.setWindowTitle("Table Model (View 1)")
        self.view.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.mydb = mydb

        button = QPushButton("Join")
        button.clicked.connect(self.merge)
        main_lt.addWidget(button)

        button = QPushButton("Exit")
        button.clicked.connect(lambda: exit())
        main_lt.addWidget(button)

        self.setLayout(main_lt)
        self.setWindowTitle('QT1')

    def set_model(self):
        self.view.setModel(self.mydb.get_model())

    def merge(self):
        ind_list = self.view.selectedIndexes()
        out = list(self.view.model().data(i) for i in ind_list)
        out = [out[i] for i in range(len(out)) if i % 2 == 0]
        if len(out) < 2:
            return
        self.mydb.merge(out)
        mb = QMessageBox()
        mb.setText('Merged %s' % str(out))
        mb.exec_()
        self.set_model()
开发者ID:greyfenrir,项目名称:qt.ex,代码行数:37,代码来源:master.py

示例2: createView

# 需要导入模块: from PyQt5.QtWidgets import QTableView [as 别名]
# 或者: from PyQt5.QtWidgets.QTableView import setWindowTitle [as 别名]
def createView(title, model):
    view = QTableView()
    view.setModel(model)
    view.setItemDelegate(QSqlRelationalDelegate(view))
    view.setWindowTitle(title)

    return view
开发者ID:death-finger,项目名称:Scripts,代码行数:9,代码来源:relationaltablemodel.py

示例3: WishlistForm

# 需要导入模块: from PyQt5.QtWidgets import QTableView [as 别名]
# 或者: from PyQt5.QtWidgets.QTableView import setWindowTitle [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)
开发者ID:DenitsaKostova,项目名称:Bookoholic,代码行数:42,代码来源:show_wishlist.py

示例4: LibraryForm

# 需要导入模块: from PyQt5.QtWidgets import QTableView [as 别名]
# 或者: from PyQt5.QtWidgets.QTableView import setWindowTitle [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)
开发者ID:DenitsaKostova,项目名称:Bookoholic,代码行数:39,代码来源:show_library.py

示例5: ShowItems_Form

# 需要导入模块: from PyQt5.QtWidgets import QTableView [as 别名]
# 或者: from PyQt5.QtWidgets.QTableView import setWindowTitle [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())
开发者ID:esevlogiev,项目名称:FrontDesk-System,代码行数:77,代码来源:show_room_items.py

示例6: createView

# 需要导入模块: from PyQt5.QtWidgets import QTableView [as 别名]
# 或者: from PyQt5.QtWidgets.QTableView import setWindowTitle [as 别名]
def createView(title, model):
    view = QTableView()
    view.setModel(model)
    view.setWindowTitle(title)
    return view
开发者ID:valeriy67,项目名称:Cquality,代码行数:7,代码来源:test.py

示例7: GoodreadsOptionsForm

# 需要导入模块: from PyQt5.QtWidgets import QTableView [as 别名]
# 或者: from PyQt5.QtWidgets.QTableView import setWindowTitle [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)
开发者ID:DenitsaKostova,项目名称:Bookoholic,代码行数:74,代码来源:goodreads_option.py

示例8: updateEditorGeometry

# 需要导入模块: from PyQt5.QtWidgets import QTableView [as 别名]
# 或者: from PyQt5.QtWidgets.QTableView import setWindowTitle [as 别名]
        spinBox.interpretText()
        value = spinBox.value()

        model.setData(index, value, Qt.EditRole)

    def updateEditorGeometry(self, editor, option, index):
        editor.setGeometry(option.rect)


if __name__ == '__main__':

    import sys

    app = QApplication(sys.argv)

    model = QStandardItemModel(4, 2)
    tableView = QTableView()
    tableView.setModel(model)

    delegate = SpinBoxDelegate()
    tableView.setItemDelegate(delegate)

    for row in range(4):
        for column in range(2):
            index = model.index(row, column, QModelIndex())
            model.setData(index, (row + 1) * (column + 1))

    tableView.setWindowTitle("Spin Box Delegate")
    tableView.show()
    sys.exit(app.exec_())
开发者ID:CarlosAndres12,项目名称:pyqt5,代码行数:32,代码来源:spinboxdelegate.py

示例9: ShowClient_Form

# 需要导入模块: from PyQt5.QtWidgets import QTableView [as 别名]
# 或者: from PyQt5.QtWidgets.QTableView import setWindowTitle [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)
开发者ID:esevlogiev,项目名称:FrontDesk-System,代码行数:68,代码来源:show_client.py

示例10: SearchForm

# 需要导入模块: from PyQt5.QtWidgets import QTableView [as 别名]
# 或者: from PyQt5.QtWidgets.QTableView import setWindowTitle [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_()
开发者ID:DenitsaKostova,项目名称:Bookoholic,代码行数:63,代码来源:show_book.py

示例11: createView

# 需要导入模块: from PyQt5.QtWidgets import QTableView [as 别名]
# 或者: from PyQt5.QtWidgets.QTableView import setWindowTitle [as 别名]
def createView(title, model):
    global offset, views

    view = QTableView()
    views.append(view)
    view.setModel(model)
    view.setWindowTitle(title)
    view.move(100 + offset, 100 + offset)
    offset += 20
    view.show()
开发者ID:death-finger,项目名称:Scripts,代码行数:12,代码来源:querymodel.py


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