Python PyQt5.QtCore.Qt.CheckStateRole() Examples
The following are 30
code examples of PyQt5.QtCore.Qt.CheckStateRole().
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: ProtocolTreeModel.py From urh with GNU General Public License v3.0 | 6 votes |
def data(self, index: QModelIndex, role=None): item = self.getItem(index) if role == Qt.DisplayRole: return item.data() elif role == Qt.DecorationRole and item.is_group: return QIcon.fromTheme("folder") elif role == Qt.CheckStateRole: return item.show elif role == Qt.FontRole: if item.is_group and self.rootItem.index_of(item) in self.controller.active_group_ids: font = QFont() font.setBold(True) return font elif item.protocol in self.controller.selected_protocols: font = QFont() font.setBold(True) return font elif role == Qt.ToolTipRole: return item.data()
Example #2
Source File: MessageTypeTableModel.py From urh with GNU General Public License v3.0 | 6 votes |
def data(self, index, role=Qt.DisplayRole): row = index.row() if not index.isValid() or row >= len(self.message_types): return message_type = self.message_types[row] if role == Qt.DisplayRole: if index.column() == 0: return message_type.name elif index.column() == 1: return "" elif role == Qt.CheckStateRole: if index.column() == 0: return message_type.show elif index.column() == 1: return None elif role == Qt.EditRole: if index.column() == 0: return message_type.name elif role == Qt.FontRole and index.column() == 0: font = QFont() font.setBold(index.row() in self.selected_message_type_indices) return font
Example #3
Source File: ParticipantListModel.py From urh with GNU General Public License v3.0 | 6 votes |
def data(self, index: QModelIndex, role=None): row = index.row() if role == Qt.DisplayRole: if row == 0: return "not assigned" else: try: return str(self.participants[row-1]) except IndexError: return None elif role == Qt.CheckStateRole: if row == 0: return Qt.Checked if self.show_unassigned else Qt.Unchecked else: try: return Qt.Checked if self.participants[row-1].show else Qt.Unchecked except IndexError: return None
Example #4
Source File: qt.py From mint-amazon-tagger with GNU General Public License v3.0 | 6 votes |
def data(self, index, role): if not index.isValid(): return None if index.column() == 0: value = ('' if self.my_data[index.row()][index.column() + 1] else 'Skip') else: value = self.my_data[index.row()][index.column() + 1] if role == Qt.EditRole: return value elif role == Qt.DisplayRole: return value elif role == Qt.CheckStateRole: if index.column() == 0: return ( Qt.Checked if self.my_data[index.row()][index.column() + 1] else Qt.Unchecked)
Example #5
Source File: GeneratorListModel.py From urh with GNU General Public License v3.0 | 6 votes |
def data(self, index, role=Qt.DisplayRole): row = index.row() if row >= len(self.labels): return if role == Qt.DisplayRole: nfuzzval = len(self.labels[row].fuzz_values) nfuzzval = str(nfuzzval - 1) if nfuzzval > 1 else "empty" try: return self.labels[row].name + " (" + nfuzzval + ")" except TypeError: return "" elif role == Qt.CheckStateRole: return self.labels[row].fuzz_me elif role == Qt.BackgroundColorRole: return settings.LABEL_COLORS[self.labels[row].color_index]
Example #6
Source File: tabmodel_z5.py From python101 with MIT License | 6 votes |
def data(self, index, rola=Qt.DisplayRole): """ WyĆwietlanie danych """ i = index.row() j = index.column() if rola == Qt.DisplayRole: return '{0}'.format(self.tabela[i][j]) elif rola == Qt.CheckStateRole and (j == 3 or j == 4): if self.tabela[i][j]: return Qt.Checked else: return Qt.Unchecked elif rola == Qt.EditRole and j == 1: return self.tabela[i][j] else: return QVariant()
Example #7
Source File: anchor_position_dialog.py From crazyflie-clients-python with GNU General Public License v2.0 | 6 votes |
def data(self, index, role=None): value = self._anchor_positions[index.row()][index.column()] if index.isValid(): if index.column() == 0: if role == Qt.CheckStateRole: return QVariant(value) elif index.column() == 1: if role == Qt.DisplayRole: return QVariant(value) else: if role == Qt.DisplayRole: return QVariant('%.2f' % (value)) elif role == Qt.EditRole: return QVariant(value) elif role == Qt.BackgroundRole: return self._get_background(index.row(), index.column()) return QVariant()
Example #8
Source File: tabmodel_z6.py From python101 with MIT License | 6 votes |
def data(self, index, rola=Qt.DisplayRole): """ WyĆwietlanie danych """ i = index.row() j = index.column() if rola == Qt.DisplayRole: return '{0}'.format(self.tabela[i][j]) elif rola == Qt.CheckStateRole and (j == 3 or j == 4): if self.tabela[i][j]: return Qt.Checked else: return Qt.Unchecked elif rola == Qt.EditRole and j == 1: return self.tabela[i][j] else: return QVariant()
Example #9
Source File: LabelValueTableModel.py From urh with GNU General Public License v3.0 | 6 votes |
def setData(self, index: QModelIndex, value, role=None): row = index.row() lbl = self.display_labels[row] if role == Qt.EditRole and index.column() in (0, 1, 2, 3): if index.column() == 0: lbl.name = value new_field_type = self.controller.field_types_by_caption.get(value, None) self.controller.active_message_type.change_field_type_of_label(lbl, new_field_type) elif index.column() == 1: lbl.color_index = value self.label_color_changed.emit(lbl) elif index.column() == 2: lbl.display_format_index = value elif index.column() == 3: lbl.display_order_str = value self.dataChanged.emit(self.index(row, 0), self.index(row, self.columnCount())) elif role == Qt.CheckStateRole and index.column() == 0: lbl.show = value self.protolabel_visibility_changed.emit(lbl) return True
Example #10
Source File: OptionsDialog.py From urh with GNU General Public License v3.0 | 6 votes |
def setData(self, index: QModelIndex, value, role=None): if not index.isValid(): return False i, j = index.row(), index.column() device = self.get_device_at(i) if role == Qt.CheckStateRole: enabled = bool(value) if j == 0: device.is_enabled = enabled if j == 2: if enabled and device.has_native_backend: device.selected_backend = Backends.native elif not enabled and device.has_gnuradio_backend: device.selected_backend = Backends.grc elif j == 3: if enabled and device.has_gnuradio_backend: device.selected_backend = Backends.grc elif not enabled and device.has_native_backend: device.selected_backend = Backends.native self.update() device.write_settings() return True
Example #11
Source File: test_generator.py From urh with GNU General Public License v3.0 | 5 votes |
def test_fuzzing_label_list_view(self): self.add_signal_to_form("ask.complex") gframe = self.form.generator_tab_controller # type: GeneratorTabController gframe.ui.cbViewType.setCurrentText("Bit") self.add_signal_to_generator(0) gframe.ui.tabWidget.setCurrentWidget(gframe.ui.tab_fuzzing) gframe.ui.tableMessages.selectRow(0) self.assertEqual(gframe.label_list_model.rowCount(), 0) gframe.create_fuzzing_label(0, 10, 20) self.assertEqual(gframe.label_list_model.rowCount(), 1) model = gframe.label_list_model lbl = model.labels[0] self.assertTrue(bool(lbl.fuzz_me)) self.assertEqual(len(lbl.fuzz_values), 1) self.assertTrue(bool(model.data(model.index(0,0), role=Qt.CheckStateRole)), True) model.setData(model.index(0,0), Qt.Unchecked, role=Qt.CheckStateRole) self.assertFalse(lbl.fuzz_me) model.setData(model.index(0,0), "test", role=Qt.EditRole) self.assertEqual("test (empty)", model.data(model.index(0,0), role=Qt.DisplayRole)) lbl.fuzz_values.append("101010") model.update() self.assertEqual("test (1)", model.data(model.index(0, 0), role=Qt.DisplayRole))
Example #12
Source File: ParticipantListModel.py From urh with GNU General Public License v3.0 | 5 votes |
def setData(self, index: QModelIndex, value, role=None): if index.row() == 0 and role == Qt.CheckStateRole: if bool(value) != self.show_unassigned: self.show_unassigned = bool(value) self.show_state_changed.emit() elif role == Qt.CheckStateRole: try: if self.participants[index.row()-1].show != value: self.participants[index.row()-1].show = value self.show_state_changed.emit() except IndexError: return False return True
Example #13
Source File: SimulatorParticipantListModel.py From urh with GNU General Public License v3.0 | 5 votes |
def data(self, index: QModelIndex, role=Qt.DisplayRole): i = index.row() participant = self.simulator_config.active_participants[i] if not index.isValid(): return None if role == Qt.DisplayRole: return participant.name + " (" + participant.shortname + ")" elif role == Qt.CheckStateRole: return Qt.Checked if participant.simulate else Qt.Unchecked
Example #14
Source File: SimulatorParticipantListModel.py From urh with GNU General Public License v3.0 | 5 votes |
def setData(self, index: QModelIndex, value, role=None): i = index.row() participants = self.simulator_config.active_participants if role == Qt.CheckStateRole: participants[i].simulate = value self.update() self.participant_simulate_changed.emit(participants[i]) return True
Example #15
Source File: MessageTypeTableView.py From urh with GNU General Public License v3.0 | 5 votes |
def on_show_all_action_triggered(self): for i in range(self.model().rowCount()): self.model().setData(self.model().index(i, 0), Qt.Checked, role=Qt.CheckStateRole)
Example #16
Source File: qtmodels.py From QualCoder with MIT License | 5 votes |
def setData(self,index, value, role): key = self._row_to_key[index.row()] if role == Qt.CheckStateRole: self._checkstate[key] = value self.checkstate_changed.emit(key,bool(value)) return True
Example #17
Source File: test_simulator_tab_gui.py From urh with GNU General Public License v3.0 | 5 votes |
def test_participants_list(self): alice = Participant("Alice", "A") bob = Participant("Bob", "B") self.form.project_manager.participants.append(alice) self.form.project_manager.participants.append(bob) self.form.project_manager.project_updated.emit() mt = self.form.compare_frame_controller.proto_analyzer.default_message_type msg1 = SimulatorMessage(destination=alice, plain_bits=array("B", [1, 0, 1, 1]), pause=100, message_type=mt) msg2 = SimulatorMessage(destination=bob, plain_bits=array("B", [1, 0, 1, 1]), pause=100, message_type=mt) simulator_manager = self.form.simulator_tab_controller.simulator_config simulator_manager.add_items([msg1, msg2], 0, simulator_manager.rootItem) simulator_manager.add_label(5, 15, "test", parent_item=simulator_manager.rootItem.children[0]) stc = self.form.simulator_tab_controller # type: SimulatorTabController model = stc.ui.listViewSimulate.model() self.assertEqual(model.rowCount(), 2) self.assertEqual(model.data(model.index(0, 0)), "Alice (A)") self.assertEqual(model.data(model.index(1, 0)), "Bob (B)") self.assertFalse(self.form.project_manager.participants[0].simulate) self.assertEqual(model.data(model.index(0, 0), role=Qt.CheckStateRole), Qt.Unchecked) self.assertFalse(self.form.project_manager.participants[1].simulate) self.assertEqual(model.data(model.index(1, 0), role=Qt.CheckStateRole), Qt.Unchecked) model.setData(model.index(0, 0), Qt.Checked, role=Qt.CheckStateRole) self.assertTrue(self.form.project_manager.participants[0].simulate)
Example #18
Source File: qtmodels.py From QualCoder with MIT License | 5 votes |
def data(self,index,role): idx = index.row() if role == Qt.DisplayRole: return self.nativedata[idx][self.key] elif role == Qt.ForegroundRole: return QtGui.QBrush(Qt.black) elif role == Qt.BackgroundRole: return QtGui.QBrush(QtGui.QColor(self.nativedata[idx].get('color',Qt.white))) elif role == Qt.CheckStateRole: return self._checkstate.get(key,Qt.CheckState.Unchecked)
Example #19
Source File: qtmodels.py From QualCoder with MIT License | 5 votes |
def setData(self,index, value, role): key = self._row_to_key[index.row()] if role == Qt.CheckStateRole: self._checkstate[key] = value self.checkstate_changed.emit(key,bool(value)) return True
Example #20
Source File: qtmodels.py From QualCoder with MIT License | 5 votes |
def data(self,index,role): if index.isValid(): key = self._row_to_key[index.row()] if role == Qt.DisplayRole: if self.key is None: return key else: return self.nativedata[key][self.key] elif role == Qt.ForegroundRole: return QtGui.QBrush(Qt.black) elif role == Qt.BackgroundRole: return QtGui.QBrush(QtGui.QColor(self.nativedata[key].get('color',Qt.white))) elif role == Qt.CheckStateRole: return self._checkstate.get(key,Qt.CheckState.Unchecked)
Example #21
Source File: extract_dialog.py From vorta with GNU General Public License v3.0 | 5 votes |
def data(self, index, role): if not index.isValid(): return None item = index.internalPointer() if role == Qt.DisplayRole: return item.data(index.column()) elif role == Qt.CheckStateRole and index.column() == 0: return item.getCheckedState() else: return None
Example #22
Source File: ProtocolTreeModel.py From urh with GNU General Public License v3.0 | 5 votes |
def setData(self, index: QModelIndex, value, role=None): item = self.getItem(index) if role == Qt.EditRole and len(value) > 0: item.setData(value) return True elif role == Qt.CheckStateRole: item.show = value return True return False
Example #23
Source File: PluginListModel.py From urh with GNU General Public License v3.0 | 5 votes |
def setData(self, index: QModelIndex, value, role=None): if role == Qt.CheckStateRole: self.plugins[index.row()].enabled = value return True
Example #24
Source File: PluginListModel.py From urh with GNU General Public License v3.0 | 5 votes |
def data(self, index: QModelIndex, role=None): row = index.row() if role == Qt.DisplayRole: return self.plugins[row].name elif role == Qt.CheckStateRole: return self.plugins[row].enabled elif role == Qt.TextColorRole and self.plugins[row] in self.highlighted_plugins: return settings.HIGHLIGHT_TEXT_FOREGROUND_COLOR elif role == Qt.BackgroundColorRole and self.plugins[row] in self.highlighted_plugins: return settings.HIGHLIGHT_TEXT_BACKGROUND_COLOR elif role == Qt.FontRole and self.plugins[row] in self.highlighted_plugins: font = QFont() font.setBold(True) return font
Example #25
Source File: OptionsDialog.py From urh with GNU General Public License v3.0 | 5 votes |
def data(self, index: QModelIndex, role=Qt.DisplayRole): if not index.isValid(): return None i = index.row() j = index.column() device = self.get_device_at(i) if role == Qt.DisplayRole: if j == 0: return self.backend_handler.DEVICE_NAMES[i] elif j == 1: if device.is_enabled: if device.supports_rx and device.supports_tx: device_info = "supports RX and TX" elif device.supports_rx and not device.supports_tx: device_info = "supports RX only" elif not device.supports_rx and device.supports_tx: device_info = "supports TX only" else: device_info = "" else: device_info = "disabled" return device_info elif j == 2: return "" if device.has_native_backend else "not available" elif j == 3: return "" if device.has_gnuradio_backend else "not available" elif role == Qt.CheckStateRole: if j == 0 and (device.has_native_backend or device.has_gnuradio_backend): return Qt.Checked if device.is_enabled else Qt.Unchecked elif j == 2 and device.has_native_backend: return Qt.Checked if device.selected_backend == Backends.native else Qt.Unchecked elif j == 3 and device.has_gnuradio_backend: return Qt.Checked if device.selected_backend == Backends.grc else Qt.Unchecked
Example #26
Source File: qcheckcombobox.py From artisan with GNU General Public License v3.0 | 5 votes |
def setItemCheckState(self, index, state): """ Set the check state for item at `index` to `state`. Parameters ---------- index : int state : Qt.CheckState """ self.setItemData(index, state, Qt.CheckStateRole)
Example #27
Source File: qcheckcombobox.py From artisan with GNU General Public License v3.0 | 5 votes |
def itemCheckState(self, index): """ Return the check state for item at `index` Parameters ---------- index : int Returns ------- state : Qt.CheckState """ state = self.itemData(index, role=Qt.CheckStateRole) if isinstance(state, int): return Qt.CheckState(state) else: return Qt.Unchecked
Example #28
Source File: tabmodel_z6.py From python101 with MIT License | 5 votes |
def setData(self, index, value, rola=Qt.DisplayRole): """ Zmiana danych """ i = index.row() j = index.column() if rola == Qt.EditRole and j == 1: self.tabela[i][j] = value elif rola == Qt.CheckStateRole and (j == 3 or j == 4): if value: self.tabela[i][j] = True else: self.tabela[i][j] = False return True
Example #29
Source File: tabmodel_z5.py From python101 with MIT License | 5 votes |
def setData(self, index, value, rola=Qt.DisplayRole): """ Zmiana danych """ i = index.row() j = index.column() if rola == Qt.EditRole and j == 1: self.tabela[i][j] = value elif rola == Qt.CheckStateRole and (j == 3 or j == 4): if value: self.tabela[i][j] = True else: self.tabela[i][j] = False return True
Example #30
Source File: qt.py From mint-amazon-tagger with GNU General Public License v3.0 | 5 votes |
def setData(self, index, value, role): if not index.isValid(): return False if role == Qt.CheckStateRole and index.column() == 0: self.my_data[index.row()][index.column() + 1] = value == Qt.Checked self.dataChanged.emit(index, index) return True