本文整理汇总了Python中PyQt5.QtCore.Qt.ItemIsEditable方法的典型用法代码示例。如果您正苦于以下问题:Python Qt.ItemIsEditable方法的具体用法?Python Qt.ItemIsEditable怎么用?Python Qt.ItemIsEditable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.Qt
的用法示例。
在下文中一共展示了Qt.ItemIsEditable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: paint
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import ItemIsEditable [as 别名]
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)
示例2: editorEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import ItemIsEditable [as 别名]
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
示例3: flags
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import ItemIsEditable [as 别名]
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
示例4: flags
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import ItemIsEditable [as 别名]
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
示例5: flags
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import ItemIsEditable [as 别名]
def flags(self, index):
return Qt.ItemIsEditable | Qt.ItemIsEnabled | Qt.ItemIsSelectable
示例6: flags
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import ItemIsEditable [as 别名]
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)
示例7: flags
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import ItemIsEditable [as 别名]
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)
示例8: flags
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import ItemIsEditable [as 别名]
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
示例9: flags
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import ItemIsEditable [as 别名]
def flags(self, QModelIndex):
return Qt.ItemIsEditable | Qt.ItemIsSelectable | Qt.ItemIsEnabled
示例10: createGUI
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import ItemIsEditable [as 别名]
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")
示例11: createGUI
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import ItemIsEditable [as 别名]
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")
示例12: flags
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import ItemIsEditable [as 别名]
def flags(self, index):
base_flag = Qt.ItemIsEnabled | Qt.ItemIsSelectable
if self.is_editable:
return base_flag | Qt.ItemIsEditable
else:
return base_flag
示例13: flags
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import ItemIsEditable [as 别名]
def flags(self, index):
f = Qt.ItemIsEnabled | Qt.ItemIsSelectable
if index.column() == 0:
f = f | Qt.ItemIsUserCheckable | Qt.ItemIsEditable
return f
示例14: _redraw_strcol
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import ItemIsEditable [as 别名]
def _redraw_strcol(self, row):
start = self.row_size * row
end = start + self.row_size
data = self.data[start:end]
print_data = printable_data(data, include_newline=False)
item = QTableWidgetItem(print_data)
item.setFlags(item.flags() ^ Qt.ItemIsEditable)
self.datatable.setItem(row, self.str_col, item)
示例15: redraw_table
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import ItemIsEditable [as 别名]
def redraw_table(self, length=None):
with DisableUpdates(self.datatable):
oldsig = self.datatable.blockSignals(True)
self.row_size = length or self.row_size
self.datatable.setColumnCount(self.row_size + 1)
self.datatable.setRowCount(0)
self.str_col = self.row_size
self.datatable.horizontalHeader().hide()
self.datatable.verticalHeader().hide()
rows = int(len(self.data) / self.row_size)
if len(self.data) % self.row_size > 0:
rows += 1
self.datatable.setRowCount(rows)
for i in range(rows * self.row_size):
row = i / self.row_size
col = i % self.row_size
if i < len(self.data):
dataval = "%02x" % self.data[i]
item = QTableWidgetItem(dataval)
if self.read_only:
item.setFlags(item.flags() ^ Qt.ItemIsEditable)
else:
item = QTableWidgetItem("")
item.setFlags(item.flags() ^ Qt.ItemIsEditable)
self.datatable.setItem(row, col, item)
for row in range(rows):
self._redraw_strcol(row)
self.datatable.blockSignals(oldsig)
self.datatable.resizeColumnsToContents()
self.datatable.resizeRowsToContents()