Python PyQt5.QtCore.Qt 模块,ItemIsSelectable() 实例源码

我们从Python开源项目中,提取了以下27个代码示例,用于说明如何使用PyQt5.QtCore.Qt.ItemIsSelectable()

项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def createIcons(self):
        configButton = QListWidgetItem(self.contentsWidget)
        configButton.setIcon(QIcon(':/images/config.png'))
        configButton.setText("Configuration")
        configButton.setTextAlignment(Qt.AlignHCenter)
        configButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)

        updateButton = QListWidgetItem(self.contentsWidget)
        updateButton.setIcon(QIcon(':/images/update.png'))
        updateButton.setText("Update")
        updateButton.setTextAlignment(Qt.AlignHCenter)
        updateButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)

        queryButton = QListWidgetItem(self.contentsWidget)
        queryButton.setIcon(QIcon(':/images/query.png'))
        queryButton.setText("Query")
        queryButton.setTextAlignment(Qt.AlignHCenter)
        queryButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)

        self.contentsWidget.currentItemChanged.connect(self.changePage)
项目:examples    作者:pyqt    | 项目源码 | 文件源码
def createIcons(self):
        configButton = QListWidgetItem(self.contentsWidget)
        configButton.setIcon(QIcon(':/images/config.png'))
        configButton.setText("Configuration")
        configButton.setTextAlignment(Qt.AlignHCenter)
        configButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)

        updateButton = QListWidgetItem(self.contentsWidget)
        updateButton.setIcon(QIcon(':/images/update.png'))
        updateButton.setText("Update")
        updateButton.setTextAlignment(Qt.AlignHCenter)
        updateButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)

        queryButton = QListWidgetItem(self.contentsWidget)
        queryButton.setIcon(QIcon(':/images/query.png'))
        queryButton.setText("Query")
        queryButton.setTextAlignment(Qt.AlignHCenter)
        queryButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)

        self.contentsWidget.currentItemChanged.connect(self.changePage)
项目:pyqt5-example    作者:guinslym    | 项目源码 | 文件源码
def createIcons(self):
        configButton = QListWidgetItem(self.contentsWidget)
        configButton.setIcon(QIcon(':/images/config.png'))
        configButton.setText("Configuration")
        configButton.setTextAlignment(Qt.AlignHCenter)
        configButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)

        updateButton = QListWidgetItem(self.contentsWidget)
        updateButton.setIcon(QIcon(':/images/update.png'))
        updateButton.setText("Update")
        updateButton.setTextAlignment(Qt.AlignHCenter)
        updateButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)

        queryButton = QListWidgetItem(self.contentsWidget)
        queryButton.setIcon(QIcon(':/images/query.png'))
        queryButton.setText("Query")
        queryButton.setTextAlignment(Qt.AlignHCenter)
        queryButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)

        self.contentsWidget.currentItemChanged.connect(self.changePage)
项目:KerbalPie    作者:Vivero    | 项目源码 | 文件源码
def flags(self, index):
        col = index.column()
        flags = Qt.ItemIsEnabled
        if col == 0:
            flags = flags | Qt.ItemIsSelectable
        return flags
项目:gui_tool    作者:UAVCAN    | 项目源码 | 文件源码
def set_row(self, row, model):
        for col, spec in enumerate(self.columns):
            value = spec.render(model)
            color = None
            if isinstance(value, tuple):
                value, color = value
            w = QTableWidgetItem(str(value))
            if color is not None:
                w.setBackground(color)
            w.setTextAlignment(Qt.AlignVCenter | Qt.AlignLeft)
            w.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
            self.setItem(row, col, w)

        self.setRowHidden(row, not self.apply_filter_to_row(row))
项目:vidcutter    作者:ozmartian    | 项目源码 | 文件源码
def initCategories(self):
        generalButton = QListWidgetItem(self.categories)
        generalButton.setIcon(QIcon(':/images/settings-general.png'))
        generalButton.setText('General')
        generalButton.setToolTip('General settings')
        generalButton.setTextAlignment(Qt.AlignHCenter)
        generalButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
        videoButton = QListWidgetItem(self.categories)
        videoButton.setIcon(QIcon(':/images/settings-video.png'))
        videoButton.setText('Video')
        videoButton.setToolTip('Video settings')
        videoButton.setTextAlignment(Qt.AlignHCenter)
        videoButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
        themeButton = QListWidgetItem(self.categories)
        themeButton.setIcon(QIcon(':/images/settings-theme.png'))
        themeButton.setText('Theme')
        themeButton.setToolTip('Theme settings')
        themeButton.setTextAlignment(Qt.AlignHCenter)
        themeButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
        logsButton = QListWidgetItem(self.categories)
        logsButton.setIcon(QIcon(':/images/settings-logs.png'))
        logsButton.setText('Logs')
        logsButton.setToolTip('Logging settings')
        logsButton.setTextAlignment(Qt.AlignHCenter)
        logsButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
        self.categories.currentItemChanged.connect(self.changePage)
        self.categories.setCurrentRow(0)
        self.categories.setMaximumWidth(self.categories.sizeHintForColumn(0) + 2)
        self.setMinimumWidth(650 if sys.platform == 'darwin' else 620)
        if sys.platform != 'win32':
            self.adjustSize()
