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


Python QtCore.QItemSelection方法代码示例

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


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

示例1: remove_participants

# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QItemSelection [as 别名]
def remove_participants(self, selection: QItemSelection):
        if len(self.participants) < 1:
            return

        if selection.isEmpty():
            start, end = len(self.participants) - 1, len(self.participants) - 1  # delete last element
        else:
            start, end = min([rng.top() for rng in selection]), max([rng.bottom() for rng in selection])

        del self.participants[start:end + 1]
        num_removed = (end + 1) - start
        for participant in self.participants:
            if participant.relative_rssi > len(self.participants) - 1:
                participant.relative_rssi -= num_removed

        # fix duplicates
        n = len(self.participants)
        for p1, p2 in itertools.combinations(self.participants, 2):
            if p1.relative_rssi == p2.relative_rssi:
                p1.relative_rssi = next((i for i in range(n)
                                         if i not in set(p.relative_rssi for p in self.participants)),
                                        0)

        self.update()
        self.participant_edited.emit() 
开发者ID:jopohl,项目名称:urh,代码行数:27,代码来源:ParticipantTableModel.py

示例2: show_refs

# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QItemSelection [as 别名]
def show_refs(self, selection):
        if isinstance(selection, QItemSelection):
            if not selection.indexes(): # no selection
                return

        node = self.get_current_node()
        if node:
            self.refs_ui.show_refs(node) 
开发者ID:FreeOpcUa,项目名称:opcua-client-gui,代码行数:10,代码来源:mainwindow.py

示例3: show_attrs

# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QItemSelection [as 别名]
def show_attrs(self, selection):
        if isinstance(selection, QItemSelection):
            if not selection.indexes(): # no selection
                return

        node = self.get_current_node()
        if node:
            self.attrs_ui.show_attrs(node) 
开发者ID:FreeOpcUa,项目名称:opcua-client-gui,代码行数:10,代码来源:mainwindow.py

示例4: default_label_changed_slot

# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QItemSelection [as 别名]
def default_label_changed_slot(self, selection: QItemSelection):
        selected_rows = self.treeview_labels.selectionModel().selectedRows(2)
        if len(selected_rows) > 0:
            index: QModelIndex = selected_rows[0]
            current_label: LabelVO = self.treeview_labels.model().data(index)
            self.image_viewer.current_label = current_label 
开发者ID:haruiz,项目名称:CvStudio,代码行数:8,代码来源:image_viewer_widget.py

示例5: on_selectionChanged

# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QItemSelection [as 别名]
def on_selectionChanged(self):
        """
        Runs when cells are selected in the Header. This selects columns in the data table when the header is clicked,
        and then calls selectAbove()
        """
        # Check focus so we don't get recursive loop, since headers trigger selection of data cells and vice versa
        if self.hasFocus():
            dataView = self.parent.dataView

            # Set selection mode so selecting one row or column at a time adds to selection each time
            if self.orientation == Qt.Horizontal:  # This case is for the horizontal header
                # Get the header's selected columns
                selection = self.selectionModel().selection()

                # Removes the higher levels so that only the lowest level of the header affects the data table selection
                last_row_ix = self.df.columns.nlevels - 1
                last_col_ix = self.model().columnCount() - 1
                higher_levels = QtCore.QItemSelection(self.model().index(0, 0),
                                                      self.model().index(last_row_ix - 1, last_col_ix))
                selection.merge(higher_levels, QtCore.QItemSelectionModel.Deselect)

                # Select the cells in the data view
                dataView.selectionModel().select(selection,
                                                 QtCore.QItemSelectionModel.Columns | QtCore.QItemSelectionModel.ClearAndSelect)
            if self.orientation == Qt.Vertical:
                selection = self.selectionModel().selection()

                last_row_ix = self.model().rowCount() - 1
                last_col_ix = self.df.index.nlevels - 1
                higher_levels = QtCore.QItemSelection(self.model().index(0, 0),
                                                      self.model().index(last_row_ix, last_col_ix - 1))
                selection.merge(higher_levels, QtCore.QItemSelectionModel.Deselect)

                dataView.selectionModel().select(selection,
                                                 QtCore.QItemSelectionModel.Rows | QtCore.QItemSelectionModel.ClearAndSelect)

        self.selectAbove()

    # Take the current set of selected cells and make it so that any spanning cell above a selected cell is selected too
    # This should happen after every selection change 
开发者ID:adamerose,项目名称:pandasgui,代码行数:42,代码来源:dataframe_viewer.py

示例6: move_up

# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QItemSelection [as 别名]
def move_up(self, selection: QItemSelection):
        if selection.isEmpty() or len(self.participants) < 1:
            return None, None

        start, end = min([rng.top() for rng in selection]), max([rng.bottom() for rng in selection])
        if start == 0:
            return None, None

        for i in range(start, end + 1):
            self.participants[i], self.participants[i - 1] = self.participants[i - 1], self.participants[i]

        self.update()
        self.participant_edited.emit()

        return start, end 
开发者ID:jopohl,项目名称:urh,代码行数:17,代码来源:ParticipantTableModel.py

示例7: move_down

# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QItemSelection [as 别名]
def move_down(self, selection: QItemSelection):
        if selection.isEmpty() or len(self.participants) < 1:
            return None, None

        start, end = min([rng.top() for rng in selection]), max([rng.bottom() for rng in selection])
        if end >= len(self.participants) - 1:
            return None, None

        for i in reversed(range(start, end + 1)):
            self.participants[i], self.participants[i + 1] = self.participants[i + 1], self.participants[i]

        self.update()
        self.participant_edited.emit()

        return start, end 
开发者ID:jopohl,项目名称:urh,代码行数:17,代码来源:ParticipantTableModel.py

示例8: selectionChanged

# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QItemSelection [as 别名]
def selectionChanged(self, selection1: QItemSelection, selection2: QItemSelection):
        self.selection_changed.emit()
        super().selectionChanged(selection1, selection2) 
开发者ID:jopohl,项目名称:urh,代码行数:5,代码来源:ProtocolTreeView.py

示例9: select

# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QItemSelection [as 别名]
def select(self, row_1, col_1, row_2, col_2):
        selection = QItemSelection()
        start_index = self.model().index(row_1, col_1)
        end_index = self.model().index(row_2, col_2)
        selection.select(start_index, end_index)
        self.selectionModel().select(selection, QItemSelectionModel.Select) 
开发者ID:jopohl,项目名称:urh,代码行数:8,代码来源:ParticipantTableView.py

示例10: selectionChanged

# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QItemSelection [as 别名]
def selectionChanged(self, selection_1: QItemSelection, selection_2: QItemSelection):
        self.selection_changed.emit()
        super().selectionChanged(selection_1, selection_2) 
开发者ID:jopohl,项目名称:urh,代码行数:5,代码来源:ProtocolTableView.py


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