Python PyQt5.QtCore.Qt.ItemIsEditable() Examples
The following are 30
code examples of PyQt5.QtCore.Qt.ItemIsEditable().
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: CheckBoxDelegateQt.py From KStock with GNU General Public License v3.0 | 6 votes |
def paint(self, painter, option, index): ''' Paint a checkbox without the label. ''' checked = bool(index.model().data(index, Qt.DisplayRole)) opts = QStyleOptionButton() opts.state |= QStyle.State_Active if index.flags() & Qt.ItemIsEditable: opts.state |= QStyle.State_Enabled else: opts.state |= QStyle.State_ReadOnly if checked: opts.state |= QStyle.State_On else: opts.state |= QStyle.State_Off opts.rect = self.getCheckBoxRect(option) QApplication.style().drawControl(QStyle.CE_CheckBox, opts, painter)
Example #2
Source File: CheckBoxDelegateQt.py From KStock with GNU General Public License v3.0 | 6 votes |
def editorEvent(self, event, model, option, index): ''' Change the data in the model and the state of the checkbox if the user presses the left mouse button and this cell is editable. Otherwise do nothing. ''' if not (index.flags() & Qt.ItemIsEditable): return False if event.button() == Qt.LeftButton: if event.type() == QEvent.MouseButtonRelease: if self.getCheckBoxRect(option).contains(event.pos()): self.setModelData(None, model, index) return True elif event.type() == QEvent.MouseButtonDblClick: if self.getCheckBoxRect(option).contains(event.pos()): return True return False
Example #3
Source File: PLabelTableModel.py From urh with GNU General Public License v3.0 | 5 votes |
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 #4
Source File: autokey_treewidget.py From autokey with GNU General Public License v3.0 | 5 votes |
def __init__(self, parent: Optional[FolderWidgetItem], script: model.Script): QTreeWidgetItem.__init__(self) self.script = script self.setIcon(0, QIcon.fromTheme("text-x-python")) self.setText(0, script.description) self.setText(1, script.get_abbreviations()) self.setText(2, script.get_hotkey_string()) self.setData(3, Qt.UserRole, script) if parent is not None: # TODO: Script without parent allowed? This is should be an error. parent.addChild(self) self.setFlags(self.flags() | Qt.ItemIsEditable)
Example #5
Source File: tabmodel_z5.py From python101 with MIT License | 5 votes |
def flags(self, index): """ Zwraca właściwości kolumn tabeli """ flags = super(TabModel, self).flags(index) j = index.column() if j == 1: flags |= Qt.ItemIsEditable elif j == 3 or j == 4: flags |= Qt.ItemIsUserCheckable return flags
Example #6
Source File: tabmodel_z6.py From python101 with MIT License | 5 votes |
def flags(self, index): """ Zwraca właściwości kolumn tabeli """ flags = super(TabModel, self).flags(index) j = index.column() if j == 1: flags |= Qt.ItemIsEditable elif j == 3 or j == 4: flags |= Qt.ItemIsUserCheckable return flags
Example #7
Source File: SignalsExample.py From PyQt with GNU General Public License v3.0 | 5 votes |
def initData(self): # 初始化模拟数据 for i in range(100): item = QListWidgetItem('Item {0}'.format(i), self.listWidget) if i % 3 == 0: item.setFlags(item.flags() | Qt.ItemIsEditable)
Example #8
Source File: planned_model.py From TreeNote with GNU General Public License v3.0 | 5 votes |
def flags(self, index): return Qt.ItemIsEditable | Qt.ItemIsEnabled | Qt.ItemIsSelectable
Example #9
Source File: project.py From BORIS with GNU General Public License v3.0 | 5 votes |
def variableTypeChanged(self, row): """ variable type combobox changed """ if self.twVariables.cellWidget(row, tw_indVarFields.index("type")).currentText() == SET_OF_VALUES: if self.twVariables.item(row, tw_indVarFields.index("possible values")).text() == "NA": self.twVariables.item(row, tw_indVarFields.index("possible values")).setText("Double-click to add values") else: # check if set of values defined if self.twVariables.item(row, tw_indVarFields.index("possible values")).text() not in ["NA", "Double-click to add values"]: if dialog.MessageDialog(programName, "Erase the set of values?", [YES, CANCEL]) == CANCEL: self.twVariables.cellWidget(row, tw_indVarFields.index("type")).setCurrentIndex(SET_OF_VALUES_idx) return else: self.twVariables.item(row, tw_indVarFields.index("possible values")).setText("NA") else: self.twVariables.item(row, tw_indVarFields.index("possible values")).setText("NA") if self.twVariables.cellWidget(row, tw_indVarFields.index("type")).currentText() == TIMESTAMP: self.twVariables.item(row, tw_indVarFields.index("default value")).setFlags(Qt.ItemIsEnabled) else: self.twVariables.item(row, tw_indVarFields.index("default value")).setFlags( Qt.ItemIsSelectable | Qt.ItemIsEditable | Qt.ItemIsEnabled) # check compatibility between variable type and default value if not self.check_variable_default_value(self.twVariables.item(row, tw_indVarFields.index("default value")).text(), self.twVariables.cellWidget(row, tw_indVarFields.index("type")).currentIndex()): QMessageBox.warning(self, programName + " - Independent variables error", "The default value ({0}) of variable <b>{1}</b> is not compatible with variable type".format( self.twVariables.item(row, tw_indVarFields.index("default value")).text(), self.twVariables.item(row, tw_indVarFields.index("label")).text()))
Example #10
Source File: ChecksumWidget.py From urh with GNU General Public License v3.0 | 5 votes |
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 #11
Source File: ProtocolTableModel.py From urh with GNU General Public License v3.0 | 5 votes |
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 #12
Source File: LabelValueTableModel.py From urh with GNU General Public License v3.0 | 5 votes |
def flags(self, index: QModelIndex): flags = super().flags(index) if index.column() in (0, 1, 2, 3): flags |= Qt.ItemIsEditable if index.column() == 0: flags |= Qt.ItemIsUserCheckable return flags
Example #13
Source File: GeneratorListModel.py From urh with GNU General Public License v3.0 | 5 votes |
def flags(self, index): flags = Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsEditable try: lbl = self.labels[index.row()] except IndexError: return flags if len(lbl.fuzz_values) > 1: flags |= Qt.ItemIsUserCheckable else: lbl.fuzz_me = False return flags
Example #14
Source File: autokey_treewidget.py From autokey with GNU General Public License v3.0 | 5 votes |
def __init__(self, parent: Optional[FolderWidgetItem], phrase: model.Phrase): QTreeWidgetItem.__init__(self) self.phrase = phrase self.setIcon(0, QIcon.fromTheme("text-x-generic")) self.setText(0, phrase.description) self.setText(1, phrase.get_abbreviations()) self.setText(2, phrase.get_hotkey_string()) self.setData(3, Qt.UserRole, phrase) if parent is not None: # TODO: Phrase without parent allowed? This is should be an error. parent.addChild(self) self.setFlags(self.flags() | Qt.ItemIsEditable)
Example #15
Source File: SimulatorMessageFieldModel.py From urh with GNU General Public License v3.0 | 5 votes |
def flags(self, index: QModelIndex): row, col = index.row(), index.column() label = self.message_type[row] # type: SimulatorProtocolLabel if col == 2 and label.is_checksum_label: return Qt.ItemIsSelectable flags = Qt.ItemIsEnabled | Qt.ItemIsSelectable if not(col == 3 and label.value_type_index == 1): flags |= Qt.ItemIsEditable return flags
Example #16
Source File: SimulatorMessageTableModel.py From urh with GNU General Public License v3.0 | 5 votes |
def flags(self, index: QModelIndex): if index.isValid(): if self.is_writeable: return Qt.ItemIsEnabled | Qt.ItemIsEditable | Qt.ItemIsSelectable else: return Qt.ItemIsEnabled | Qt.ItemIsSelectable else: return Qt.NoItemFlags
Example #17
Source File: ParticipantTableModel.py From urh with GNU General Public License v3.0 | 5 votes |
def flags(self, index: QModelIndex): if not index.isValid(): return Qt.NoItemFlags return Qt.ItemIsEditable | Qt.ItemIsEnabled | Qt.ItemIsSelectable
Example #18
Source File: util.py From urh with GNU General Public License v3.0 | 5 votes |
def create_table_item(content): item = QTableWidgetItem(str(content)) item.setFlags(item.flags() & ~Qt.ItemIsEditable) return item
Example #19
Source File: test_message_type_options_gui.py From urh with GNU General Public License v3.0 | 5 votes |
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 #20
Source File: ParamTab.py From crazyflie-clients-python with GNU General Public License v2.0 | 5 votes |
def flags(self, index): """Re-implemented function for getting the flags for a certain index""" flag = super(ParamBlockModel, self).flags(index) node = index.internalPointer() if index.column() == 3 and node.parent and node.access == "RW": flag |= Qt.ItemIsEditable return flag
Example #21
Source File: __init__.py From corrscope with BSD 2-Clause "Simplified" License | 5 votes |
def flags(self, index: QModelIndex): if not index.isValid(): return Qt.ItemIsEnabled return ( qc.QAbstractItemModel.flags(self, index) | Qt.ItemIsEditable | Qt.ItemNeverHasChildren )
Example #22
Source File: predefined_label.py From CNNArt with Apache License 2.0 | 5 votes |
def createGUI(self): length = len(self.labelHist) tableData = pandas.read_csv('configGUI/predefined_label.csv') self.table = QTableWidget(length, 2) self.table.setHorizontalHeaderLabels(["Label Name", "Label Color"]) self.table.verticalHeader().setVisible(True) self.table.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustToContents) self.table.cellDoubleClicked.connect(self.editCell) self.table.cellChanged.connect(self.cellChanged) for i in range(length): name = tableData.at[i,'label name'] nameItem = QTableWidgetItem(name) nameItem.setFlags(nameItem.flags() | Qt.ItemIsEditable) color = QColor(tableData.at[i,'label color']) colorItem = QTableWidgetItem() colorItem.setData(Qt.DisplayRole, color) colorItem.setFlags(colorItem.flags() | Qt.ItemIsEditable) self.table.setItem(i, 0, nameItem) self.table.setItem(i, 1, colorItem) self.table.resizeColumnToContents(0) self.layout = QGridLayout() self.layout.addWidget(self.table, 0, 0) self.setLayout(self.layout) self.setWindowTitle("Predefined Label Editor")
Example #23
Source File: ObjList.py From KStock with GNU General Public License v3.0 | 5 votes |
def flags(self, index): flags = QAbstractTableModel.flags(self, index) if not index.isValid(): return flags prop = self.getProperty(index) if prop is None: return flags flags |= Qt.ItemIsEnabled flags |= Qt.ItemIsSelectable mode = prop.get('mode', "Read/Write") if "Write" in mode: flags |= Qt.ItemIsEditable return flags
Example #24
Source File: qmodels.py From linux-show-player with GNU General Public License v3.0 | 5 votes |
def flags(self, index): return Qt.ItemIsEditable | Qt.ItemIsEnabled | Qt.ItemIsSelectable
Example #25
Source File: otomo_armor_editor.py From mhw_armor_edit with The Unlicense | 5 votes |
def flags(self, qindex: QModelIndex): if qindex.isValid(): if qindex.column() in (1, 2, 3): return super().flags(qindex) & ~Qt.ItemIsEditable return super().flags(qindex)
Example #26
Source File: shell_table_editor.py From mhw_armor_edit with The Unlicense | 5 votes |
def flags(self, index): if not index.isValid(): return super().flags(index) node = index.internalPointer() if isinstance(node, ShellTreeEntryNode) and index.column() in (1, 2, 3): return super().flags(index) | Qt.ItemIsEditable return super().flags(index)
Example #27
Source File: weapon_gun_editor.py From mhw_armor_edit with The Unlicense | 5 votes |
def flags(self, qindex): flags = super().flags(qindex) if qindex.column() in (WpDatGEntry.id.index, WpDatGEntry.gmd_name_index.index, WpDatGEntry.gmd_description_index): return flags & ~Qt.ItemIsEditable return flags
Example #28
Source File: ListModel.py From DownloaderForReddit with GNU General Public License v3.0 | 5 votes |
def flags(self, QModelIndex): return Qt.ItemIsEditable | Qt.ItemIsSelectable | Qt.ItemIsEnabled
Example #29
Source File: predefined_networks.py From CNNArt with Apache License 2.0 | 5 votes |
def createGUI(self): tableData = pd.read_csv('DLart/networks.csv') self.networkHist = [] for i in range(pd.DataFrame.count(tableData)['name']): self.networkHist.append(tableData.iloc[i]['name']) length = len(self.networkHist) self.table = QTableWidget(length, 2) self.table.setHorizontalHeaderLabels(["Network Name", "Network Path"]) self.table.verticalHeader().setVisible(True) self.table.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustToContents) self.table.cellDoubleClicked.connect(self.editCell) self.table.cellChanged.connect(self.cellChanged) for i in range(length): name = tableData.at[i,'name'] nameItem = QTableWidgetItem(name) nameItem.setFlags(nameItem.flags() | Qt.ItemIsEditable) path = tableData.at[i,'path'].replace(".", "/") + '.py' pathItem = QTableWidgetItem(path) self.table.setItem(i, 0, nameItem) self.table.setItem(i, 1, pathItem) self.table.resizeColumnToContents(0) self.table.horizontalHeader().setStretchLastSection(True) self.layout = QGridLayout() self.layout.addWidget(self.table, 0, 0) self.setLayout(self.layout) self.setWindowTitle("Predefined Neural Networks Editor")
Example #30
Source File: settings_model.py From CHATIMUSMAXIMUS with GNU General Public License v3.0 | 5 votes |
def flags(self, index): if not index.isValid(): return 0 if index.column() == 0: return Qt.ItemIsEnabled | Qt.ItemIsSelectable return Qt.ItemIsEditable | Qt.ItemIsEnabled | Qt.ItemIsSelectable