Python PyQt5.QtCore.Qt.ItemIsEnabled() Examples

The following are 30 code examples of PyQt5.QtCore.Qt.ItemIsEnabled(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PyQt5.QtCore.Qt , or try the search function .
Example #1
Source File: gui.py    From pbtk with GNU General Public License v3.0 9 votes vote down vote up
def load_endpoints(self):
        self.choose_endpoint.endpoints.clear()
        
        for name in listdir(str(BASE_PATH / 'endpoints')):
            if name.endswith('.json'):
                item = QListWidgetItem(name.split('.json')[0], self.choose_endpoint.endpoints)
                item.setFlags(item.flags() & ~Qt.ItemIsEnabled)
                
                pb_msg_to_endpoints = defaultdict(list)
                with open(str(BASE_PATH / 'endpoints' / name)) as fd:
                    for endpoint in load(fd, object_pairs_hook=OrderedDict):
                        pb_msg_to_endpoints[endpoint['request']['proto_msg'].split('.')[-1]].append(endpoint)
                
                for pb_msg, endpoints in pb_msg_to_endpoints.items():
                    item = QListWidgetItem(' ' * 4 + pb_msg, self.choose_endpoint.endpoints)
                    item.setFlags(item.flags() & ~Qt.ItemIsEnabled)
                    
                    for endpoint in endpoints:
                        path_and_qs = '/' + endpoint['request']['url'].split('/', 3).pop()
                        item = QListWidgetItem(' ' * 8 + path_and_qs, self.choose_endpoint.endpoints)
                        item.setData(Qt.UserRole, endpoint)
        
        self.set_view(self.choose_endpoint) 
Example #2
Source File: LogBlockDebugTab.py    From crazyflie-clients-python with GNU General Public License v2.0 6 votes vote down vote up
def _update_tree(self, conf, value):
        """Update the block tree"""
        self._block_tree.clear()
        for block in self._helper.cf.log.log_blocks:
            item = QtWidgets.QTreeWidgetItem()
            item.setFlags(Qt.ItemIsEnabled |
                          Qt.ItemIsSelectable)
            item.setData(0, Qt.DisplayRole, block.id)
            item.setData(1, Qt.EditRole, block.name)
            item.setData(2, Qt.DisplayRole, (block.period_in_ms))
            item.setData(3, Qt.DisplayRole, block.added)
            item.setData(4, Qt.EditRole, block.started)
            item.setData(5, Qt.EditRole, block.err_no)
            for var in block.variables:
                subItem = QtWidgets.QTreeWidgetItem()
                subItem.setFlags(Qt.ItemIsEnabled |
                                 Qt.ItemIsSelectable)
                subItem.setData(6, Qt.EditRole, var.name)
                item.addChild(subItem)

            self._block_tree.addTopLevelItem(item)
            self._block_tree.expandItem(item) 
Example #3
Source File: wallet_data_models.py    From dash-masternode-tool with MIT License 6 votes vote down vote up
def flags(self, index):
        return Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsEditable 
Example #4
Source File: import_survey.py    From QualCoder with MIT License 6 votes vote down vote up
def fill_tableWidget(self):
        ''' Fill table widget with data. '''

        numRows = self.ui.tableWidget.rowCount()
        for row in range(0, numRows):
            self.ui.tableWidget.removeRow(0)
        self.ui.tableWidget.setColumnCount(len(self.fields))
        for c, field in enumerate(self.fields):
            item = QtWidgets.QTableWidgetItem(field + "\n" + self.fields_type[c] + "\n")
            self.ui.tableWidget.setHorizontalHeaderItem(c, item)
        self.ui.tableWidget.setRowCount(len(self.data))
        for row in range(0, len(self.data)):
            for col in range(0, len(self.fields)):
                value = str(self.data[row][col])
                item = QtWidgets.QTableWidgetItem(value)
                item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)  # not editatble
                self.ui.tableWidget.setItem(row, col, item)
        self.ui.tableWidget.resizeColumnsToContents()
        for col in range(0, self.ui.tableWidget.columnCount()):
            if self.ui.tableWidget.columnWidth(col) > 200:
                self.ui.tableWidget.setColumnWidth(col, 200) 