项目:defconQt    作者:trufont    | 项目源码 | 文件源码
def flags(self, index):
        flags = Qt.ItemIsEnabled | Qt.ItemIsSelectable \
            | Qt.ItemIsDragEnabled | Qt.ItemIsDropEnabled \
            | Qt.ItemNeverHasChildren
        if not isinstance(self.data(index), (Font, Glyph)):
            flags |= Qt.ItemIsEditable
        return flags
项目:Py2DSpectroscopy    作者:SvenBo90    | 项目源码 | 文件源码
def cb_function_selected(self, index):

        # get the peak number of the changed function
        i_peak = int(self.sender().objectName()[-1])

        # check which function has been selected and update the table flags accordingly
        if index == 0:

            # peak has been turned off
            for i_row in range(1, 5):
                self.ui.table_widget.item(i_peak, i_row).setFlags(Qt.NoItemFlags)

        elif index == 1:

            # gaussian  has been selected
            for i_row in range(1, 4):
                self.ui.table_widget.item(i_peak, i_row).setFlags(
                    Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable)
            self.ui.table_widget.item(i_peak, 4).setFlags(Qt.NoItemFlags)

        elif index == 2:

            # lorentzian has been selected
            for i_row in range(1, 3):
                self.ui.table_widget.item(i_peak, i_row).setFlags(
                    Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable)
            self.ui.table_widget.item(i_peak, 3).setFlags(Qt.NoItemFlags)
            self.ui.table_widget.item(i_peak, 4).setFlags(
                Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable)

        elif index == 3:

            # voigt has been selected
            for i_row in range(1, 5):
                self.ui.table_widget.item(i_peak, i_row).setFlags(
                    Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable)
项目:crispy    作者:mretegan    | 项目源码 | 文件源码
def flags(self, index):
        """Return the active flags for the given index. Add editable
        flag to items in the first colum or greater.
        """
        activeFlags = (Qt.ItemIsEnabled | Qt.ItemIsSelectable |
                       Qt.ItemIsUserCheckable)

        node = self.getNode(index)
        column = index.column()

        if column > 0 and not node.childCount():
            activeFlags = activeFlags | Qt.ItemIsEditable

        return activeFlags
项目:deen    作者:takeshixx    | 项目源码 | 文件源码
def _process_row(self, y, row):
        cols = self.columnCount()
        for x, i in enumerate(range(0, len(row), self._width)):
            block = row[i:i+self._width]
            item = QTableWidgetItem(codecs.encode(block, 'hex').decode())
            item.setBackground(QBrush(QColor('lightgray')))
            item.setForeground(QBrush(QColor('black')))
            item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
            item.setData(Qt.UserRole, block)  # store original data
            if self._read_only:
                item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
            else:
                item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable)
            self.setItem(y, x, item)

        # process remaining, unfilled cells
        for j in range(x+1, cols):
            item = QTableWidgetItem()
            item.setBackground(QBrush(QColor('white')))
            item.setFlags(Qt.NoItemFlags)
            item.setTextAlignment(Qt.AlignHCenter)
            self.setItem(y, j, item)

        text = self._bytes_to_ascii(row)
        item = QTableWidgetItem(text)
        item.setData(Qt.UserRole, row)  # store original data
        item.setTextAlignment(Qt.AlignLeft| Qt.AlignVCenter)
        item.setBackground(QBrush(QColor('lightblue')))
        item.setForeground(QBrush(QColor('black')))
        if self._read_only:
            item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
        else:
            item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable)
        self.setItem(y, cols - 1, item)
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def setupItemsTable(self):
        self.itemsTable = QTableWidget(len(self.items), 2)

        for row, item in enumerate(self.items):
            name = QTableWidgetItem(item)
            name.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
            self.itemsTable.setItem(row, 0, name)
            quantity = QTableWidgetItem('1')
            self.itemsTable.setItem(row, 1, quantity)
项目:examples    作者:pyqt    | 项目源码 | 文件源码
def setupItemsTable(self):
        self.itemsTable = QTableWidget(len(self.items), 2)

        for row, item in enumerate(self.items):
            name = QTableWidgetItem(item)
            name.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
            self.itemsTable.setItem(row, 0, name)
            quantity = QTableWidgetItem('1')
            self.itemsTable.setItem(row, 1, quantity)
项目:OpenTutorials_PyQt    作者:RavenKyu    | 项目源码 | 文件源码
def flags(self, QModelIndex):
        """
        ?? ????? ?? ??
        """
        return Qt.ItemIsEditable | Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsTristate
