本文整理汇总了Python中PyQt5.Qt.QTableWidgetItem.setCheckState方法的典型用法代码示例。如果您正苦于以下问题:Python QTableWidgetItem.setCheckState方法的具体用法?Python QTableWidgetItem.setCheckState怎么用?Python QTableWidgetItem.setCheckState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.Qt.QTableWidgetItem
的用法示例。
在下文中一共展示了QTableWidgetItem.setCheckState方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: populate_table_row
# 需要导入模块: from PyQt5.Qt import QTableWidgetItem [as 别名]
# 或者: from PyQt5.Qt.QTableWidgetItem import setCheckState [as 别名]
def populate_table_row(self, row, line):
if True:
checkbox_cell = QTableWidgetItem()
checkbox_cell.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
checkbox_cell.setCheckState(Qt.Unchecked)
checkbox_cell.setToolTip(_('Checked sections will be included in <i>all</i> split books.<br>Default title will still be taken from the first <i>selected</i> section, and section order will remain as shown.')+
'<br>'+_('Use Context Menu (right-click) on selected sections to check or uncheck all selected sections.'))
self.setItem(row, 0, checkbox_cell)
href = line['href']
if line['anchor']:
href = "%s#%s"%(href,line['anchor'])
href_cell = ReadOnlyTableWidgetItem(href)
href_cell.setToolTip(line['sample']+SAMPLE_NOTE)
self.setItem(row, 1, href_cell)
if 'guide' in line:
guide = "(%s):%s"%line['guide']
else:
guide = ""
guide_cell = ReadOnlyTableWidgetItem(guide)
guide_cell.setToolTip(_("Indicates 'special' pages: copyright, titlepage, etc."))
self.setItem(row, 2, guide_cell)
toc_str = "|".join(line['toc'])
toc_cell = QTableWidgetItem(toc_str)
toc_cell.setData(Qt.UserRole, toc_str)
toc_cell.setToolTip(_('''Click and copy hotkey to copy text.
Double-click to edit ToC entry.
Pipes(|) divide different ToC entries to the same place.'''))
self.setItem(row, 3, toc_cell)
示例2: setup_row
# 需要导入模块: from PyQt5.Qt import QTableWidgetItem [as 别名]
# 或者: from PyQt5.Qt.QTableWidgetItem import setCheckState [as 别名]
def setup_row(self, field_metadata, row, col, oldkey=None):
flags = Qt.ItemIsEnabled | Qt.ItemIsSelectable
item = QTableWidgetItem(col)
item.setFlags(flags)
self.opt_columns.setItem(row, 1, item)
if col.startswith('#'):
fm = self.custcols[oldkey if oldkey is not None else col]
else:
fm = field_metadata[col]
if col == 'title':
coltype = _('Text')
elif col == 'ondevice':
coltype = _('Yes/No with text')
else:
dt = fm['datatype']
if fm['is_multiple']:
if col == 'authors' or fm.get('display', {}).get('is_names', False):
coltype = _('Ampersand separated text, shown in the Tag browser')
else:
coltype = self.column_desc['*' + dt]
else:
coltype = self.column_desc[dt]
coltype_info = (coltype if oldkey is None else
' ' + _('(lookup name was {0}) {1}'.format(oldkey, coltype)))
item = QTableWidgetItem(coltype_info)
item.setFlags(flags)
self.opt_columns.setItem(row, 2, item)
desc = fm['display'].get('description', "")
item = QTableWidgetItem(desc)
item.setFlags(flags)
self.opt_columns.setItem(row, 3, item)
item = QTableWidgetItem(fm['name'])
item.setData(Qt.UserRole, (col))
item.setFlags(flags)
self.opt_columns.setItem(row, 0, item)
if col.startswith('#'):
item.setData(Qt.DecorationRole, (QIcon(I('column.png'))))
if col != 'ondevice':
flags |= Qt.ItemIsUserCheckable
item.setFlags(flags)
if col != 'ondevice':
item.setCheckState(Qt.Unchecked if col in self.hidden_cols else
Qt.Checked)
示例3: update_table
# 需要导入模块: from PyQt5.Qt import QTableWidgetItem [as 别名]
# 或者: from PyQt5.Qt.QTableWidgetItem import setCheckState [as 别名]
def update_table(self, init=False):
if init:
self.init_table()
records = DatabaseManager.get_all_keyboards()
self.keyboard_table.setRowCount(records[0])
for idx, record in enumerate(records[1]):
self.keyboard_table.setItem(idx, 1, QTableWidgetItem(record.language_name))
self.keyboard_table.setItem(idx, 2, QTableWidgetItem(str(record.id)))
chk_box = QTableWidgetItem()
chk_box.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
chk_box.setCheckState(Qt.Unchecked)
self.keyboard_table.setItem(idx, 0, chk_box)
self.keyboard_table.resizeRowsToContents()
return
示例4: __init__
# 需要导入模块: from PyQt5.Qt import QTableWidgetItem [as 别名]
# 或者: from PyQt5.Qt.QTableWidgetItem import setCheckState [as 别名]
def __init__(self, parent, items):
QDialog.__init__(self, parent)
Ui_DeleteMatchingFromDeviceDialog.__init__(self)
self.setupUi(self)
self.explanation.setText('<p>'+_('All checked books will be '
'<b>permanently deleted</b> from your '
'device. Please verify the list.')+'</p>')
self.buttonBox.accepted.connect(self.accepted)
self.buttonBox.rejected.connect(self.rejected)
self.table.cellClicked.connect(self.cell_clicked)
self.table.setSelectionMode(QAbstractItemView.NoSelection)
self.table.setColumnCount(7)
self.table.setHorizontalHeaderLabels(
['', _('Location'), _('Title'), _('Author'),
_('Date'), _('Format'), _('Path')])
rows = 0
for card in items:
rows += len(items[card][1])
self.table.setRowCount(rows)
row = 0
for card in items:
(model,books) = items[card]
for (id,book) in books:
item = QTableWidgetItem()
item.setFlags(Qt.ItemIsUserCheckable|Qt.ItemIsEnabled)
item.setCheckState(Qt.Checked)
item.setData(Qt.UserRole, (model, id, book.path))
self.table.setItem(row, 0, item)
self.table.setItem(row, 1, tableItem(card))
self.table.setItem(row, 2, titleTableItem(book.title))
self.table.setItem(row, 3, authorTableItem(book))
self.table.setItem(row, 4, dateTableItem(book.datetime))
self.table.setItem(row, 5, centeredTableItem(book.path.rpartition('.')[2]))
self.table.setItem(row, 6, tableItem(book.path))
row += 1
self.table.setCurrentCell(0, 1)
self.table.resizeColumnsToContents()
self.table.setSortingEnabled(True)
self.table.sortByColumn(2, Qt.AscendingOrder)
self.table.setCurrentCell(0, 1)
示例5: setup_row
# 需要导入模块: from PyQt5.Qt import QTableWidgetItem [as 别名]
# 或者: from PyQt5.Qt.QTableWidgetItem import setCheckState [as 别名]
def setup_row(self, field_metadata, row, col):
item = QTableWidgetItem(col)
self.opt_columns.setItem(row, 1, item)
if col.startswith('#'):
fm = self.custcols[col]
else:
fm = field_metadata[col]
if col == 'title':
coltype = _('Text')
elif col == 'ondevice':
coltype = _('Yes/No with text')
else:
dt = fm['datatype']
if fm['is_multiple']:
dt = '*' + dt
coltype = self.column_desc[dt]
item = QTableWidgetItem(coltype)
self.opt_columns.setItem(row, 2, item)
desc = fm['display'].get('description', "")
item = QTableWidgetItem(desc)
self.opt_columns.setItem(row, 3, item)
item = QTableWidgetItem(fm['name'])
item.setData(Qt.UserRole, (col))
self.opt_columns.setItem(row, 0, item)
if col.startswith('#'):
item.setData(Qt.DecorationRole, (QIcon(I('column.png'))))
flags = Qt.ItemIsEnabled|Qt.ItemIsSelectable
if col != 'ondevice':
flags |= Qt.ItemIsUserCheckable
item.setFlags(flags)
if col != 'ondevice':
item.setCheckState(Qt.Unchecked if col in self.hidden_cols else
Qt.Checked)