Example #5
Source File: file_table.py    From parsec-cloud with GNU Affero General Public License v3.0 6 votes vote down vote up
def add_parent_workspace(self):
        row_idx = self.rowCount()
        self.insertRow(row_idx)
        items = []
        p = Pixmap(":/icons/images/material/arrow_upward.svg")
        p.replace_color(QColor(0, 0, 0), QColor(0x99, 0x99, 0x99))
        items.append(CustomTableItem(QIcon(p), ""))
        items.append(CustomTableItem(_("TEXT_FILE_TREE_PARENT_WORKSPACE")))
        items.append(CustomTableItem())
        items.append(CustomTableItem())
        items.append(CustomTableItem())

        for col, item in zip(Column, items):
            item.setData(NAME_DATA_INDEX, "")
            item.setData(TYPE_DATA_INDEX, FileType.ParentWorkspace)
            item.setData(UUID_DATA_INDEX, None)
            item.setFlags(Qt.ItemIsEnabled)
            self.setItem(row_idx, col, item) 
Example #6
Source File: dlg_findCollTx.py    From PIVX-SPMT with MIT License 6 votes vote down vote up
def display_utxos(self):
        def item(value):
            item = QTableWidgetItem(value)
            item.setTextAlignment(Qt.AlignCenter)
            item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
            return item

        self.tableW.setRowCount(len(self.utxos))
        for row, utxo in enumerate(self.utxos):
            pivxAmount = round(int(utxo.get('satoshis', 0))/1e8, 8)
            self.tableW.setItem(row, 0, item(str(pivxAmount)))
            self.tableW.setItem(row, 1, item(str(utxo['confirmations'])))
            self.tableW.setItem(row, 2, item(utxo.get('txid', None)))
            self.tableW.setItem(row, 3, item(str(utxo.get('vout', None))))

        if len(self.utxos):
            self.tableW.resizeColumnsToContents()
            self.lblMessage.setVisible(False)
            self.tableW.horizontalHeader().setSectionResizeMode(2, QHeaderView.Stretch)

        else:
            self.lblMessage.setText('<b style="color:purple">No UTXO found for current address.\nEnter tx manually</b>')
            self.lblMessage.setVisible(True) 
Example #7
Source File: file_table.py    From parsec-cloud with GNU Affero General Public License v3.0 6 votes vote down vote up
def add_parent_folder(self):
        row_idx = self.rowCount()
        self.insertRow(row_idx)
        items = []
        p = Pixmap(":/icons/images/material/arrow_upward.svg")
        p.replace_color(QColor(0, 0, 0), QColor(0x99, 0x99, 0x99))
        items.append(CustomTableItem(QIcon(p), ""))
        items.append(CustomTableItem(_("TEXT_FILE_TREE_PARENT_FOLDER")))
        items.append(CustomTableItem())
        items.append(CustomTableItem())
        items.append(CustomTableItem())

        for col, item in zip(Column, items):
            item.setData(NAME_DATA_INDEX, "")
            item.setData(TYPE_DATA_INDEX, FileType.ParentFolder)
            item.setData(UUID_DATA_INDEX, None)
            item.setFlags(Qt.ItemIsEnabled)
            self.setItem(row_idx, col, item) 
Example #8
Source File: OptionsDialog.py    From urh with GNU General Public License v3.0 6 votes vote down vote up
def flags(self, index: QModelIndex):
        if not index.isValid():
            return None

        j = index.column()
        device = self.get_device_at(index.row())
        if j == 0 and not device.has_native_backend and not device.has_gnuradio_backend:
            return Qt.NoItemFlags

        if j in [1, 2, 3] and not device.is_enabled:
            return Qt.NoItemFlags

        if j == 2 and not device.has_native_backend:
            return Qt.NoItemFlags

        if j == 3 and not device.has_gnuradio_backend:
            return Qt.NoItemFlags

        flags = Qt.ItemIsEnabled

        if j in [0, 2, 3]:
            flags |= Qt.ItemIsUserCheckable

        return flags 
Example #9
Source File: completionmodel.py    From qutebrowser with GNU General Public License v3.0 6 votes vote down vote up
def flags(self, index):
        """Return the item flags for index.

        Override QAbstractItemModel::flags.

        Return: The item flags, or Qt.NoItemFlags on error.
        """
        if not index.isValid():
            return Qt.NoItemFlags
        if index.parent().isValid():
            # item
            return (Qt.ItemIsEnabled | Qt.ItemIsSelectable |
                    Qt.ItemNeverHasChildren)
        else:
            # category
            return Qt.NoItemFlags 