项目:DownloaderForReddit    作者:MalloyDelacroix    | 项目源码 | 文件源码
def flags(self, QModelIndex):
        return Qt.ItemIsEditable | Qt.ItemIsSelectable | Qt.ItemIsEnabled
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def test_edit_rules(self):
        num_rules = len(self.message_type.ruleset)
        self.assertEqual(num_rules, self.dialog.ruleset_table_model.rowCount())
        self.dialog.ui.rbAssignAutomatically.click()
        self.assertFalse(self.message_type.assign_manually)
        self.dialog.ui.rbAssignManually.click()
        self.assertTrue(self.message_type.assign_manually)

        self.dialog.ui.rbAssignAutomatically.click()
        self.assertTrue(self.dialog.ui.btnAddRule.isEnabled())
        self.dialog.ui.btnAddRule.click()
        self.assertEqual(num_rules + 1, len(self.message_type.ruleset))
        self.assertEqual(num_rules + 1, self.dialog.ruleset_table_model.rowCount())

        model = self.dialog.ruleset_table_model
        model.setData(model.index(0, 0), 10, role=Qt.EditRole)
        self.assertEqual(self.message_type.ruleset[0].start, 9)
        model.setData(model.index(0, 1), 20, role=Qt.EditRole)
        self.assertEqual(self.message_type.ruleset[0].end, 20)
        model.setData(model.index(0, 2), 2, role=Qt.EditRole)
        self.assertEqual(self.message_type.ruleset[0].value_type, 2)
        model.setData(model.index(0, 3), 2, role=Qt.EditRole)
        model.setData(model.index(0, 4), "10101", role=Qt.EditRole)
        self.assertEqual(self.message_type.ruleset[0].target_value, "10101")

        for i in range(model.rowCount()):
            for j in range(model.columnCount()):
                self.assertEqual(model.flags(model.index(i, j)), Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable)

        self.dialog.ui.btnRemoveRule.click()
        self.assertEqual(num_rules, len(self.message_type.ruleset))
        self.assertEqual(num_rules, self.dialog.ruleset_table_model.rowCount())
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def flags(self, index):
        return Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsUserCheckable
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def flags(self, index):
        return Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsUserCheckable
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def flags(self, index: QModelIndex):
        if not index.isValid():
            return Qt.ItemIsDropEnabled
        return Qt.ItemIsEditable | Qt.ItemIsEnabled | Qt.ItemIsSelectable | \
               Qt.ItemIsUserCheckable | Qt.ItemIsDragEnabled | Qt.ItemIsDropEnabled
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def flags(self, QModelIndex):
        return Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsEditable
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def flags(self, index):
        return Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsUserCheckable | \
               Qt.ItemIsEditable | Qt.ItemIsDragEnabled
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def flags(self, index: QModelIndex):
        if not index.isValid():
            return Qt.ItemIsEnabled

        return Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsDragEnabled | Qt.ItemIsDropEnabled
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def flags(self, index: QModelIndex):
        if not index.isValid():
            return Qt.ItemIsEnabled

        return Qt.ItemIsEnabled | Qt.ItemIsDropEnabled | Qt.ItemIsSelectable | Qt.ItemIsDragEnabled | Qt.ItemIsEditable
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def flags(self, index: QModelIndex):
        return Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def flags(self, index: QModelIndex):
        return Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable
项目:fomod-designer    作者:GandaG    | 项目源码 | 文件源码
def write_attribs(self):
        self.text = self.properties["<node_text>"].value
        if self.text.startswith("<designer.metadata.do.not.edit>"):
            self.getparent().model_item.takeRow(self.model_item.row())
        else:
            self.model_item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsDragEnabled | Qt.ItemIsEnabled)
项目:pyqt5-example    作者:guinslym    | 项目源码 | 文件源码
def setupItemsTable(self):
        self.itemsTable = QTableWidget(len(self.items), 2)

        for row, item in enumerate(self.items):
            name = QTableWidgetItem(item)
            name.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
            self.itemsTable.setItem(row, 0, name)
            quantity = QTableWidgetItem('1')
            self.itemsTable.setItem(row, 1, quantity)
项目:fomod-designer    作者:GandaG    | 项目源码 | 文件源码
def init(self, name, tag, allowed_instances,
             sort_order="0",
             allowed_children=None,
             properties=None,
             wizard=None,
             required_children=None,
             either_children_group=None,
             at_least_one_children_group=None,
             name_editable=False,
             ):

        if not properties:
            properties = OrderedDict()
        if not allowed_children:
            allowed_children = ()
        if not required_children:
            required_children = ()
        if not either_children_group:
            either_children_group = ()
        if not at_least_one_children_group:
            at_least_one_children_group = ()

        self.name = name
        self.tag = tag
        self.sort_order = sort_order
        self.properties = properties
        self.allowed_children = allowed_children
        self.required_children = required_children
        self.either_children_group = either_children_group
        self.at_least_one_children_group = at_least_one_children_group
        self.hidden_children = []
        self.is_hidden = False
        self.allowed_instances = allowed_instances
        self.wizard = wizard
        self.metadata = {}
        self.user_sort_order = "0".zfill(7)

        self.model_item = NodeStandardItem(self)
        self.model_item.setText(self.name)
        if allowed_instances > 1 or not allowed_instances:
            self.model_item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsDragEnabled | Qt.ItemIsEnabled | Qt.ItemIsEditable)
        else:
            self.model_item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsDropEnabled | Qt.ItemIsEnabled | Qt.ItemIsEditable)
        self.model_item.setEditable(name_editable)