當前位置: 首頁>>代碼示例>>Python>>正文


Python QBoxLayout.addSpacing方法代碼示例

本文整理匯總了Python中PyQt5.QtWidgets.QBoxLayout.addSpacing方法的典型用法代碼示例。如果您正苦於以下問題:Python QBoxLayout.addSpacing方法的具體用法?Python QBoxLayout.addSpacing怎麽用?Python QBoxLayout.addSpacing使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt5.QtWidgets.QBoxLayout的用法示例。


在下文中一共展示了QBoxLayout.addSpacing方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from PyQt5.QtWidgets import QBoxLayout [as 別名]
# 或者: from PyQt5.QtWidgets.QBoxLayout import addSpacing [as 別名]
    def __init__(self, parent):
        super(UserManagerWidget, self).__init__(parent)
        self.parent = parent

        self.sort_order = 'by_name'

        view.notifier.observers.append(self)

        self.header_label = QLabel('Users')

        self.header_widget = QWidget(self)
        header_layout = QBoxLayout(QBoxLayout.LeftToRight)
        header_layout.addWidget(self.header_label)
        self.header_widget.setLayout(header_layout)

        self.sort_by_name_btn = QPushButton('Sort by Name', self)
        self.sort_by_name_btn.clicked.connect(self.sort_by_name)
        self.sort_by_rank_btn = QPushButton('Sort by Rank', self)
        self.sort_by_rank_btn.clicked.connect(self.sort_by_rank)

        self.sort_btns_widget = QWidget(self)
        sort_btns_layout = QBoxLayout(QBoxLayout.LeftToRight)
        sort_btns_layout.addWidget(self.sort_by_name_btn)
        sort_btns_layout.addSpacing(10)
        sort_btns_layout.addWidget(self.sort_by_rank_btn)
        self.sort_btns_widget.setLayout(sort_btns_layout)

        self.user_list = QTableWidget(style.style_loader.TABLE_INITIAL_LENGTH, 3, self)
        self.user_list.setFixedHeight(300)
        self.user_list.setFixedWidth(400)
        self.user_list.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
        self.user_list.verticalHeader().setSectionResizeMode(QHeaderView.Fixed)

        self.user_list_widget = QWidget(self)
        user_list_layout = QBoxLayout(QBoxLayout.LeftToRight)
        user_list_layout.addWidget(self.user_list)
        self.user_list_widget.setLayout(user_list_layout)

        self.add_player_btn = QPushButton('Add User', self)
        self.add_player_btn.clicked.connect(self.parent.show_add_user_widget)
        self.remove_player_btn = QPushButton('Remove User', self)
        self.remove_player_btn.clicked.connect(self.parent.show_remove_user_widget)

        self.player_btns_widget = QWidget(self)
        player_btn_layout = QBoxLayout(QBoxLayout.LeftToRight)
        player_btn_layout.addWidget(self.add_player_btn)
        player_btn_layout.addSpacing(10)
        player_btn_layout.addWidget(self.remove_player_btn)
        self.player_btns_widget.setLayout(player_btn_layout)

        self.error = None

        layout = QFormLayout()
        layout.addRow(self.header_widget)
        layout.addRow(self.sort_btns_widget)
        layout.addRow(self.user_list_widget)
        layout.addRow(self.player_btns_widget)
        self.setLayout(layout)

        self.update()
開發者ID:zlohner,項目名稱:TournamentOrganizer,代碼行數:62,代碼來源:user_manager_widget.py

示例2: __init__

# 需要導入模塊: from PyQt5.QtWidgets import QBoxLayout [as 別名]
# 或者: from PyQt5.QtWidgets.QBoxLayout import addSpacing [as 別名]
    def __init__(self, parent):
        super(TournamentOrganizerWidget, self).__init__(parent)
        self.parent = parent

        # Default Players (for quick testing)
        player_names = [
            'Frodo',
            'Sam',
            'Merry',
            'Pippin',
            'Gandalf',
            'Aragorn',
            'Legolas',
            'Gimli',
            'Boromir'
        ]
        # for name in player_names:
        # 	to.add_player(name, None)

        self.sort_order = 'by_name'

        view.notifier.observers.append(self)

        self.header_label = QLabel('Players')

        self.header_widget = QWidget(self)
        header_layout = QBoxLayout(QBoxLayout.LeftToRight)
        header_layout.addWidget(self.header_label)
        self.header_widget.setLayout(header_layout)

        self.sort_by_name_btn = QPushButton('Sort by Name', self)
        self.sort_by_name_btn.clicked.connect(self.sort_by_name)
        self.sort_by_rank_btn = QPushButton('Sort by Rank', self)
        self.sort_by_rank_btn.clicked.connect(self.sort_by_rank)

        self.sort_btns_widget = QWidget(self)
        sort_btns_layout = QBoxLayout(QBoxLayout.LeftToRight)
        sort_btns_layout.addWidget(self.sort_by_name_btn)
        sort_btns_layout.addSpacing(10)
        sort_btns_layout.addWidget(self.sort_by_rank_btn)
        self.sort_btns_widget.setLayout(sort_btns_layout)

        self.player_list = QTableWidget(style.style_loader.TABLE_INITIAL_LENGTH, 2, self)
        self.player_list.setHorizontalHeaderLabels(['Name', 'Record'])
        self.player_list.setFixedHeight(300)
        self.player_list.setFixedWidth(400)
        self.player_list.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
        self.player_list.verticalHeader().setSectionResizeMode(QHeaderView.Fixed)
        self.player_list.horizontalHeader().setVisible(True)

        self.player_list_widget = QWidget(self)
        player_list_layout = QBoxLayout(QBoxLayout.LeftToRight)
        player_list_layout.addWidget(self.player_list)
        self.player_list_widget.setLayout(player_list_layout)

        self.add_player_btn = QPushButton('Add Player', self)
        self.add_player_btn.clicked.connect(self.parent.show_add_player_widget)
        self.remove_player_btn = QPushButton('Remove Player', self)
        self.remove_player_btn.clicked.connect(self.parent.show_remove_player_widget)

        self.player_btns_widget = QWidget(self)
        player_btn_layout = QBoxLayout(QBoxLayout.LeftToRight)
        player_btn_layout.addWidget(self.add_player_btn)
        player_btn_layout.addSpacing(10)
        player_btn_layout.addWidget(self.remove_player_btn)
        self.player_btns_widget.setLayout(player_btn_layout)

        self.error = None

        layout = QFormLayout()
        layout.addRow(self.header_widget)
        layout.addRow(self.sort_btns_widget)
        layout.addRow(self.player_list_widget)
        layout.addRow(self.player_btns_widget)
        self.setLayout(layout)

        self.update()
開發者ID:zlohner,項目名稱:TournamentOrganizer,代碼行數:79,代碼來源:tournament_organizer_widget.py


注:本文中的PyQt5.QtWidgets.QBoxLayout.addSpacing方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。