Example #10
Source File: project.py    From BORIS with GNU General Public License v3.0 6 votes vote down vote up
def pb_clone_behavior_clicked(self):
        """
        clone the selected configuration
        """
        if not self.twBehaviors.selectedIndexes():
            QMessageBox.about(self, programName, "First select a behavior")
        else:
            self.twBehaviors.setRowCount(self.twBehaviors.rowCount() + 1)

            row = self.twBehaviors.selectedIndexes()[0].row()
            for field in behavioursFields:
                item = QTableWidgetItem(self.twBehaviors.item(row, behavioursFields[field]))
                self.twBehaviors.setItem(self.twBehaviors.rowCount() - 1, behavioursFields[field], item)
                if field in [TYPE, "category", "excluded", "coding map", "modifiers"]:
                    item.setFlags(Qt.ItemIsEnabled)
                    item.setBackground(QColor(230, 230, 230)) 
Example #11
Source File: project.py    From BORIS with GNU General Public License v3.0 6 votes vote down vote up
def pbAddBehavior_clicked(self):
        """
        add new behavior to ethogram
        """

        try:
            # Add behavior to table
            self.twBehaviors.setRowCount(self.twBehaviors.rowCount() + 1)
            for field_type in behavioursFields:
                item = QTableWidgetItem()
                if field_type == TYPE:
                    item.setText("Point event")

                if field_type in [TYPE, "category", "excluded", "coding map", "modifiers"]:
                    item.setFlags(Qt.ItemIsEnabled)
                    item.setBackground(QColor(230, 230, 230))
                self.twBehaviors.setItem(self.twBehaviors.rowCount() - 1, behavioursFields[field_type], item)
        except Exception:
            logging.critical(f"Error:<br><b>{sys.exc_info()[1]}</b>")
            dialog.error_message("adding a new behavior", sys.exc_info()) 
Example #12
Source File: dlg_selectMNs.py    From PIVX-SPMT with MIT License 5 votes vote down vote up
def loadMasternodes(self):
        for row, mn in enumerate(self.main_wnd.caller.masternode_list):
            name = mn.get('name')
            txid = mn.get('collateral').get('txid')
            item = masternodeItem(name, txid)
            item.setTextAlignment(Qt.AlignCenter)
            item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
            self.ui.mnList.setItem(row, 0, item)
            # check if already selected
            if name in [x[1] for x in self.main_wnd.votingMasternodes]:
                item.setSelected(True) 
Example #13
Source File: DyTreeWidget.py    From DevilYuan with MIT License 5 votes vote down vote up
def __InitFieldItem(self, parent, item):
        treeItem = QTreeWidgetItem(parent)
        treeItem.setText(0, item)
        treeItem.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled | Qt.ItemIsSelectable)
        treeItem.setCheckState(0, Qt.Unchecked)

        return treeItem 
Example #14
Source File: ParticipantTableModel.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def flags(self, index: QModelIndex):
        if not index.isValid():
            return Qt.NoItemFlags

        return Qt.ItemIsEditable | Qt.ItemIsEnabled | Qt.ItemIsSelectable 
Example #15
Source File: SectionComboBoxDelegate.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def add_parent_item(self, text):
        item = QStandardItem(text)
        item.setFlags(item.flags() & ~(Qt.ItemIsEnabled | Qt.ItemIsSelectable))
        item.setData("parent", Qt.AccessibleDescriptionRole)

        font = item.font()
        font.setBold(True)
        item.setFont(font)

        self.model().appendRow(item) 
Example #16
Source File: FuzzingTableModel.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def flags(self, QModelIndex):
        return Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsEditable 
Example #17
Source File: ParticipantListModel.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def flags(self, index):
        return Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsUserCheckable 
Example #18
Source File: test_message_type_options_gui.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
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()) 
Example #19
Source File: ProtocolTreeModel.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #20
Source File: PluginListModel.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def flags(self, index):
        return Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsUserCheckable 
Example #21
Source File: RulesetTableModel.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def flags(self, index: QModelIndex):
        return Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable 
Example #22
Source File: PLabelTableModel.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def flags(self, index):
        if not index.isValid():
            return Qt.NoItemFlags

        try:
            _ = self.message_type[index.row()]
        except IndexError:
            return Qt.NoItemFlags

        return Qt.ItemIsEditable | Qt.ItemIsEnabled | Qt.ItemIsSelectable 
Example #23
Source File: FieldTypeTableModel.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def flags(self, index: QModelIndex):
        return Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable 
Example #24
Source File: ProtocolTableModel.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def flags(self, index: QModelIndex):
        if index.isValid():
            alignment_offset = self.get_alignment_offset_at(index.row())
            if index.column() < alignment_offset:
                return Qt.ItemIsSelectable | Qt.ItemIsEnabled

            if self.is_writeable:
                return Qt.ItemIsEnabled | Qt.ItemIsEditable | Qt.ItemIsSelectable
            else:
                return Qt.ItemIsEnabled | Qt.ItemIsSelectable
        else:
            return Qt.NoItemFlags 
Example #25
Source File: ChecksumWidget.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def flags(self, index):
            if not index.isValid():
                return Qt.NoItemFlags

            try:
                _ = self.checksum_label.data_ranges[index.row()]
            except IndexError:
                return Qt.NoItemFlags

            return Qt.ItemIsEditable | Qt.ItemIsEnabled | Qt.ItemIsSelectable 
Example #26
Source File: qtmodels.py    From QualCoder with MIT License 5 votes vote down vote up
def flags(self,index):
        if self.checkable:
            return  Qt.ItemIsUserCheckable | Qt.ItemIsEnabled 
        else:
            return  Qt.ItemIsEnabled | Qt.ItemIsSelectable 
Example #27
Source File: ModulationParametersDialog.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parameters: list, modulation_type: str, parent=None):
        super().__init__(parent)
        self.ui = Ui_DialogModulationParameters()
        self.ui.setupUi(self)
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setWindowFlags(Qt.Window)

        self.parameters = parameters
        self.num_bits = int(math.log2(len(parameters)))

        if "FSK" in modulation_type:
            self.ui.tblSymbolParameters.setItemDelegateForColumn(1, KillerSpinBoxDelegate(-1e12, 1e12, self))
            self.ui.tblSymbolParameters.horizontalHeaderItem(1).setText("Frequency in Hz")
        elif "ASK" in modulation_type:
            self.ui.tblSymbolParameters.horizontalHeaderItem(1).setText("Amplitude")
            self.ui.tblSymbolParameters.setItemDelegateForColumn(1, SpinBoxDelegate(0, 100, self, "%"))
        elif "PSK" in modulation_type:
            self.ui.tblSymbolParameters.setItemDelegateForColumn(1, SpinBoxDelegate(-360, 360, self, "°"))
            self.ui.tblSymbolParameters.horizontalHeaderItem(1).setText("Phase")

        fmt = "{0:0" + str(self.num_bits) + "b}"
        self.ui.tblSymbolParameters.setRowCount(len(parameters))
        for i, parameter in enumerate(parameters):
            item = QTableWidgetItem(fmt.format(i))
            font = item.font()
            font.setBold(True)
            item.setFont(font)
            item.setFlags(Qt.ItemIsEnabled)
            self.ui.tblSymbolParameters.setItem(i, 0, item)

            item = QTableWidgetItem()
            item.setData(Qt.DisplayRole, self.parameters[i])
            self.ui.tblSymbolParameters.setItem(i, 1, item)
            self.ui.tblSymbolParameters.openPersistentEditor(self.ui.tblSymbolParameters.item(i, 1))

        self.create_connects() 
Example #28
Source File: qtmodels.py    From QualCoder with MIT License 5 votes vote down vote up
def flags(self,index):
        if self.checkable:
            return  Qt.ItemIsUserCheckable | Qt.ItemIsEnabled 
        else:
            return  Qt.ItemIsEnabled | Qt.ItemIsSelectable 
Example #29
Source File: __init__.py    From binja_dynamics with Apache License 2.0 5 votes vote down vote up
def _makewidget(val, center=False):
    """ Small helper function that builds a TableWidgetItem and sets up the font the way we want"""
    out = QtWidgets.QTableWidgetItem(str(val))
    out.setFlags(Qt.ItemIsEnabled)
    out.setFont(monospace)
    if(center):
        out.setTextAlignment(Qt.AlignCenter)
    return out 
Example #30
Source File: GeneratorTableModel.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def flags(self, index: QModelIndex):
        if not index.isValid():
            return Qt.ItemIsEnabled

        return Qt.ItemIsEnabled | Qt.ItemIsDropEnabled | Qt.ItemIsSelectable | Qt.ItemIsDragEnabled | Qt.ItemIsEditable